diff --git a/CHANGELOG.md b/CHANGELOG.md index a489689e7b..cea7765056 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - [#1274](https://github.com/regen-network/regen-ledger/pull/1274) Add `cancel-sell-order` command +#### Fixed +- [#1278](https://github.com/regen-network/regen-ledger/pull/1278) Fix `open` not set in `Msg/CreateBatch` + ## [v4.0.0-rc1](https://github.com/regen-network/regen-ledger/releases/tag/v4.0.0-rc1) - 2022-07-15 ### General diff --git a/x/ecocredit/server/core/features/msg_create_batch.feature b/x/ecocredit/server/core/features/msg_create_batch.feature index 56a7ff0296..1262a8ae16 100644 --- a/x/ecocredit/server/core/features/msg_create_batch.feature +++ b/x/ecocredit/server/core/features/msg_create_batch.feature @@ -347,7 +347,8 @@ Feature: Msg/CreateBatch "project_id": "C01-001", "metadata": "regen:13toVfvC2YxrrfSXWB5h2BGHiXZURsKxWUz72uDRDSPMCrYPguGUXSC.rdf", "start_date": "2020-01-01T00:00:00Z", - "end_date": "2021-01-01T00:00:00Z" + "end_date": "2021-01-01T00:00:00Z", + "open": true } """ Then expect batch properties @@ -356,7 +357,8 @@ Feature: Msg/CreateBatch "denom": "C01-001-20200101-20210101-001", "metadata": "regen:13toVfvC2YxrrfSXWB5h2BGHiXZURsKxWUz72uDRDSPMCrYPguGUXSC.rdf", "start_date": "2020-01-01T00:00:00Z", - "end_date": "2021-01-01T00:00:00Z" + "end_date": "2021-01-01T00:00:00Z", + "open": true } """ diff --git a/x/ecocredit/server/core/msg_create_batch.go b/x/ecocredit/server/core/msg_create_batch.go index c5ef96edb3..793a2f85a1 100644 --- a/x/ecocredit/server/core/msg_create_batch.go +++ b/x/ecocredit/server/core/msg_create_batch.go @@ -54,13 +54,14 @@ func (k Keeper) CreateBatch(ctx context.Context, req *core.MsgCreateBatch) (*cor startDate, endDate := timestamppb.New(*req.StartDate), timestamppb.New(*req.EndDate) issuanceDate := timestamppb.New(sdkCtx.BlockTime()) batchKey, err := k.stateStore.BatchTable().InsertReturningID(ctx, &api.Batch{ - ProjectKey: project.Key, Issuer: issuer, + ProjectKey: project.Key, Denom: batchDenom, Metadata: req.Metadata, StartDate: startDate, EndDate: endDate, IssuanceDate: issuanceDate, + Open: req.Open, }) if err != nil { return nil, err diff --git a/x/ecocredit/server/core/msg_create_batch_test.go b/x/ecocredit/server/core/msg_create_batch_test.go index 76a818e403..62f03073b9 100644 --- a/x/ecocredit/server/core/msg_create_batch_test.go +++ b/x/ecocredit/server/core/msg_create_batch_test.go @@ -15,6 +15,7 @@ import ( api "github.com/regen-network/regen-ledger/api/regen/ecocredit/v1" "github.com/regen-network/regen-ledger/types" + "github.com/regen-network/regen-ledger/types/ormutil" "github.com/regen-network/regen-ledger/x/ecocredit/core" ) @@ -293,14 +294,8 @@ func (s *createBatchSuite) AliceAttemptsToCreateABatchWithProperties(a gocuke.Do err := jsonpb.UnmarshalString(a.Content, &msg) require.NoError(s.t, err) - s.res, s.err = s.k.CreateBatch(s.ctx, &core.MsgCreateBatch{ - Issuer: s.alice.String(), - ProjectId: msg.ProjectId, - Issuance: msg.Issuance, - Metadata: msg.Metadata, - StartDate: msg.StartDate, - EndDate: msg.EndDate, - }) + msg.Issuer = s.alice.String() + s.res, s.err = s.k.CreateBatch(s.ctx, &msg) } func (s *createBatchSuite) ExpectNoError() { @@ -371,9 +366,16 @@ func (s *createBatchSuite) ExpectBatchProperties(a gocuke.DocString) { batch, err := s.stateStore.BatchTable().GetByDenom(s.ctx, expected.Denom) require.NoError(s.t, err) - require.Equal(s.t, expected.Metadata, batch.Metadata) - require.Equal(s.t, expected.StartDate.Seconds, batch.StartDate.Seconds) - require.Equal(s.t, expected.EndDate.Seconds, batch.EndDate.Seconds) + coreBatch := new(core.Batch) + require.NoError(s.t, ormutil.PulsarToGogoSlow(batch, coreBatch)) + + // set the properties that get set during state machine execution. + expected.Key = coreBatch.Key + expected.ProjectKey = coreBatch.ProjectKey + expected.Issuer = coreBatch.Issuer + expected.IssuanceDate = coreBatch.IssuanceDate + + require.Equal(s.t, expected, *coreBatch) } func (s *createBatchSuite) ExpectBatchContract(a gocuke.DocString) {