From 6d94704b2fbb62fbf4814cf6d192171f4fc7289b Mon Sep 17 00:00:00 2001 From: Yaru Wang Date: Fri, 23 Jun 2023 15:21:10 +0200 Subject: [PATCH] test: fixgenesis test --- x/ccv/provider/keeper/genesis_test.go | 23 +++++++++++++++++++++++ x/ccv/provider/module_test.go | 2 ++ 2 files changed, 25 insertions(+) diff --git a/x/ccv/provider/keeper/genesis_test.go b/x/ccv/provider/keeper/genesis_test.go index fe666dcc2c..1b56c4a79f 100644 --- a/x/ccv/provider/keeper/genesis_test.go +++ b/x/ccv/provider/keeper/genesis_test.go @@ -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}}, @@ -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 @@ -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) { diff --git a/x/ccv/provider/module_test.go b/x/ccv/provider/module_test.go index 0eee81cc1f..b0c312e56f 100644 --- a/x/ccv/provider/module_test.go +++ b/x/ccv/provider/module_test.go @@ -109,6 +109,8 @@ func TestInitGenesis(t *testing.T) { nil, nil, nil, + nil, + nil, ) cdc := keeperParams.Cdc