Skip to content

Commit

Permalink
multi: make use of require.Len where possible
Browse files Browse the repository at this point in the history
This commit changes instances of `require.Equal(t, <int>, len(<var>))`
to `require.Len(t, <var>, <int>)` where possible.
  • Loading branch information
ffranr committed Jan 11, 2024
1 parent f124681 commit b2a98a9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions itest/assertions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1567,10 +1567,10 @@ func assertGroups(t *testing.T, client taprpc.TaprootAssetsClient,
require.NoError(t, err)

groupKeys := maps.Keys(assetGroups.Groups)
require.Equal(t, 2, len(groupKeys))
require.Len(t, groupKeys, 2)

groupedAssets := assetGroups.Groups[groupKeys[0]].Assets
require.Equal(t, 1, len(groupedAssets))
require.Len(t, groupedAssets, 1)
require.Equal(t, 1, len(assetGroups.Groups[groupKeys[1]].Assets))

groupedAssets = append(
Expand Down
10 changes: 5 additions & 5 deletions tapdb/assets_store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1261,7 +1261,7 @@ func TestAssetExportLog(t *testing.T) {
// looking for all unconfirmed transfers.
assetTransfers, err := db.QueryAssetTransfers(ctx, TransferQuery{})
require.NoError(t, err)
require.Equal(t, 1, len(assetTransfers))
require.Len(t, assetTransfers, 1)

// We should also be able to find it based on its outpoint.
firstOutput := spendDelta.Outputs[0]
Expand All @@ -1270,7 +1270,7 @@ func TestAssetExportLog(t *testing.T) {
AnchorTxHash: firstOutputAnchor.OutPoint.Hash[:],
})
require.NoError(t, err)
require.Equal(t, 1, len(assetTransfers))
require.Len(t, assetTransfers, 1)

// Check that the new UTXO is found among our managed UTXOs.
utxos, err = assetsStore.FetchManagedUTXOs(ctx)
Expand Down Expand Up @@ -1302,13 +1302,13 @@ func TestAssetExportLog(t *testing.T) {
UnconfOnly: true,
})
require.NoError(t, err)
require.Equal(t, 1, len(assetTransfers))
require.Len(t, assetTransfers, 1)

// This should also show up in the set of pending parcels. It should
// also match exactly the inbound parcel we used to make the delta.
parcels, err := assetsStore.PendingParcels(ctx)
require.NoError(t, err)
require.Equal(t, 1, len(parcels))
require.Len(t, parcels, 1)
require.Equal(t, spendDelta, parcels[0])

// We should also be able to query for the parcel when filtering on its
Expand Down Expand Up @@ -1428,7 +1428,7 @@ func TestAssetExportLog(t *testing.T) {
// At this point, there should be no more pending parcels.
parcels, err = assetsStore.PendingParcels(ctx)
require.NoError(t, err)
require.Equal(t, 0, len(parcels))
require.Len(t, parcels, 0)
}

// TestAssetGroupWitnessUpsert tests that if you try to insert another asset
Expand Down

0 comments on commit b2a98a9

Please sign in to comment.