Skip to content

Commit

Permalink
Adding additional test for proposals
Browse files Browse the repository at this point in the history
  • Loading branch information
jleni committed Feb 5, 2019
1 parent d88ee17 commit 84a7345
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions x/gov/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,38 @@ func TestEqualProposalID(t *testing.T) {
require.True(t, state1.Equal(state2))
}

func TestEqualProposals(t *testing.T) {
// Generate mock app and keepers
mapp, keeper, _, addrs, _, _ := getMockApp(t, 2, GenesisState{}, nil)
SortAddresses(addrs)
mapp.BeginBlock(abci.RequestBeginBlock{})
ctx := mapp.BaseApp.NewContext(false, abci.Header{})

// Create two proposals
proposal1 := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)
proposal2 := keeper.NewTextProposal(ctx, "Test", "description", ProposalTypeText)

// They are similar but their IDs should be different
require.NotEqual(t, proposal1, proposal2)
require.False(t, ProposalEqual(proposal1, proposal2))

// Now create two genesis blocks
state1 := GenesisState{Proposals: []Proposal{proposal1}}
state2 := GenesisState{Proposals: []Proposal{proposal2}}
require.NotEqual(t, state1, state2)
require.False(t, state1.Equal(state2))

// Now make proposals identical by setting both IDs to 55
proposal1.SetProposalID(55)
proposal2.SetProposalID(55)
require.Equal(t, proposal1, proposal1)
require.True(t, ProposalEqual(proposal1, proposal2))

// State should be identical now..
require.Equal(t, state1, state2)
require.True(t, state1.Equal(state2))
}

func TestImportExportQueues(t *testing.T) {

// Generate mock app and keepers
Expand Down

0 comments on commit 84a7345

Please sign in to comment.