Skip to content

Commit

Permalink
test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronc committed Mar 19, 2024
1 parent 1657932 commit 8d6299f
Showing 1 changed file with 38 additions and 22 deletions.
60 changes: 38 additions & 22 deletions x/ecocredit/genesis/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -884,34 +884,39 @@ 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",
Unit: "acres",
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: &timestamppb.Timestamp{Seconds: 100},
EndDate: &timestamppb.Timestamp{Seconds: 101},
Expand All @@ -920,6 +925,7 @@ func TestValidateGenesisWithBasketBalance(t *testing.T) {
{
Issuer: sdk.AccAddress("addr3"),
ProjectKey: 1,
ClassKey: bioClsKey,
Denom: "BIO02-001-20200101-20210101-001",
StartDate: &timestamppb.Timestamp{Seconds: 100},
EndDate: &timestamppb.Timestamp{Seconds: 101},
Expand All @@ -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,
Expand All @@ -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"),
Expand Down

0 comments on commit 8d6299f

Please sign in to comment.