diff --git a/itest/addrs_test.go b/itest/addrs_test.go index 6f5651cfd..e5b1058ef 100644 --- a/itest/addrs_test.go +++ b/itest/addrs_test.go @@ -48,8 +48,9 @@ func testAddresses(t *harnessTest) { // In order to force a split, we don't try to send the full // asset. addr, err := secondTapd.NewAddr(ctxt, &taprpc.NewAddrRequest{ - AssetId: a.AssetGenesis.AssetId, - Amt: a.Amount - 1, + AssetId: a.AssetGenesis.AssetId, + Amt: a.Amount - 1, + AssetVersion: a.Version, }) require.NoError(t.t, err) addresses = append(addresses, addr) @@ -99,10 +100,16 @@ func testAddresses(t *harnessTest) { ctxt, &taprpc.ListTransfersRequest{}, ) require.NoError(t.t, err) + require.Len(t.t, resp.Transfers, len(rpcAssets)) require.Len(t.t, resp.Transfers[0].Outputs, 2) + firstOut := resp.Transfers[0].Outputs[0] require.EqualValues(t.t, 1, firstOut.Amount) + require.Equal( + t.t, addresses[0].AssetVersion, firstOut.AssetVersion, + ) + firstIn := resp.Transfers[0].Inputs[0] require.Equal( t.t, rpcAssets[0].AssetGenesis.AssetId, firstIn.AssetId, @@ -268,8 +275,10 @@ func runMultiSendTest(ctxt context.Context, t *harnessTest, alice, transfer := resp.Transfers[runIdx] require.Len(t.t, transfer.Outputs, numOutputs) + firstOut := transfer.Outputs[0] require.EqualValues(t.t, changeAmt, firstOut.Amount) + firstIn := transfer.Inputs[0] require.Equal(t.t, genInfo.AssetId, firstIn.AssetId) diff --git a/itest/assertions.go b/itest/assertions.go index 6aa197620..b8381c890 100644 --- a/itest/assertions.go +++ b/itest/assertions.go @@ -112,6 +112,18 @@ func AssetScriptKeyIsBurnCheck(isBurn bool) AssetCheck { } } +// AssetVersionCheck returns a check function that tests an asset's version. +func AssetVersionCheck(version taprpc.AssetVersion) AssetCheck { + return func(a *taprpc.Asset) error { + if a.Version != a.Version { + return fmt.Errorf("unexpected asset version, got %v "+ + "wanted %v", a.Version, version) + } + + return nil + } +} + // GroupAssetsByName converts an unordered list of assets to a map of lists of // assets, where all assets in a list have the same name. func GroupAssetsByName(assets []*taprpc.Asset) map[string][]*taprpc.Asset { @@ -681,6 +693,7 @@ func AssertNonInteractiveRecvComplete(t *testing.T, func AssertAddr(t *testing.T, expected *taprpc.Asset, actual *taprpc.Addr) { require.Equal(t, expected.AssetGenesis.AssetId, actual.AssetId) require.Equal(t, expected.AssetType, actual.AssetType) + require.Equal(t, expected.Version, actual.AssetVersion) if expected.AssetGroup == nil { require.Nil(t, actual.GroupKey) diff --git a/itest/assets_test.go b/itest/assets_test.go index 2bd110300..e79b22ed0 100644 --- a/itest/assets_test.go +++ b/itest/assets_test.go @@ -24,7 +24,8 @@ var ( AssetMeta: &taprpc.AssetMeta{ Data: []byte("some metadata"), }, - Amount: 5000, + Amount: 5000, + AssetVersion: taprpc.AssetVersion_ASSET_VERSION_V0, }, }, { @@ -34,7 +35,8 @@ var ( AssetMeta: &taprpc.AssetMeta{ Data: []byte("some metadata"), }, - Amount: 1, + Amount: 1, + AssetVersion: taprpc.AssetVersion_ASSET_VERSION_V1, }, }, } @@ -46,7 +48,8 @@ var ( AssetMeta: &taprpc.AssetMeta{ Data: []byte("some metadata"), }, - Amount: 5000, + Amount: 5000, + AssetVersion: taprpc.AssetVersion_ASSET_VERSION_V1, }, EnableEmission: true, }, @@ -57,7 +60,8 @@ var ( AssetMeta: &taprpc.AssetMeta{ Data: []byte("some metadata"), }, - Amount: 1, + Amount: 1, + AssetVersion: taprpc.AssetVersion_ASSET_VERSION_V0, }, EnableEmission: true, }, diff --git a/itest/utils.go b/itest/utils.go index 16a13a856..3586be073 100644 --- a/itest/utils.go +++ b/itest/utils.go @@ -207,6 +207,7 @@ func MintAssetUnconfirmed(t *testing.T, minerClient *rpcclient.Client, AssetTypeCheck(assetRequest.Asset.AssetType), AssetAnchorCheck(*hashes[0], zeroHash), AssetScriptKeyIsLocalCheck(true), + AssetVersionCheck(assetRequest.Asset.AssetVersion), ) }