itest: extend testAnchorReservedValue to open additional channels
We do this to trigger a bug that will be resolved in a follow-up commit. This bug prevents inbound legacy channels from being rejected by the recipient if they have at least one anchor channel already opened without an on-chain balance.
This commit is contained in:
parent
1287328678
commit
d7299802d4
@ -180,7 +180,8 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
err := net.ConnectNodes(ctxt, alice, bob)
|
err := net.ConnectNodes(ctxt, alice, bob)
|
||||||
require.NoError(t.t, err)
|
require.NoError(t.t, err)
|
||||||
|
|
||||||
// Send just enough coins for Alice to open a channel without a change output.
|
// Send just enough coins for Alice to open a channel without a change
|
||||||
|
// output.
|
||||||
const (
|
const (
|
||||||
chanAmt = 1000000
|
chanAmt = 1000000
|
||||||
feeEst = 8000
|
feeEst = 8000
|
||||||
@ -206,20 +207,45 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// Alice opens a smaller channel. This works since it will have a
|
// Alice opens a smaller channel. This works since it will have a
|
||||||
// change output.
|
// change output.
|
||||||
ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout)
|
ctxt, _ = context.WithTimeout(context.Background(), defaultTimeout)
|
||||||
aliceChanPoint := openChannelAndAssert(
|
aliceChanPoint1 := openChannelAndAssert(
|
||||||
ctxt, t, net, alice, bob,
|
ctxt, t, net, alice, bob,
|
||||||
lntest.OpenChannelParams{
|
lntest.OpenChannelParams{
|
||||||
Amt: chanAmt / 2,
|
Amt: chanAmt / 4,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
// If Alice tries to open another anchor channel to Bob, Bob should not
|
||||||
err = alice.WaitForNetworkChannelOpen(ctxt, aliceChanPoint)
|
// reject it as he is not contributing any funds.
|
||||||
require.NoError(t.t, err)
|
aliceChanPoint2 := openChannelAndAssert(
|
||||||
|
ctxt, t, net, alice, bob, lntest.OpenChannelParams{
|
||||||
|
Amt: chanAmt / 4,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
// Similarly, if Alice tries to open a legacy channel to Bob, Bob should
|
||||||
err = bob.WaitForNetworkChannelOpen(ctxt, aliceChanPoint)
|
// not reject it as he is not contributing any funds. We'll restart Bob
|
||||||
|
// to remove his support for anchors.
|
||||||
|
err = net.RestartNode(bob, nil)
|
||||||
require.NoError(t.t, err)
|
require.NoError(t.t, err)
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
|
aliceChanPoint3 := openChannelAndAssert(
|
||||||
|
ctxt, t, net, alice, bob, lntest.OpenChannelParams{
|
||||||
|
Amt: chanAmt / 4,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
chanPoints := []*lnrpc.ChannelPoint{
|
||||||
|
aliceChanPoint1, aliceChanPoint2, aliceChanPoint3,
|
||||||
|
}
|
||||||
|
for _, chanPoint := range chanPoints {
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
|
err = alice.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||||
|
require.NoError(t.t, err)
|
||||||
|
|
||||||
|
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||||
|
err = bob.WaitForNetworkChannelOpen(ctxt, chanPoint)
|
||||||
|
require.NoError(t.t, err)
|
||||||
|
}
|
||||||
|
|
||||||
// Alice tries to send all coins to an internal address. This is
|
// Alice tries to send all coins to an internal address. This is
|
||||||
// allowed, since the final wallet balance will still be above the
|
// allowed, since the final wallet balance will still be above the
|
||||||
@ -317,7 +343,9 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
|
|
||||||
// Alice closes channel, should now be allowed to send everything to an
|
// Alice closes channel, should now be allowed to send everything to an
|
||||||
// external address.
|
// external address.
|
||||||
closeChannelAndAssert(ctxt, t, net, alice, aliceChanPoint, false)
|
for _, chanPoint := range chanPoints {
|
||||||
|
closeChannelAndAssert(ctxt, t, net, alice, chanPoint, false)
|
||||||
|
}
|
||||||
|
|
||||||
newBalance := waitForConfirmedBalance()
|
newBalance := waitForConfirmedBalance()
|
||||||
if newBalance <= aliceBalance {
|
if newBalance <= aliceBalance {
|
||||||
@ -339,11 +367,11 @@ func testAnchorReservedValue(net *lntest.NetworkHarness, t *harnessTest) {
|
|||||||
// generated above.
|
// generated above.
|
||||||
block = mineBlocks(t, net, 1, 1)[0]
|
block = mineBlocks(t, net, 1, 1)[0]
|
||||||
|
|
||||||
// The sweep transaction should have two inputs, the change output from
|
// The sweep transaction should have four inputs, the change output from
|
||||||
// the previous sweep, and the output from the coop closed channel.
|
// the previous sweep, and the outputs from the coop closed channels.
|
||||||
sweepTx = block.Transactions[1]
|
sweepTx = block.Transactions[1]
|
||||||
if len(sweepTx.TxIn) != 2 {
|
if len(sweepTx.TxIn) != 4 {
|
||||||
t.Fatalf("expected 2 inputs instead have %v", len(sweepTx.TxIn))
|
t.Fatalf("expected 4 inputs instead have %v", len(sweepTx.TxIn))
|
||||||
}
|
}
|
||||||
|
|
||||||
// It should have a single output.
|
// It should have a single output.
|
||||||
|
Loading…
Reference in New Issue
Block a user