@@ -20,18 +20,23 @@ func testBurnAssets(t *harnessTest) {
2020 minerClient := t .lndHarness .Miner .Client
2121 rpcAssets := MintAssetsConfirmBatch (
2222 t .t , minerClient , t .tapd , []* mintrpc.MintAssetRequest {
23- simpleAssets [0 ], simpleAssets [1 ], issuableAssets [1 ],
23+ simpleAssets [0 ], simpleAssets [1 ], issuableAssets [0 ],
24+ issuableAssets [1 ],
2425 },
2526 )
2627
2728 // We first fan out the assets we have to different outputs.
2829 var (
29- chainParams = & address .RegressionNetTap
30- simpleAsset = rpcAssets [0 ]
31- simpleCollectible = rpcAssets [1 ]
32- simpleAssetGen = simpleAsset .AssetGenesis
33- simpleCollectibleGen = simpleCollectible .AssetGenesis
34- simpleAssetID [32 ]byte
30+ chainParams = & address .RegressionNetTap
31+ simpleAsset = rpcAssets [0 ]
32+ simpleCollectible = rpcAssets [1 ]
33+ simpleGroup = rpcAssets [2 ]
34+ simpleGroupCollect = rpcAssets [3 ]
35+ simpleAssetGen = simpleAsset .AssetGenesis
36+ simpleCollectibleGen = simpleCollectible .AssetGenesis
37+ simpleGroupGen = simpleGroup .AssetGenesis
38+ simpleGroupCollectGen = simpleGroupCollect .AssetGenesis
39+ simpleAssetID [32 ]byte
3540 )
3641 copy (simpleAssetID [:], simpleAssetGen .AssetId )
3742
@@ -59,8 +64,8 @@ func testBurnAssets(t *harnessTest) {
5964 // - 300 units to new script key
6065 outputAmounts := []uint64 {1100 , 1200 , 1600 , 800 , 300 }
6166 vPkt := tappsbt .ForInteractiveSend (
62- simpleAssetID , outputAmounts [0 ], scriptKey1 , 0 , anchorInternalKeyDesc1 ,
63- asset .V0 , chainParams ,
67+ simpleAssetID , outputAmounts [0 ], scriptKey1 , 0 ,
68+ anchorInternalKeyDesc1 , asset .V0 , chainParams ,
6469 )
6570 tappsbt .AddOutput (
6671 vPkt , outputAmounts [1 ], scriptKey2 , 0 , anchorInternalKeyDesc1 ,
@@ -233,4 +238,66 @@ func testBurnAssets(t *harnessTest) {
233238 t .t , t .tapd , simpleAssetGen .AssetId ,
234239 simpleAsset .Amount - burnAmt - multiBurnAmt ,
235240 )
241+
242+ resp , err := t .tapd .ListAssets (ctxt , & taprpc.ListAssetRequest {
243+ IncludeSpent : true ,
244+ })
245+ require .NoError (t .t , err )
246+ assets , err := formatProtoJSON (resp )
247+ require .NoError (t .t , err )
248+ t .Logf ("All assets before last burn: %v" , assets )
249+
250+ // Test case 5: Burn some units of a grouped asset. We start by making
251+ // sure we still have the full balance before burning.
252+ AssertBalanceByID (
253+ t .t , t .tapd , simpleGroupGen .AssetId , simpleGroup .Amount ,
254+ )
255+ burnResp , err = t .tapd .BurnAsset (ctxt , & taprpc.BurnAssetRequest {
256+ Asset : & taprpc.BurnAssetRequest_AssetId {
257+ AssetId : simpleGroupGen .AssetId ,
258+ },
259+ AmountToBurn : burnAmt ,
260+ ConfirmationText : taprootassets .AssetBurnConfirmationText ,
261+ })
262+ require .NoError (t .t , err )
263+
264+ burnRespJSON , err = formatProtoJSON (burnResp )
265+ require .NoError (t .t , err )
266+ t .Logf ("Got response from burning units from grouped asset: %v" ,
267+ burnRespJSON )
268+
269+ AssertAssetOutboundTransferWithOutputs (
270+ t .t , minerClient , t .tapd , burnResp .BurnTransfer ,
271+ simpleGroupGen .AssetId ,
272+ []uint64 {simpleGroup .Amount - burnAmt , burnAmt }, 5 , 6 , 2 , true ,
273+ )
274+ AssertBalanceByID (
275+ t .t , t .tapd , simpleGroupGen .AssetId , simpleGroup .Amount - burnAmt ,
276+ )
277+
278+ // Test case 6: Burn the single unit of a grouped collectible. We start
279+ // by making sure we still have the full balance before burning.
280+ AssertBalanceByID (
281+ t .t , t .tapd , simpleGroupCollectGen .AssetId ,
282+ simpleGroupCollect .Amount ,
283+ )
284+ burnResp , err = t .tapd .BurnAsset (ctxt , & taprpc.BurnAssetRequest {
285+ Asset : & taprpc.BurnAssetRequest_AssetId {
286+ AssetId : simpleGroupCollectGen .AssetId ,
287+ },
288+ AmountToBurn : 1 ,
289+ ConfirmationText : taprootassets .AssetBurnConfirmationText ,
290+ })
291+ require .NoError (t .t , err )
292+
293+ burnRespJSON , err = formatProtoJSON (burnResp )
294+ require .NoError (t .t , err )
295+ t .Logf ("Got response from burning units from grouped asset: %v" ,
296+ burnRespJSON )
297+
298+ AssertAssetOutboundTransferWithOutputs (
299+ t .t , minerClient , t .tapd , burnResp .BurnTransfer ,
300+ simpleGroupCollectGen .AssetId , []uint64 {1 }, 6 , 7 , 1 , true ,
301+ )
302+ AssertBalanceByID (t .t , t .tapd , simpleGroupCollectGen .AssetId , 0 )
236303}
0 commit comments