From f121f40179707204fc7321022d86f23236052577 Mon Sep 17 00:00:00 2001 From: Paul Chen Date: Tue, 25 Jun 2024 18:43:05 +0800 Subject: [PATCH] fix: fix gov db cdc and test cases --- database/gov.go | 4 +--- database/gov_test.go | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/database/gov.go b/database/gov.go index 5ff5ec07b..1d560329f 100644 --- a/database/gov.go +++ b/database/gov.go @@ -7,7 +7,6 @@ import ( "time" upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" govtypesv1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1" "github.com/lib/pq" @@ -88,9 +87,8 @@ INSERT INTO proposal( vi+1, vi+2, vi+3, vi+4, vi+5, vi+6, vi+7, vi+8, vi+9, vi+10, vi+11) var jsonMessages []string - var protoCodec codec.ProtoCodec for _, msg := range proposal.Messages { - contentBz, err := protoCodec.MarshalJSON(msg) + contentBz, err := db.cdc.MarshalJSON(msg) if err != nil { return fmt.Errorf("error while marshalling proposal msg: %s", err) } diff --git a/database/gov_test.go b/database/gov_test.go index 6eca0af4f..56f4f9da8 100644 --- a/database/gov_test.go +++ b/database/gov_test.go @@ -186,7 +186,7 @@ func (suite *DbTestSuite) TestBigDipperDb_SaveProposals() { "Proposal Title 1", "Proposal Description 1", "Proposal Metadata 1", - "[{\"@type\": \"/cosmos.gov.v1.MsgUpdateParams\", \"params\": {\"quorum\": \"0.5\", \"threshold\": \"0.3\", \"min_deposit\": [{\"denom\": \"uatom\", \"amount\": \"1000\"}], \"voting_period\": \"0.000300s\", \"burn_vote_veto\": false, \"veto_threshold\": \"0.15\", \"burn_vote_quorum\": false, \"max_deposit_period\": \"300s\", \"min_initial_deposit_ratio\": \"0\", \"burn_proposal_deposit_prevote\": false}, \"authority\": \"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn\"}]", + "[{\"@type\": \"/cosmos.gov.v1.MsgUpdateParams\", \"params\": {\"quorum\": \"0.5\", \"threshold\": \"0.3\", \"min_deposit\": [{\"denom\": \"uatom\", \"amount\": \"1000\"}], \"voting_period\": \"0.000300s\", \"burn_vote_veto\": false, \"veto_threshold\": \"0.15\", \"burn_vote_quorum\": false, \"min_deposit_ratio\": \"\", \"max_deposit_period\": \"300s\", \"expedited_threshold\": \"\", \"proposal_cancel_dest\": \"\", \"expedited_min_deposit\": [], \"proposal_cancel_ratio\": \"\", \"expedited_voting_period\": null, \"min_initial_deposit_ratio\": \"0\", \"burn_proposal_deposit_prevote\": false}, \"authority\": \"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn\"}]", time.Date(2020, 1, 1, 00, 00, 00, 000, time.UTC), time.Date(2020, 1, 1, 01, 00, 00, 000, time.UTC), testutils.NewTimePointer(time.Date(2020, 1, 1, 02, 00, 00, 000, time.UTC)), @@ -361,7 +361,7 @@ func (suite *DbTestSuite) TestBigDipperDb_UpdateProposal() { "Proposal 1", "Description of proposal 1", "Metadata of proposal 1", - "[{\"@type\": \"/cosmos.gov.v1.MsgUpdateParams\", \"params\": {\"quorum\": \"0.5\", \"threshold\": \"0.3\", \"min_deposit\": [{\"denom\": \"uatom\", \"amount\": \"1000\"}], \"voting_period\": \"0.000300s\", \"burn_vote_veto\": false, \"veto_threshold\": \"0.15\", \"burn_vote_quorum\": false, \"max_deposit_period\": \"300s\", \"min_initial_deposit_ratio\": \"0\", \"burn_proposal_deposit_prevote\": false}, \"authority\": \"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn\"}]", + "[{\"@type\": \"/cosmos.gov.v1.MsgUpdateParams\", \"params\": {\"quorum\": \"0.5\", \"threshold\": \"0.3\", \"min_deposit\": [{\"denom\": \"uatom\", \"amount\": \"1000\"}], \"voting_period\": \"0.000300s\", \"burn_vote_veto\": false, \"veto_threshold\": \"0.15\", \"burn_vote_quorum\": false, \"min_deposit_ratio\": \"\", \"max_deposit_period\": \"300s\", \"expedited_threshold\": \"\", \"proposal_cancel_dest\": \"\", \"expedited_min_deposit\": [], \"proposal_cancel_ratio\": \"\", \"expedited_voting_period\": null, \"min_initial_deposit_ratio\": \"0\", \"burn_proposal_deposit_prevote\": false}, \"authority\": \"cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn\"}]", proposal.SubmitTime, proposal.DepositEndTime, timestamp1, @@ -373,6 +373,7 @@ func (suite *DbTestSuite) TestBigDipperDb_UpdateProposal() { var stored dbtypes.ProposalRow err = suite.database.SQL.Get(&stored, `SELECT * FROM proposal LIMIT 1`) suite.Require().NoError(err) + suite.T().Logf("actual: %v\nexpected: %v", stored, expected) suite.Require().True(expected.Equals(stored)) }