@@ -64,21 +64,21 @@ func testBurnAssets(t *harnessTest) {
6464 // - 800 units to scriptKey4
6565 // anchor index 3 (automatic change output):
6666 // - 300 units to new script key
67- outputAmounts := []uint64 {1100 , 1200 , 1600 , 800 , 300 }
67+ outputAmounts := []uint64 {300 , 1100 , 1200 , 1600 , 800 }
6868 vPkt := tappsbt .ForInteractiveSend (
69- simpleAssetID , outputAmounts [0 ], scriptKey1 , 0 , 0 , 0 ,
69+ simpleAssetID , outputAmounts [1 ], scriptKey1 , 0 , 0 , 0 ,
7070 anchorInternalKeyDesc1 , asset .V0 , chainParams ,
7171 )
7272 tappsbt .AddOutput (
73- vPkt , outputAmounts [1 ], scriptKey2 , 0 , anchorInternalKeyDesc1 ,
73+ vPkt , outputAmounts [2 ], scriptKey2 , 0 , anchorInternalKeyDesc1 ,
7474 asset .V0 ,
7575 )
7676 tappsbt .AddOutput (
77- vPkt , outputAmounts [2 ], scriptKey3 , 1 , anchorInternalKeyDesc2 ,
77+ vPkt , outputAmounts [3 ], scriptKey3 , 1 , anchorInternalKeyDesc2 ,
7878 asset .V0 ,
7979 )
8080 tappsbt .AddOutput (
81- vPkt , outputAmounts [3 ], scriptKey4 , 2 , anchorInternalKeyDesc3 ,
81+ vPkt , outputAmounts [4 ], scriptKey4 , 2 , anchorInternalKeyDesc3 ,
8282 asset .V0 ,
8383 )
8484
@@ -120,7 +120,7 @@ func testBurnAssets(t *harnessTest) {
120120 Asset : & taprpc.BurnAssetRequest_AssetId {
121121 AssetId : simpleAssetID [:],
122122 },
123- AmountToBurn : outputAmounts [2 ],
123+ AmountToBurn : outputAmounts [3 ],
124124 ConfirmationText : taprootassets .AssetBurnConfirmationText ,
125125 })
126126 require .ErrorContains (
@@ -152,7 +152,7 @@ func testBurnAssets(t *harnessTest) {
152152 AssertAssetOutboundTransferWithOutputs (
153153 t .t , minerClient , t .tapd , burnResp .BurnTransfer ,
154154 simpleAssetGen .AssetId ,
155- []uint64 {burnAmt , outputAmounts [2 ] - burnAmt }, 1 , 2 , 2 , true ,
155+ []uint64 {outputAmounts [3 ] - burnAmt , burnAmt }, 1 , 2 , 2 , true ,
156156 )
157157
158158 // We'll now assert that the burned asset has the correct state.
@@ -175,11 +175,8 @@ func testBurnAssets(t *harnessTest) {
175175 t .t , t .tapd , simpleAssetGen .AssetId , simpleAsset .Amount - burnAmt ,
176176 )
177177
178- burns , err := t .tapd .ListBurns (ctxt , & taprpc.ListBurnsRequest {})
179- require .NoError (t .t , err )
180-
181- require .Len (t .t , burns .Burns , 1 )
182- burn := burns .Burns [0 ]
178+ burns := AssertNumBurns (t .t , t .tapd , 1 , nil )
179+ burn := burns [0 ]
183180 require .Equal (t .t , uint64 (burnAmt ), burn .Amount )
184181 require .Equal (t .t , burnResp .BurnTransfer .AnchorTxHash , burn .AnchorTxid )
185182 require .Equal (t .t , burn .AssetId , simpleAssetID [:])
@@ -188,7 +185,7 @@ func testBurnAssets(t *harnessTest) {
188185 // The burned asset should be pruned from the tree when we next spend
189186 // the anchor output it was in (together with the change). So let's test
190187 // that we can successfully spend the change output.
191- secondSendAmt := outputAmounts [2 ] - burnAmt
188+ secondSendAmt := outputAmounts [3 ] - burnAmt
192189 fullSendAddr , stream := NewAddrWithEventStream (
193190 t .t , t .tapd , & taprpc.NewAddrRequest {
194191 AssetId : simpleAssetGen .AssetId ,
@@ -232,7 +229,7 @@ func testBurnAssets(t *harnessTest) {
232229 // two largest inputs we have, the one over 1500 we sent above and the
233230 // 1200 from the initial fan out transfer.
234231 const changeAmt = 300
235- multiBurnAmt := outputAmounts [1 ] + secondSendAmt - changeAmt
232+ multiBurnAmt := outputAmounts [2 ] + secondSendAmt - changeAmt
236233 burnResp , err = t .tapd .BurnAsset (ctxt , & taprpc.BurnAssetRequest {
237234 Asset : & taprpc.BurnAssetRequest_AssetId {
238235 AssetId : simpleAssetGen .AssetId ,
@@ -250,7 +247,7 @@ func testBurnAssets(t *harnessTest) {
250247 AssertAssetOutboundTransferWithOutputs (
251248 t .t , minerClient , t .tapd , burnResp .BurnTransfer ,
252249 simpleAssetGen .AssetId ,
253- []uint64 {multiBurnAmt , changeAmt }, 4 , 5 , 2 , true ,
250+ []uint64 {changeAmt , multiBurnAmt }, 4 , 5 , 2 , true ,
254251 )
255252
256253 // Our final asset balance should be reduced by both successful burn
@@ -290,18 +287,15 @@ func testBurnAssets(t *harnessTest) {
290287 AssertAssetOutboundTransferWithOutputs (
291288 t .t , minerClient , t .tapd , burnResp .BurnTransfer ,
292289 simpleGroupGen .AssetId ,
293- []uint64 {burnAmt , simpleGroup .Amount - burnAmt }, 5 , 6 , 2 , true ,
290+ []uint64 {simpleGroup .Amount - burnAmt , burnAmt }, 5 , 6 , 2 , true ,
294291 )
295292 AssertBalanceByID (
296293 t .t , t .tapd , simpleGroupGen .AssetId , simpleGroup .Amount - burnAmt ,
297294 )
298295
299- burns , err = t .tapd .ListBurns (ctxt , & taprpc.ListBurnsRequest {})
300- require .NoError (t .t , err )
301-
302- require .Len (t .t , burns .Burns , 4 )
296+ burns = AssertNumBurns (t .t , t .tapd , 4 , nil )
303297 var groupBurn * taprpc.AssetBurn
304- for _ , b := range burns . Burns {
298+ for _ , b := range burns {
305299 if bytes .Equal (b .AssetId , simpleGroupGen .AssetId ) {
306300 groupBurn = b
307301 }
@@ -356,30 +350,21 @@ func testBurnAssets(t *harnessTest) {
356350
357351 // Fetch the burns related to the simple asset id, which should have a
358352 // total of 2 burns (tc1 & tc4).
359- burns , err = t .tapd . ListBurns ( ctxt , & taprpc.ListBurnsRequest {
353+ AssertNumBurns ( t . t , t .tapd , 2 , & taprpc.ListBurnsRequest {
360354 AssetId : simpleAssetGen .AssetId ,
361355 })
362- require .NoError (t .t , err )
363-
364- require .Len (t .t , burns .Burns , 2 )
365356
366357 // Fetch the burns related to the group key of the grouped asset in tc5.
367358 // There should be 1 burn.
368- burns , err = t .tapd . ListBurns ( ctxt , & taprpc.ListBurnsRequest {
359+ AssertNumBurns ( t . t , t .tapd , 1 , & taprpc.ListBurnsRequest {
369360 TweakedGroupKey : simpleGroup .AssetGroup .TweakedGroupKey ,
370361 })
371- require .NoError (t .t , err )
372-
373- require .Len (t .t , burns .Burns , 1 )
374362
375363 // Fetch the burns associated with the txhash of the burn in tc5. There
376364 // should be 1 burn returned.
377- burns , err = t .tapd . ListBurns ( ctxt , & taprpc.ListBurnsRequest {
365+ AssertNumBurns ( t . t , t .tapd , 1 , & taprpc.ListBurnsRequest {
378366 AnchorTxid : groupBurnTxHash ,
379367 })
380- require .NoError (t .t , err )
381-
382- require .Len (t .t , burns .Burns , 1 )
383368}
384369
385370// testBurnGroupedAssets tests that some amount of an asset from an asset group
@@ -464,7 +449,7 @@ func testBurnGroupedAssets(t *harnessTest) {
464449 // Assert that the asset burn transfer occurred correctly.
465450 AssertAssetOutboundTransferWithOutputs (
466451 t .t , miner , t .tapd , burnResp .BurnTransfer ,
467- burnAssetID , []uint64 {burnAmt , postBurnAmt }, 0 , 1 , 2 , true ,
452+ burnAssetID , []uint64 {postBurnAmt , burnAmt }, 0 , 1 , 2 , true ,
468453 )
469454
470455 // Ensure that the burnt asset has the correct state.
0 commit comments