@@ -1045,7 +1045,9 @@ func testSupplyCommitMintBurn(t *harnessTest) {
10451045// 4. Calling FetchSupplyLeaves to verify burn leaves are included.
10461046// 5. Minting another tranche into the same group.
10471047// 6. Calling FetchSupplyLeaves to verify all leaves are present.
1048- // 7. Testing inclusion proof generation for various leaf types.
1048+ // 7. Ignoring an asset outpoint from the second mint.
1049+ // 8. Calling FetchSupplyLeaves to verify ignore leaves are included.
1050+ // 9. Testing inclusion proof generation for various leaf types.
10491051func testFetchSupplyLeaves (t * harnessTest ) {
10501052 ctxb := context .Background ()
10511053
@@ -1259,7 +1261,7 @@ func testFetchSupplyLeaves(t *harnessTest) {
12591261 expectedIssuanceTotal := int64 (
12601262 mintReq .Asset .Amount + secondMintReq .Asset .Amount ,
12611263 )
1262- _ , _ = WaitForSupplyCommit (
1264+ _ , supplyOutpoint = WaitForSupplyCommit (
12631265 t .t , ctxb , t .tapd , groupKeyBytes , fn .Some (supplyOutpoint ),
12641266 func (resp * unirpc.FetchSupplyCommitResponse ) bool {
12651267 return resp .IssuanceSubtreeRoot != nil &&
@@ -1302,6 +1304,103 @@ func testFetchSupplyLeaves(t *harnessTest) {
13021304 "total issuance amount mismatch" ,
13031305 )
13041306
1307+ t .Log ("Ignoring an asset outpoint from the second mint" )
1308+
1309+ // Get the outpoint from the second minted asset to ignore it.
1310+ // We must ignore the entire asset at the outpoint, not just a portion.
1311+ ignoreAmount := rpcSecondAsset [0 ].Amount
1312+ ignoreAssetOutpoint := taprpc.AssetOutPoint {
1313+ AnchorOutPoint : rpcSecondAsset [0 ].ChainAnchor .AnchorOutpoint ,
1314+ AssetId : rpcSecondAsset [0 ].AssetGenesis .AssetId ,
1315+ ScriptKey : rpcSecondAsset [0 ].ScriptKey ,
1316+ }
1317+ ignoreReq := & unirpc.IgnoreAssetOutPointRequest {
1318+ AssetOutPoint : & ignoreAssetOutpoint ,
1319+ Amount : ignoreAmount ,
1320+ }
1321+
1322+ respIgnore , err := t .tapd .IgnoreAssetOutPoint (ctxb , ignoreReq )
1323+ require .NoError (t .t , err )
1324+ require .NotNil (t .t , respIgnore )
1325+ require .EqualValues (t .t , ignoreAmount , respIgnore .Leaf .RootSum )
1326+
1327+ t .Log ("Updating supply commitment after ignoring asset outpoint" )
1328+ UpdateAndMineSupplyCommit (
1329+ t .t , ctxb , t .tapd , t .lndHarness .Miner ().Client ,
1330+ groupKeyBytes , 1 ,
1331+ )
1332+
1333+ t .Log ("Wait for the supply commitment to include the ignored outpoint." )
1334+ _ , _ = WaitForSupplyCommit (
1335+ t .t , ctxb , t .tapd , groupKeyBytes , fn .Some (supplyOutpoint ),
1336+ func (resp * unirpc.FetchSupplyCommitResponse ) bool {
1337+ if resp .IgnoreSubtreeRoot == nil {
1338+ return false
1339+ }
1340+
1341+ return resp .IgnoreSubtreeRoot .RootNode .RootSum ==
1342+ int64 (ignoreAmount )
1343+ },
1344+ )
1345+
1346+ t .Log ("Fetching supply leaves after ignoring asset outpoint" )
1347+ req = unirpc.FetchSupplyLeavesRequest {
1348+ GroupKey : & unirpc.FetchSupplyLeavesRequest_GroupKeyBytes {
1349+ GroupKeyBytes : groupKeyBytes ,
1350+ },
1351+ }
1352+ leavesResp4 , err := t .tapd .FetchSupplyLeaves (ctxb , & req )
1353+ require .NoError (t .t , err )
1354+ require .NotNil (t .t , leavesResp4 )
1355+
1356+ // Verify we have two issuance leaves, one burn leaf, and one ignore
1357+ // leaf.
1358+ require .Len (
1359+ t .t , leavesResp4 .IssuanceLeaves , 2 ,
1360+ "expected 2 issuance leaves after ignore" ,
1361+ )
1362+ require .Len (
1363+ t .t , leavesResp4 .BurnLeaves , 1 ,
1364+ "expected 1 burn leaf after ignore" ,
1365+ )
1366+ require .Len (
1367+ t .t , leavesResp4 .IgnoreLeaves , 1 ,
1368+ "expected 1 ignore leaf after ignore" ,
1369+ )
1370+
1371+ // Verify the ignore leaf amount.
1372+ ignoreLeaf := leavesResp4 .IgnoreLeaves [0 ]
1373+ require .EqualValues (
1374+ t .t , ignoreAmount , ignoreLeaf .LeafNode .RootSum ,
1375+ "ignore leaf amount mismatch" ,
1376+ )
1377+
1378+ // Compare the ignore leaf block data with that given in
1379+ // *unirpc.SupplyLeafBlockHeader message field.
1380+ //
1381+ // TODO(ffranr): Extend t.lndHarness.Miner() with
1382+ // GetBlockHeaderByHeight and use here.
1383+ //
1384+ // We can't retrieve the block header from the miner based on block
1385+ // height, so we fetch it given the block hash in the field we are
1386+ // testing. This is not ideal, but it covers timestamp and height
1387+ // verification.
1388+ expectedBlockHeight := ignoreLeaf .BlockHeight
1389+ ignoreLeafBlockHeader :=
1390+ leavesResp4 .BlockHeaders [expectedBlockHeight ]
1391+
1392+ ignoreBlockHash , err := chainhash .NewHash (ignoreLeafBlockHeader .Hash )
1393+ require .NoError (t .t , err )
1394+
1395+ ignoreLeafBlock := t .lndHarness .Miner ().GetBlock (ignoreBlockHash )
1396+ require .NotNil (t .t , ignoreLeafBlock )
1397+ expectedBlockTimestamp := ignoreLeafBlock .Header .Timestamp .Unix ()
1398+
1399+ AssertSupplyLeafBlockHeaders (
1400+ t .t , expectedBlockHeight , expectedBlockTimestamp ,
1401+ * ignoreBlockHash , leavesResp4 .BlockHeaders ,
1402+ )
1403+
13051404 t .Log ("Testing inclusion proof generation for supply leaves" )
13061405
13071406 // Collect leaf keys for inclusion proof request.
0 commit comments