mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
itest: fix wrong node queried for balance
This commit is contained in:
parent
23baa75c09
commit
a60db53a5a
@ -3546,6 +3546,15 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
|
||||
err)
|
||||
}
|
||||
|
||||
// Calculate the total fee Carol paid.
|
||||
var totalFeeCarol btcutil.Amount
|
||||
for _, tx := range sweepTxns {
|
||||
fee, err := getTxFee(net.Miner.Client, tx)
|
||||
require.NoError(t.t, err)
|
||||
|
||||
totalFeeCarol += fee
|
||||
}
|
||||
|
||||
// We look up the sweep txns we have found in mempool and create
|
||||
// expected resolutions for carol.
|
||||
carolCommit, carolAnchor := findCommitAndAnchor(
|
||||
@ -3651,7 +3660,9 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
|
||||
// At this point, the CSV will expire in the next block, meaning that
|
||||
// the sweeping transaction should now be broadcast. So we fetch the
|
||||
// node's mempool to ensure it has been properly broadcast.
|
||||
sweepingTXID, err := waitForTxInMempool(net.Miner.Client, minerMempoolTimeout)
|
||||
sweepingTXID, err := waitForTxInMempool(
|
||||
net.Miner.Client, minerMempoolTimeout,
|
||||
)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to get sweep tx from mempool: %v", err)
|
||||
}
|
||||
@ -4227,21 +4238,30 @@ func channelForceClosureTest(net *lntest.NetworkHarness, t *harnessTest,
|
||||
t.Fatalf(predErr.Error())
|
||||
}
|
||||
|
||||
// At this point, Bob should now be aware of his new immediately
|
||||
// At this point, Carol should now be aware of her new immediately
|
||||
// spendable on-chain balance, as it was Alice who broadcast the
|
||||
// commitment transaction.
|
||||
ctxt, _ = context.WithTimeout(ctxb, defaultTimeout)
|
||||
carolBalResp, err = net.Bob.WalletBalance(ctxt, carolBalReq)
|
||||
if err != nil {
|
||||
t.Fatalf("unable to get carol's balance: %v", err)
|
||||
}
|
||||
carolExpectedBalance := btcutil.Amount(carolStartingBalance) + pushAmt
|
||||
if btcutil.Amount(carolBalResp.ConfirmedBalance) < carolExpectedBalance {
|
||||
t.Fatalf("carol's balance is incorrect: expected %v got %v",
|
||||
carolExpectedBalance,
|
||||
carolBalResp.ConfirmedBalance)
|
||||
carolBalResp, err = carol.WalletBalance(ctxt, carolBalReq)
|
||||
require.NoError(t.t, err, "unable to get carol's balance")
|
||||
|
||||
// Carol's expected balance should be its starting balance plus the
|
||||
// push amount sent by Alice and minus the miner fee paid.
|
||||
carolExpectedBalance := btcutil.Amount(carolStartingBalance) +
|
||||
pushAmt - totalFeeCarol
|
||||
|
||||
// In addition, if this is an anchor-enabled channel, further add the
|
||||
// anchor size.
|
||||
if channelType == commitTypeAnchors {
|
||||
carolExpectedBalance += btcutil.Amount(anchorSize)
|
||||
}
|
||||
|
||||
require.Equal(
|
||||
t.t, carolExpectedBalance,
|
||||
btcutil.Amount(carolBalResp.ConfirmedBalance),
|
||||
"carol's balance is incorrect",
|
||||
)
|
||||
|
||||
// Finally, we check that alice and carol have the set of resolutions
|
||||
// we expect.
|
||||
assertReports(ctxb, t, alice, op, aliceReports)
|
||||
|
Loading…
Reference in New Issue
Block a user