itest: enable anchor type for force close test
Co-authored-by: Johan T. Halseth <johanth@gmail.com>
This commit is contained in:
parent
714166eeb0
commit
23c81949cc
@ -3081,6 +3081,7 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
// outputs can be swept.
|
||||
commitTypes := []commitType{
|
||||
commitTypeLegacy,
|
||||
commitTypeAnchors,
|
||||
}
|
||||
|
||||
for _, channelType := range commitTypes {
|
||||
@ -3120,7 +3121,19 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
err)
|
||||
}
|
||||
|
||||
channelForceClosureTest(net, ht, alice, carol)
|
||||
// Also give Carol some coins to allow her to sweep her
|
||||
// anchor.
|
||||
err = net.SendCoins(
|
||||
ctxt, btcutil.SatoshiPerBitcoin, carol,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to send coins to Alice: %v",
|
||||
err)
|
||||
}
|
||||
|
||||
channelForceClosureTest(
|
||||
net, ht, alice, carol, channelType,
|
||||
)
|
||||
})
|
||||
if !success {
|
||||
return
|
||||
@ -3129,7 +3142,7 @@ func testChannelForceClosure(net *lntest.NetworkHarness, t *harnessTest) {
|
||||
}
|
||||
|
||||
func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
|
||||
alice, carol *lntest.HarnessNode) {
|
||||
alice, carol *lntest.HarnessNode, channelType commitType) {
|
||||
|
||||
ctxb := context.Background()
|
||||
|
||||
@ -3305,8 +3318,16 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
|
||||
}
|
||||
|
||||
// Mine a block which should confirm the commitment transaction
|
||||
// broadcast as a result of the force closure.
|
||||
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
|
||||
// broadcast as a result of the force closure. If there are anchors, we
|
||||
// also expect the anchor sweep tx to be in the mempool.
|
||||
expectedTxes := 1
|
||||
if channelType == commitTypeAnchors {
|
||||
expectedTxes = 2
|
||||
}
|
||||
|
||||
_, err = waitForNTxsInMempool(
|
||||
net.Miner.Node, expectedTxes, minerMempoolTimeout,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to find commitment in miner mempool: %v", err)
|
||||
}
|
||||
@ -3347,12 +3368,17 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
|
||||
}
|
||||
|
||||
// None of our outputs have been swept, so they should all be in
|
||||
// limbo.
|
||||
// limbo. For anchors, we expect the anchor amount to be
|
||||
// recovered.
|
||||
if forceClose.LimboBalance == 0 {
|
||||
return errors.New("all funds should still be in " +
|
||||
"limbo")
|
||||
}
|
||||
if forceClose.RecoveredBalance != 0 {
|
||||
expectedRecoveredBalance := int64(0)
|
||||
if channelType == commitTypeAnchors {
|
||||
expectedRecoveredBalance = anchorSize
|
||||
}
|
||||
if forceClose.RecoveredBalance != expectedRecoveredBalance {
|
||||
return errors.New("no funds should yet be shown " +
|
||||
"as recovered")
|
||||
}
|
||||
@ -3372,8 +3398,11 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
|
||||
}
|
||||
|
||||
// Carol's sweep tx should be in the mempool already, as her output is
|
||||
// not timelocked.
|
||||
_, err = waitForTxInMempool(net.Miner.Node, minerMempoolTimeout)
|
||||
// not timelocked. If there are anchors, we also expect Carol's anchor
|
||||
// sweep now.
|
||||
_, err = waitForNTxsInMempool(
|
||||
net.Miner.Node, expectedTxes, minerMempoolTimeout,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to find Carol's sweep in miner mempool: %v",
|
||||
err)
|
||||
@ -3435,7 +3464,11 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
|
||||
return errors.New("all funds should still be in " +
|
||||
"limbo")
|
||||
}
|
||||
if forceClose.RecoveredBalance != 0 {
|
||||
expectedRecoveredBalance := int64(0)
|
||||
if channelType == commitTypeAnchors {
|
||||
expectedRecoveredBalance = anchorSize
|
||||
}
|
||||
if forceClose.RecoveredBalance != expectedRecoveredBalance {
|
||||
return errors.New("no funds should yet be shown " +
|
||||
"as recovered")
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user