diff --git a/x/ecocredit/genesis/genesis_test.go b/x/ecocredit/genesis/genesis_test.go index 4357c18ae0..1b5529d60d 100644 --- a/x/ecocredit/genesis/genesis_test.go +++ b/x/ecocredit/genesis/genesis_test.go @@ -884,6 +884,13 @@ func TestValidateGenesisWithBasketBalance(t *testing.T) { bsktStore, err := basketapi.NewStateStore(modDB) require.NoError(t, err) + require.NoError(t, ss.CreditTypeTable().Insert(ormCtx, &baseapi.CreditType{ + Abbreviation: "C", + Name: "carbon", + Unit: "tons", + Precision: 6, + })) + require.NoError(t, ss.CreditTypeTable().Insert(ormCtx, &baseapi.CreditType{ Abbreviation: "BIO", Name: "biodiversity", @@ -891,27 +898,25 @@ func TestValidateGenesisWithBasketBalance(t *testing.T) { Precision: 6, })) - require.NoError(t, ss.BatchBalanceTable().Insert(ormCtx, - &baseapi.BatchBalance{ - BatchKey: 1, - Address: sdk.AccAddress("addr1"), - TradableAmount: "90.003", - RetiredAmount: "9.997", - })) + carbonClsKey, err := ss.ClassTable().InsertReturningID(ormCtx, &baseapi.Class{ + Id: "C001", + Admin: sdk.AccAddress("addr4"), + CreditTypeAbbrev: "C", + }) + require.NoError(t, err) - require.NoError(t, ss.BatchBalanceTable().Insert(ormCtx, - &baseapi.BatchBalance{ - BatchKey: 2, - Address: sdk.AccAddress("addr1"), - TradableAmount: "1.234", - EscrowedAmount: "1.234", - RetiredAmount: "0", - })) + bioClsKey, err := ss.ClassTable().InsertReturningID(ormCtx, &baseapi.Class{ + Id: "BIO001", + Admin: sdk.AccAddress("addr4"), + CreditTypeAbbrev: "BIO", + }) + require.NoError(t, err) batches := []*baseapi.Batch{ { Issuer: sdk.AccAddress("addr2"), ProjectKey: 1, + ClassKey: carbonClsKey, Denom: "C01-001-20200101-20210101-001", StartDate: ×tamppb.Timestamp{Seconds: 100}, EndDate: ×tamppb.Timestamp{Seconds: 101}, @@ -920,6 +925,7 @@ func TestValidateGenesisWithBasketBalance(t *testing.T) { { Issuer: sdk.AccAddress("addr3"), ProjectKey: 1, + ClassKey: bioClsKey, Denom: "BIO02-001-20200101-20210101-001", StartDate: ×tamppb.Timestamp{Seconds: 100}, EndDate: ×tamppb.Timestamp{Seconds: 101}, @@ -930,6 +936,23 @@ func TestValidateGenesisWithBasketBalance(t *testing.T) { require.NoError(t, ss.BatchTable().Insert(ormCtx, b)) } + require.NoError(t, ss.BatchBalanceTable().Insert(ormCtx, + &baseapi.BatchBalance{ + BatchKey: 1, + Address: sdk.AccAddress("addr1"), + TradableAmount: "90.003", + RetiredAmount: "9.997", + })) + + require.NoError(t, ss.BatchBalanceTable().Insert(ormCtx, + &baseapi.BatchBalance{ + BatchKey: 2, + Address: sdk.AccAddress("addr1"), + TradableAmount: "1.234", + EscrowedAmount: "1.234", + RetiredAmount: "0", + })) + require.NoError(t, ss.BatchSupplyTable().Insert(ormCtx, &baseapi.BatchSupply{ BatchKey: 1, @@ -946,13 +969,6 @@ func TestValidateGenesisWithBasketBalance(t *testing.T) { }), ) - class := baseapi.Class{ - Id: "BIO001", - Admin: sdk.AccAddress("addr4"), - CreditTypeAbbrev: "BIO", - } - require.NoError(t, ss.ClassTable().Insert(ormCtx, &class)) - project := baseapi.Project{ Id: "P01-001", Admin: sdk.AccAddress("addr6"),