@@ -21,6 +21,7 @@ import (
2121 "github.com/lightninglabs/taproot-assets/taprpc"
2222 "github.com/lightninglabs/taproot-assets/taprpc/mintrpc"
2323 unirpc "github.com/lightninglabs/taproot-assets/taprpc/universerpc"
24+ "github.com/lightninglabs/taproot-assets/universe"
2425 "github.com/lightningnetwork/lnd/lnrpc/chainrpc"
2526 "github.com/lightningnetwork/lnd/lntest/wait"
2627 "github.com/stretchr/testify/require"
@@ -1157,10 +1158,10 @@ func AssertUniverseRootsEqual(a, b *unirpc.AssetRootResponse) bool {
11571158func AssertUniverseStateEqual (t * testing.T , a , b unirpc.UniverseClient ) bool {
11581159 ctxb := context .Background ()
11591160
1160- rootsA , err := a . AssetRoots (ctxb , & unirpc. AssetRootRequest {} )
1161+ rootsA , err := assetRoots (ctxb , a , universe . MaxPageSize / 100 )
11611162 require .NoError (t , err )
11621163
1163- rootsB , err := b . AssetRoots (ctxb , & unirpc. AssetRootRequest {} )
1164+ rootsB , err := assetRoots (ctxb , b , universe . MaxPageSize / 100 )
11641165 require .NoError (t , err )
11651166
11661167 return AssertUniverseRootsEqual (rootsA , rootsB )
@@ -1196,10 +1197,20 @@ func AssertUniverseKeysEqual(t *testing.T, uniIDs []*unirpc.ID,
11961197 a , b unirpc.UniverseClient ) {
11971198
11981199 for _ , uniID := range uniIDs {
1199- aUniKeys , err := a .AssetLeafKeys (context .Background (), uniID )
1200+ aUniKeys , err := a .AssetLeafKeys (
1201+ context .Background (),
1202+ & unirpc.AssetLeafKeysRequest {
1203+ Id : uniID ,
1204+ },
1205+ )
12001206 require .NoError (t , err )
12011207
1202- bUniKeys , err := b .AssetLeafKeys (context .Background (), uniID )
1208+ bUniKeys , err := b .AssetLeafKeys (
1209+ context .Background (),
1210+ & unirpc.AssetLeafKeysRequest {
1211+ Id : uniID ,
1212+ },
1213+ )
12031214 require .NoError (t , err )
12041215
12051216 require .Equal (
@@ -1506,3 +1517,39 @@ func assertGroups(t *testing.T, client taprpc.TaprootAssetsClient,
15061517 equalityCheck (issuableAssets [0 ].Asset , groupedAssets [0 ])
15071518 equalityCheck (issuableAssets [1 ].Asset , groupedAssets [1 ])
15081519}
1520+
1521+ // assetRoots is a helper method that fetches all roots from a given universe
1522+ // rpc by scanning for all pages.
1523+ func assetRoots (ctx context.Context ,
1524+ uni unirpc.UniverseClient , pageSize int32 ) (* unirpc.AssetRootResponse , error ) {
1525+
1526+ offset := int32 (0 )
1527+ roots := make (map [string ]* unirpc.UniverseRoot )
1528+
1529+ for {
1530+ res , err := uni .AssetRoots (
1531+ ctx ,
1532+ & unirpc.AssetRootRequest {
1533+ Offset : offset ,
1534+ Limit : pageSize ,
1535+ },
1536+ )
1537+ if err != nil {
1538+ return nil , err
1539+ }
1540+
1541+ if len (res .UniverseRoots ) == 0 {
1542+ break
1543+ }
1544+
1545+ for k , v := range res .UniverseRoots {
1546+ roots [k ] = v
1547+ }
1548+
1549+ offset += pageSize
1550+ }
1551+
1552+ return & unirpc.AssetRootResponse {
1553+ UniverseRoots : roots ,
1554+ }, nil
1555+ }
0 commit comments