@@ -2550,74 +2550,86 @@ func AssertBalances(t *testing.T, client taprpc.TaprootAssetsClient,
25502550 },
25512551 )
25522552
2553- utxoList , err := client .ListUtxos (ctxt , & taprpc.ListUtxosRequest {
2554- IncludeLeased : config .includeLeased ,
2555- ScriptKeyType : rpcTypeQuery ,
2556- })
2557- require .NoError (t , err )
2558-
25592553 // Make sure the ListUtxos call returns the same number of (asset) UTXOs
25602554 // as the ListAssets call.
2561- var (
2562- numAnchorUtxos uint32
2563- totalBalance uint64
2564- numUtxos uint32
2565- )
2555+ assertPredUtxos := func (resp * taprpc.ListUtxosResponse ) error {
2556+ var (
2557+ numAnchorUtxos uint32
2558+ totalBalance uint64
2559+ numUtxos uint32
2560+ )
25662561
2567- for _ , btcUtxo := range utxoList .ManagedUtxos {
2568- numAnchorUtxos ++
2569- for _ , assetUtxo := range btcUtxo .Assets {
2570- if len (config .assetID ) > 0 {
2571- if ! bytes .Equal (
2572- assetUtxo .AssetGenesis .AssetId ,
2573- config .assetID ,
2574- ) {
2562+ for _ , btcUtxo := range resp .ManagedUtxos {
2563+ numAnchorUtxos ++
2564+ for _ , assetUtxo := range btcUtxo .Assets {
2565+ if len (config .assetID ) > 0 {
2566+ if ! bytes .Equal (
2567+ assetUtxo .AssetGenesis .AssetId ,
2568+ config .assetID ,
2569+ ) {
25752570
2576- continue
2571+ continue
2572+ }
25772573 }
2578- }
25792574
2580- if len (config .groupKey ) > 0 {
2581- if assetUtxo .AssetGroup == nil {
2582- continue
2583- }
2575+ if len (config .groupKey ) > 0 {
2576+ if assetUtxo .AssetGroup == nil {
2577+ continue
2578+ }
25842579
2585- if ! bytes .Equal (
2586- assetUtxo .AssetGroup .TweakedGroupKey ,
2587- config .groupKey ,
2588- ) {
2580+ // nolint: lll
2581+ actualGK := assetUtxo .AssetGroup .TweakedGroupKey
25892582
2590- continue
2583+ if ! bytes .Equal (
2584+ actualGK , config .groupKey ,
2585+ ) {
2586+
2587+ continue
2588+ }
25912589 }
2592- }
25932590
2594- if len (config .scriptKey ) > 0 {
2595- if ! bytes .Equal (
2596- assetUtxo .ScriptKey , config .scriptKey ,
2597- ) {
2591+ if len (config .scriptKey ) > 0 {
2592+ if ! bytes .Equal (
2593+ assetUtxo .ScriptKey ,
2594+ config .scriptKey ,
2595+ ) {
25982596
2599- continue
2597+ continue
2598+ }
26002599 }
2600+
2601+ totalBalance += assetUtxo .Amount
2602+ numUtxos ++
26012603 }
2604+ }
26022605
2603- totalBalance += assetUtxo .Amount
2604- numUtxos ++
2606+ if balance != totalBalance {
2607+ return fmt .Errorf ("ListUtxos balance, wanted %d, " +
2608+ "got: %v" , balance , toJSON (t , resp ))
26052609 }
2606- }
2607- require .Equal (t , balance , totalBalance , "ListUtxos balance" )
26082610
2609- if config .numAnchorUtxos > 0 {
2610- require .Equal (
2611- t , config .numAnchorUtxos , numAnchorUtxos , "num anchor " +
2612- "utxos" ,
2613- )
2614- }
2615- if config .numAssetUtxos > 0 {
2616- require .Equal (
2617- t , config .numAssetUtxos , numUtxos , "ListUtxos num " +
2618- "asset utxos" ,
2619- )
2611+ if config .numAnchorUtxos > 0 {
2612+ if config .numAnchorUtxos != numAnchorUtxos {
2613+ return fmt .Errorf ("unexpected number of " +
2614+ "anchor UTXOs" )
2615+ }
2616+ }
2617+ if config .numAssetUtxos > 0 {
2618+ if config .numAssetUtxos != numUtxos {
2619+ return fmt .Errorf ("unexpected number of " +
2620+ "asset UTXOs" )
2621+ }
2622+ }
2623+
2624+ return nil
26202625 }
2626+
2627+ rpcassert .ListUtxosRPC (t , ctxt , client , assertPredUtxos ,
2628+ & taprpc.ListUtxosRequest {
2629+ IncludeLeased : config .includeLeased ,
2630+ ScriptKeyType : rpcTypeQuery ,
2631+ },
2632+ )
26212633}
26222634
26232635func assertGroups (t * testing.T , client taprpc.TaprootAssetsClient ,
0 commit comments