Skip to content

Commit 0011bcd

Browse files
authored
Merge pull request #2229 from halseth/global-defaultcsv
lnd_test: make tests use global defaultCSV
2 parents 6d4a769 + ec76a25 commit 0011bcd

File tree

1 file changed

+10
-22
lines changed

1 file changed

+10
-22
lines changed

lnd_test.go

+10-22
Original file line numberDiff line numberDiff line change
@@ -2182,7 +2182,6 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
21822182

21832183
// TODO(roasbeef): should check default value in config here
21842184
// instead, or make delay a param
2185-
defaultCSV := uint32(4)
21862185
defaultCLTV := uint32(defaultBitcoinTimeLockDelta)
21872186

21882187
// Since we'd like to test failure scenarios with outstanding htlcs,
@@ -5594,7 +5593,6 @@ func testFailingChannel(net *lntest.NetworkHarness, t *harnessTest) {
55945593
const (
55955594
timeout = time.Duration(time.Second * 10)
55965595
paymentAmt = 10000
5597-
defaultCSV = 4
55985596
)
55995597

56005598
chanAmt := maxFundingAmount
@@ -6986,7 +6984,6 @@ func testDataLossProtection(net *lntest.NetworkHarness, t *harnessTest) {
69866984
chanAmt = maxBtcFundingAmount
69876985
paymentAmt = 10000
69886986
numInvoices = 6
6989-
defaultCSV = uint32(4)
69906987
)
69916988

69926989
// Carol will be the up-to-date party. We set --nolisten to ensure Dave
@@ -8726,7 +8723,6 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) {
87268723
dustHtlcAmt = btcutil.Amount(100)
87278724
htlcAmt = btcutil.Amount(30000)
87288725
finalCltvDelta = 40
8729-
csvDelay = 4
87308726
)
87318727
alicePayStream, err := net.Alice.SendPayment(ctxb)
87328728
if err != nil {
@@ -8816,9 +8812,9 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) {
88168812
t.Fatalf("htlc mismatch: %v", predErr)
88178813
}
88188814

8819-
// We'll mine csvDelay blocks in order to generate the sweep transaction
8815+
// We'll mine defaultCSV blocks in order to generate the sweep transaction
88208816
// of Bob's funding output.
8821-
if _, err := net.Miner.Node.Generate(csvDelay); err != nil {
8817+
if _, err := net.Miner.Node.Generate(defaultCSV); err != nil {
88228818
t.Fatalf("unable to generate blocks: %v", err)
88238819
}
88248820

@@ -8829,7 +8825,7 @@ func testMultiHopHtlcLocalTimeout(net *lntest.NetworkHarness, t *harnessTest) {
88298825

88308826
// We'll now mine the remaining blocks to cause the HTLC itself to
88318827
// timeout.
8832-
if _, err := net.Miner.Node.Generate(defaultBroadcastDelta - csvDelay); err != nil {
8828+
if _, err := net.Miner.Node.Generate(defaultBroadcastDelta - defaultCSV); err != nil {
88338829
t.Fatalf("unable to generate blocks: %v", err)
88348830
}
88358831

@@ -8943,8 +8939,6 @@ func testMultiHopReceiverChainClaim(net *lntest.NetworkHarness, t *harnessTest)
89438939
timeout := time.Duration(time.Second * 15)
89448940
ctxb := context.Background()
89458941

8946-
defaultCSV := uint32(4)
8947-
89488942
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
89498943
// Carol refusing to actually settle or directly cancel any HTLC's
89508944
// self.
@@ -9184,7 +9178,6 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
91849178
// to Carol. As Carol is in hodl mode, she won't settle this HTLC which
91859179
// opens up the base for out tests.
91869180
const (
9187-
csvDelay = 4
91889181
finalCltvDelta = 40
91899182
htlcAmt = btcutil.Amount(30000)
91909183
)
@@ -9259,9 +9252,9 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
92599252
t.Fatalf(predErr.Error())
92609253
}
92619254

9262-
// We'll mine csvDelay blocks in order to generate the sweep transaction
9255+
// We'll mine defaultCSV blocks in order to generate the sweep transaction
92639256
// of Bob's funding output.
9264-
if _, err := net.Miner.Node.Generate(csvDelay); err != nil {
9257+
if _, err := net.Miner.Node.Generate(defaultCSV); err != nil {
92659258
t.Fatalf("unable to generate blocks: %v", err)
92669259
}
92679260

@@ -9272,7 +9265,7 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
92729265

92739266
// We'll now mine enough blocks for the HTLC to expire. After this, Bob
92749267
// should hand off the now expired HTLC output to the utxo nursery.
9275-
if _, err := net.Miner.Node.Generate(finalCltvDelta - csvDelay - 1); err != nil {
9268+
if _, err := net.Miner.Node.Generate(finalCltvDelta - defaultCSV - 1); err != nil {
92769269
t.Fatalf("unable to generate blocks: %v", err)
92779270
}
92789271

@@ -9377,7 +9370,7 @@ func testMultiHopLocalForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
93779370
// We'll now mine 4 additional blocks. This should be enough for Bob's
93789371
// CSV timelock to expire and the sweeping transaction of the HTLC to be
93799372
// broadcast.
9380-
if _, err := net.Miner.Node.Generate(csvDelay); err != nil {
9373+
if _, err := net.Miner.Node.Generate(defaultCSV); err != nil {
93819374
t.Fatalf("unable to mine blocks: %v", err)
93829375
}
93839376

@@ -9441,7 +9434,6 @@ func testMultiHopRemoteForceCloseOnChainHtlcTimeout(net *lntest.NetworkHarness,
94419434
// to Carol. As Carol is in hodl mode, she won't settle this HTLC which
94429435
// opens up the base for out tests.
94439436
const (
9444-
csvDelay = 4
94459437
finalCltvDelta = 40
94469438
htlcAmt = btcutil.Amount(30000)
94479439
)
@@ -9641,8 +9633,6 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
96419633
timeout := time.Duration(time.Second * 15)
96429634
ctxb := context.Background()
96439635

9644-
defaultCSV := uint32(4)
9645-
96469636
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
96479637
// Carol refusing to actually settle or directly cancel any HTLC's
96489638
// self.
@@ -9775,7 +9765,7 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
97759765
}
97769766

97779767
// Keep track of the second level tx maturity.
9778-
carolSecondLevelCSV := defaultCSV
9768+
carolSecondLevelCSV := uint32(defaultCSV)
97799769

97809770
// When Bob notices Carol's second level transaction in the block, he
97819771
// will extract the preimage and broadcast a second level tx to claim
@@ -9850,7 +9840,7 @@ func testMultiHopHtlcLocalChainClaim(net *lntest.NetworkHarness, t *harnessTest)
98509840

98519841
// Keep track of Bob's second level maturity, and decrement our track
98529842
// of Carol's.
9853-
bobSecondLevelCSV := defaultCSV
9843+
bobSecondLevelCSV := uint32(defaultCSV)
98549844
carolSecondLevelCSV--
98559845

98569846
// If we then mine 3 additional blocks, Carol's second level tx should
@@ -9967,8 +9957,6 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest
99679957
timeout := time.Duration(time.Second * 15)
99689958
ctxb := context.Background()
99699959

9970-
defaultCSV := uint32(4)
9971-
99729960
// First, we'll create a three hop network: Alice -> Bob -> Carol, with
99739961
// Carol refusing to actually settle or directly cancel any HTLC's
99749962
// self.
@@ -10123,7 +10111,7 @@ func testMultiHopHtlcRemoteChainClaim(net *lntest.NetworkHarness, t *harnessTest
1012310111
}
1012410112

1012510113
// Keep track of the second level tx maturity.
10126-
carolSecondLevelCSV := defaultCSV
10114+
carolSecondLevelCSV := uint32(defaultCSV)
1012710115

1012810116
// When Bob notices Carol's second level transaction in the block, he
1012910117
// will extract the preimage and broadcast a sweep tx to directly claim

0 commit comments

Comments
 (0)