@@ -11,11 +11,13 @@ import (
1111 "github.com/btcsuite/btcd/btcec/v2"
1212 "github.com/btcsuite/btcd/btcec/v2/schnorr"
1313 tap "github.com/lightninglabs/taproot-assets"
14+ "github.com/lightninglabs/taproot-assets/asset"
1415 "github.com/lightninglabs/taproot-assets/fn"
1516 "github.com/lightninglabs/taproot-assets/mssmt"
1617 "github.com/lightninglabs/taproot-assets/taprpc"
1718 "github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
1819 unirpc "github.com/lightninglabs/taproot-assets/taprpc/universerpc"
20+ "github.com/lightninglabs/taproot-assets/universe"
1921 "github.com/lightningnetwork/lnd/lntest/wait"
2022 "github.com/stretchr/testify/require"
2123 "golang.org/x/exp/maps"
@@ -110,7 +112,12 @@ func testUniverseSync(t *harnessTest) {
110112 }
111113 }()
112114
113- srcRoot , ok := universeRoots .UniverseRoots [uniKey ]
115+ // Construct universe namespace.
116+ proofType , err := tap .UnmarshalUniProofType (newRoot .Id .ProofType )
117+ require .NoError (t .t , err )
118+ uniNamespace := fmt .Sprintf ("%s-%s" , proofType , uniKey )
119+
120+ srcRoot , ok := universeRoots .UniverseRoots [uniNamespace ]
114121 require .True (t .t , ok )
115122 require .True (t .t , AssertUniverseRootEqual (srcRoot , newRoot ))
116123 }
@@ -130,8 +137,7 @@ func testUniverseSync(t *harnessTest) {
130137 uniRoots := maps .Values (universeRoots .UniverseRoots )
131138 uniIDs := fn .Map (uniRoots , func (root * unirpc.UniverseRoot ) * unirpc.ID {
132139 return root .Id
133- },
134- )
140+ })
135141 AssertUniverseKeysEqual (t .t , uniIDs , t .tapd , bob )
136142 AssertUniverseLeavesEqual (t .t , uniIDs , t .tapd , bob )
137143
@@ -211,6 +217,7 @@ func testUniverseSync(t *harnessTest) {
211217 Id : & unirpc.ID_AssetId {
212218 AssetId : firstAssetID ,
213219 },
220+ ProofType : unirpc .ProofType_PROOF_TYPE_ISSUANCE ,
214221 },
215222 })
216223 require .NoError (t .t , err )
@@ -282,21 +289,29 @@ func testUniverseREST(t *harnessTest) {
282289
283290 // Simple assets are keyed by their asset ID.
284291 for _ , simpleAsset := range rpcSimpleAssets {
285- assetID := hex .EncodeToString (simpleAsset .AssetGenesis .AssetId )
286- require .Contains (t .t , roots .UniverseRoots , assetID )
292+ // Ensure that the universe root set contains issuance roots for
293+ // all of our assets.
294+ var assetID asset.ID
295+ copy (assetID [:], simpleAsset .AssetGenesis .AssetId )
296+ uniID := universe.Identifier {
297+ AssetID : assetID ,
298+ ProofType : universe .ProofTypeIssuance ,
299+ }
300+ uniIDStr := uniID .String ()
301+ require .Contains (t .t , roots .UniverseRoots , uniIDStr )
287302
288303 require .Equal (
289304 t .t , simpleAsset .AssetGenesis .Name ,
290- roots .UniverseRoots [assetID ].AssetName ,
305+ roots .UniverseRoots [uniIDStr ].AssetName ,
291306 )
292307
293308 // Query the specific root to make sure we get the same result.
294- assetRoot , err := getJSON [* unirpc.QueryRootResponse ](
309+ assetRoots , err := getJSON [* unirpc.QueryRootResponse ](
295310 fmt .Sprintf ("%s/roots/asset-id/%s" , urlPrefix , assetID ),
296311 )
297312 require .NoError (t .t , err )
298313 require .True (t .t , AssertUniverseRootEqual (
299- roots .UniverseRoots [assetID ], assetRoot . AssetRoot ,
314+ roots .UniverseRoots [uniIDStr ], assetRoots . IssuanceRoot ,
300315 ))
301316 }
302317
@@ -309,7 +324,12 @@ func testUniverseREST(t *harnessTest) {
309324 groupKey := issuableAsset .AssetGroup .TweakedGroupKey
310325 groupKeyHash := sha256 .Sum256 (groupKey [1 :])
311326 groupKeyID := hex .EncodeToString (groupKeyHash [:])
312- require .Contains (t .t , roots .UniverseRoots , groupKeyID )
327+
328+ // Construct universe namespace using the group key ID.
329+ namespace := fmt .Sprintf (
330+ "%s-%s" , universe .ProofTypeIssuance , groupKeyID ,
331+ )
332+ require .Contains (t .t , roots .UniverseRoots , namespace )
313333
314334 // Query the specific root to make sure we get the same result.
315335 // Rather than use the hash above, the API exposes the
@@ -321,9 +341,10 @@ func testUniverseREST(t *harnessTest) {
321341 assetRoot , err := getJSON [* unirpc.QueryRootResponse ](queryURI )
322342 require .NoError (t .t , err )
323343
344+ uniRoot , foundRoot := roots .UniverseRoots [namespace ]
345+ require .True (t .t , foundRoot )
324346 require .True (t .t , AssertUniverseRootEqual (
325- roots .UniverseRoots [groupKeyID ],
326- assetRoot .AssetRoot ,
347+ uniRoot , assetRoot .IssuanceRoot ,
327348 ))
328349 }
329350}
0 commit comments