Skip to content

Commit f20a875

Browse files
committed
itest: fix fee estimation test assumptions
The fee estimation test assumed that UTXOs would be locked after an error and couldn't be used anymore. This is no longer the case and we need to adjust the test. We clean up the test a bit while we're at it.
1 parent 0198a10 commit f20a875

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

itest/assertions.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,10 @@ func AssertAssetOutboundTransferWithOutputs(t *testing.T,
11081108
out := transfer.Outputs[idx]
11091109
require.Contains(t, outpoints, out.Anchor.Outpoint)
11101110
require.Contains(t, scripts, string(out.ScriptKey))
1111-
require.Equal(t, expectedAmounts[idx], out.Amount)
1111+
require.Equalf(
1112+
t, expectedAmounts[idx], out.Amount,
1113+
"expected amounts: %v, transfer: %v",
1114+
expectedAmounts, toJSON(t, transfer))
11121115
}
11131116

11141117
firstIn := transfer.Inputs[0]

itest/fee_estimation_test.go

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,11 @@ func testFeeEstimation(t *harnessTest) {
6666
rpcAssets := MintAssetsConfirmBatch(
6767
t.t, t.lndHarness.Miner().Client, t.tapd, simpleAssets,
6868
)
69+
normalAsset := rpcAssets[0]
70+
normalAssetId := normalAsset.AssetGenesis.AssetId
6971

7072
// Check the final fee rate of the mint TX.
71-
rpcMintOutpoint := rpcAssets[0].ChainAnchor.AnchorOutpoint
73+
rpcMintOutpoint := normalAsset.ChainAnchor.AnchorOutpoint
7274
mintOutpoint, err := wire.NewOutPointFromString(rpcMintOutpoint)
7375
require.NoError(t.t, err)
7476

@@ -81,16 +83,15 @@ func testFeeEstimation(t *harnessTest) {
8183
)
8284

8385
// Split the normal asset to create a transfer with two anchor outputs.
84-
normalAssetId := rpcAssets[0].AssetGenesis.AssetId
85-
splitAmount := rpcAssets[0].Amount / 2
86+
splitAmount := normalAsset.Amount / 2
8687
addr, stream := NewAddrWithEventStream(
8788
t.t, t.tapd, &taprpc.NewAddrRequest{
8889
AssetId: normalAssetId,
8990
Amt: splitAmount,
9091
},
9192
)
9293

93-
AssertAddrCreated(t.t, t.tapd, rpcAssets[0], addr)
94+
AssertAddrCreated(t.t, t.tapd, normalAsset, addr)
9495
sendResp, sendEvents := sendAssetsToAddr(t, t.tapd, addr)
9596

9697
transferIdx := 0
@@ -121,7 +122,7 @@ func testFeeEstimation(t *harnessTest) {
121122
},
122123
)
123124

124-
AssertAddrCreated(t.t, t.tapd, rpcAssets[0], addr2)
125+
AssertAddrCreated(t.t, t.tapd, normalAsset, addr2)
125126
sendResp, sendEvents = sendAssetsToAddr(t, t.tapd, addr2)
126127

127128
ConfirmAndAssertOutboundTransfer(
@@ -157,7 +158,7 @@ func testFeeEstimation(t *harnessTest) {
157158
[]*UTXORequest{initialUTXOs[3]},
158159
)
159160

160-
AssertAddrCreated(t.t, t.tapd, rpcAssets[0], addr3)
161+
AssertAddrCreated(t.t, t.tapd, normalAsset, addr3)
161162
_, err = t.tapd.SendAsset(ctxt, &taprpc.SendAssetRequest{
162163
TapAddrs: []string{addr3.Encoded},
163164
})
@@ -166,23 +167,24 @@ func testFeeEstimation(t *harnessTest) {
166167
)
167168

168169
// The transfer should also be rejected if the manually-specified
169-
// feerate fails the sanity check against the fee estimator's fee floor
170+
// fee rate fails the sanity check against the fee estimator's fee floor
170171
// of 253 sat/kw, or 1.012 sat/vB.
171172
_, err = t.tapd.SendAsset(ctxt, &taprpc.SendAssetRequest{
172173
TapAddrs: []string{addr3.Encoded},
173174
FeeRate: uint32(chainfee.FeePerKwFloor) - 1,
174175
})
175176
require.ErrorContains(t.t, err, "manual fee rate below floor")
176177

177-
// After failure at the high feerate, we should still be able to make a
178-
// transfer at a very low feerate.
178+
// After failure at the high fee rate, we should still be able to make a
179+
// transfer at a very low fee rate.
179180
t.lndHarness.SetFeeEstimateWithConf(lowFeeRate, 6)
180181
sendResp, sendEvents = sendAssetsToAddr(t, t.tapd, addr3)
181182

182183
ConfirmAndAssertOutboundTransfer(
183184
t.t, t.lndHarness.Miner().Client, t.tapd, sendResp,
184-
normalAssetId, []uint64{thirdSplitAmount, thirdSplitAmount},
185-
transferIdx, transferIdx+1,
185+
normalAssetId, []uint64{
186+
splitAmount - thirdSplitAmount, thirdSplitAmount,
187+
}, transferIdx, transferIdx+1,
186188
)
187189
transferIdx += 1
188190
AssertNonInteractiveRecvComplete(t.t, t.tapd, transferIdx)

0 commit comments

Comments
 (0)