Skip to content

Commit

Permalink
fix: fix gov db cdc and test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
dadamu committed Jun 25, 2024
1 parent 54bb111 commit f121f40
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 1 addition & 3 deletions database/gov.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand Down
5 changes: 3 additions & 2 deletions database/gov_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)),
Expand Down Expand Up @@ -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,
Expand All @@ -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))
}

Expand Down

0 comments on commit f121f40

Please sign in to comment.