Skip to content

Commit

Permalink
test: fixgenesis test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaru Wang committed Jun 23, 2023
1 parent 7099903 commit 6d94704
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
23 changes: 23 additions & 0 deletions x/ccv/provider/keeper/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func TestInitAndExportGenesis(t *testing.T) {
consumerTmPubKey := consumerCryptoId.TMProtoCryptoPublicKey()
consumerConsAddr := consumerCryptoId.ConsumerConsAddress()

initTimeoutTime := uint64(time.Now().UTC().UnixNano()) + 10
vscSendTime := time.Now().Add(-30 * time.Minute)
// create genesis struct
provGenesis := providertypes.NewGenesisState(vscID,
[]providertypes.ValsetUpdateIdToHeight{{ValsetUpdateId: vscID, Height: initHeight}},
Expand Down Expand Up @@ -97,6 +99,19 @@ func TestInitAndExportGenesis(t *testing.T) {
ConsumerAddrs: &providertypes.AddressList{Addresses: [][]byte{consumerConsAddr.ToSdkConsAddr()}},
},
},
[]providertypes.InitTimeoutTimestamp{
{
ChainId: cChainIDs[0],
Timestamp: initTimeoutTime,
},
},
[]providertypes.VscSendTimestamp{
{
ChainId: cChainIDs[0],
VscId: vscID,
Timestamp: vscSendTime,
},
},
)

// Instantiate in-mem provider keeper with mocks
Expand Down Expand Up @@ -163,6 +178,14 @@ func TestInitAndExportGenesis(t *testing.T) {

// check the exported genesis
require.Equal(t, provGenesis, pk.ExportGenesis(ctx))

initTimeoutTimestamp, found := pk.GetInitTimeoutTimestamp(ctx, cChainIDs[0])
require.Equal(t, initTimeoutTimestamp, initTimeoutTime)
require.True(t, found)

vscSendTimestamp, found := pk.GetVscSendTimestamp(ctx, cChainIDs[0], vscID)
require.Equal(t, vscSendTimestamp, vscSendTime)
require.True(t, found)
}

func assertConsumerChainStates(t *testing.T, ctx sdk.Context, pk keeper.Keeper, consumerStates ...providertypes.ConsumerState) {
Expand Down
2 changes: 2 additions & 0 deletions x/ccv/provider/module_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ func TestInitGenesis(t *testing.T) {
nil,
nil,
nil,
nil,
nil,
)

cdc := keeperParams.Cdc
Expand Down

0 comments on commit 6d94704

Please sign in to comment.