From 6f8cc05ce494e1003cdf8bd6e03614b5bf9b29db Mon Sep 17 00:00:00 2001 From: anhductn2001 Date: Mon, 2 Sep 2024 07:49:30 +0700 Subject: [PATCH] add invariant check --- tests/admc_test.go | 14 ++++++++++ tests/automated_denommetadata_test.go | 13 +++++++++ tests/bridging_fee_test.go | 4 +++ tests/eibc_ack_error_test.go | 12 ++++++++ tests/eibc_corrupted_memo_test.go | 3 ++ tests/eibc_fee_market_test.go | 8 ++++++ tests/eibc_fee_test.go | 2 ++ tests/eibc_feemarket_test.go | 18 ++++++++++++ tests/eibc_fulfillment_test.go | 24 ++++++++++++++++ tests/eibc_nobalance_test.go | 3 ++ tests/eibc_not_fulfillment_test.go | 5 ++++ tests/eibc_pfm_test.go | 4 +++ tests/eibc_timeout_test.go | 9 ++++++ tests/erc20_ibc_transfer_test.go | 6 ++++ tests/frozen_test.go | 39 ++++++++++++++++++++++++++ tests/genesis_transfer_test.go | 12 ++++++++ tests/hardfork_test.go | 6 ++++ tests/ibc_finalize_block_test.go | 18 ++++++++++++ tests/ibc_grace_period_test.go | 17 ++++++++++++ tests/ibc_timeout_test.go | 6 ++++ tests/ibc_transfer_test.go | 11 ++++++++ tests/rollapp_upgrade_test.go | 9 ++++++ tests/setup.go | 40 +++++++++++++++++++++++---- tests/tx_batch_finalization_test.go | 3 ++ tests/upgrade_hub_test.go | 3 ++ 25 files changed, 283 insertions(+), 6 deletions(-) diff --git a/tests/admc_test.go b/tests/admc_test.go index 574d838f..6e3b2bf2 100644 --- a/tests/admc_test.go +++ b/tests/admc_test.go @@ -183,6 +183,8 @@ func TestADMC_Originates_HubtoRA_EVM(t *testing.T) { require.Equal(t, "urax", resp.Metadatas[0].Base) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { @@ -405,6 +407,8 @@ func TestADMC_Migrate_Empty_User_Memo_EVM(t *testing.T) { // Minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount).Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_Migrate_With_User_Memo_EVM(t *testing.T) { @@ -801,6 +805,8 @@ func TestADMC_Originates_HubtoRA_Wasm(t *testing.T) { require.Equal(t, "urax", resp.Metadatas[0].Base) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { @@ -1020,6 +1026,8 @@ func TestADMC_Migrate_Empty_User_Memo_Wasm(t *testing.T) { // Minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount).Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { @@ -1246,6 +1254,8 @@ func TestADMC_Migrate_With_User_Memo_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount).Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_MetaData_NotFound_EVM(t *testing.T) { @@ -1442,6 +1452,8 @@ func TestADMC_MetaData_NotFound_EVM(t *testing.T) { err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestADMC_MetaData_NotFound_Wasm(t *testing.T) { @@ -1638,4 +1650,6 @@ func TestADMC_MetaData_NotFound_Wasm(t *testing.T) { err = testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) require.NoError(t, err) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/automated_denommetadata_test.go b/tests/automated_denommetadata_test.go index 53fcbf75..62f62d09 100644 --- a/tests/automated_denommetadata_test.go +++ b/tests/automated_denommetadata_test.go @@ -335,6 +335,8 @@ func TestADMC_Hub_to_RA_reserved_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestADMC_Hub_to_RA_3rd_Party_EVM send IBC transfer for a non-existing denom from hub to rollapp successfully @@ -635,6 +637,9 @@ func TestADMC_Hub_to_RA_3rd_Party_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestADMC_Hub_to_RA_reserved_Wasm send IBC transfer for a non-existing denom from hub to rollapp with setting {"transferinject":{}} in the memo @@ -951,6 +956,8 @@ func TestADMC_Hub_to_RA_reserved_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestADMC_Hub_to_RA_3rd_Party_Wasm send IBC transfer for a non-existing denom from hub to rollapp successfully @@ -1251,6 +1258,8 @@ func TestADMC_Hub_to_RA_3rd_Party_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } type floatAmountWalletData struct { @@ -1448,6 +1457,8 @@ func TestADMC_Hub_to_RA_Migrate_Dym_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestADMC_Hub_to_RA_Migrate_Dym_Wasm send IBC transfer DYM hub to rollapp successfully @@ -1636,4 +1647,6 @@ func TestADMC_Hub_to_RA_Migrate_Dym_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/bridging_fee_test.go b/tests/bridging_fee_test.go index e42d045a..d6739371 100644 --- a/tests/bridging_fee_test.go +++ b/tests/bridging_fee_test.go @@ -157,6 +157,8 @@ func Test_Non_Rollappchain_Unaffected_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, gaia1, gaiaUserAddr, dymensionIBCDenom, transferAmount) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestChangeBridgeFeeParam_EVM create a prop to change bridge fee and after prop passed, transfer from rollapp to hub should have the new bridge fee. @@ -411,4 +413,6 @@ func TestChangeBridgeFeeParam_EVM(t *testing.T) { require.True(t, isFinalized) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee).Add(transferAmount)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_ack_error_test.go b/tests/eibc_ack_error_test.go index 20396ec8..264d5400 100644 --- a/tests/eibc_ack_error_test.go +++ b/tests/eibc_ack_error_test.go @@ -437,6 +437,8 @@ func TestEIBC_AckError_Dym_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { @@ -797,6 +799,8 @@ func TestEIBC_AckError_RA_Token_EVM(t *testing.T) { testutil.WaitForBlocks(ctx, 20, rollapp1) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) }) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { @@ -1234,6 +1238,8 @@ func TestEIBC_AckError_3rd_Party_Token_EVM(t *testing.T) { testutil.WaitForBlocks(ctx, 20, rollapp1) testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) }) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_AckError_Dym_Wasm(t *testing.T) { @@ -1635,6 +1641,8 @@ func TestEIBC_AckError_Dym_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { @@ -1992,6 +2000,8 @@ func TestEIBC_AckError_RA_Token_Wasm(t *testing.T) { testutil.WaitForBlocks(ctx, 20, rollapp1) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) }) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { @@ -2381,4 +2391,6 @@ func TestEIBC_AckError_3rd_Party_Token_Wasm(t *testing.T) { testutil.WaitForBlocks(ctx, 20, rollapp1) testutil.AssertBalance(t, ctx, rollapp1, rollapp1UserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferAmount)) }) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_corrupted_memo_test.go b/tests/eibc_corrupted_memo_test.go index 01bf2324..1daaa733 100644 --- a/tests/eibc_corrupted_memo_test.go +++ b/tests/eibc_corrupted_memo_test.go @@ -252,4 +252,7 @@ func TestEIBCCorruptedMemoNegative_EVM(t *testing.T) { }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) + } diff --git a/tests/eibc_fee_market_test.go b/tests/eibc_fee_market_test.go index 65fa860a..19fcaa47 100644 --- a/tests/eibc_fee_market_test.go +++ b/tests/eibc_fee_market_test.go @@ -333,6 +333,8 @@ func TestEIBCFulfillAlreadyFulfilledDemand_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestEIBCFulfillAlreadyFulfilledDemand_Wasm attempts to change the amount of an order that already got fulfilled @@ -648,6 +650,8 @@ func TestEIBCAlreadyFulfilledDemand_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestEIBCUnallowedSigner_EVM attempts to change the amount of an order with an unallowed signer @@ -907,6 +911,8 @@ func TestEIBCUnallowedSigner_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestEIBCUnallowedSigner_Wasm attempts to change the amount of an order with an unallowed signer @@ -1167,4 +1173,6 @@ func TestEIBCUnallowedSigner_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_fee_test.go b/tests/eibc_fee_test.go index 513c0f84..d4b1f5dd 100644 --- a/tests/eibc_fee_test.go +++ b/tests/eibc_fee_test.go @@ -230,4 +230,6 @@ func TestEIBCFeeTooHigh_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_feemarket_test.go b/tests/eibc_feemarket_test.go index cde27d43..479d7809 100644 --- a/tests/eibc_feemarket_test.go +++ b/tests/eibc_feemarket_test.go @@ -317,6 +317,8 @@ func TestEIBC_Fee_Market_Success_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { @@ -628,6 +630,8 @@ func TestEIBC_Fee_Market_Success_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { @@ -925,6 +929,9 @@ func TestEIBC_Fee_Market_Auto_Created_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { @@ -1231,6 +1238,8 @@ func TestEIBC_Fee_Market_Auto_Created_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { @@ -1493,6 +1502,9 @@ func TestEIBCUpdateOnAckErrAndTimeout_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { @@ -1751,6 +1763,8 @@ func TestEIBCUpdateOnAckErrAndTimeout_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { @@ -1977,6 +1991,8 @@ func TestEIBCUpdateOnTimeout_Unallowed_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { @@ -2199,4 +2215,6 @@ func TestEIBCUpdateOnTimeout_Unallowed_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_fulfillment_test.go b/tests/eibc_fulfillment_test.go index 46344491..2bdf45a0 100644 --- a/tests/eibc_fulfillment_test.go +++ b/tests/eibc_fulfillment_test.go @@ -405,6 +405,9 @@ func TestEIBCFulfillOnOneRollApp_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestEIBCFulfillOnOneRollApp tests the case where we have 2 rollapps running, we have pending eIBC packets from both rollapps. one of the packets is fulfilled by the market maker, the other packet is not fulfilled. The test verifies that the funds are transferred correctly and the market maker's balance is updated correctly (after grace period). @@ -789,6 +792,9 @@ func TestEIBCFulfillOnOneRollApp_Wasm(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub @@ -1087,6 +1093,9 @@ func TestEIBCFulfillment_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCFulfillment_Wasm(t *testing.T) { @@ -1392,6 +1401,9 @@ func TestEIBCFulfillment_Wasm(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { @@ -1761,6 +1773,9 @@ func TestEIBCFulfillment_two_rollapps_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub @@ -2170,6 +2185,8 @@ func TestEIBCFulfillment_ThirdParty_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an eIBC packet sent from the rollapp to the hub @@ -2573,6 +2590,8 @@ func TestEIBCFulfillment_ThirdParty_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { @@ -2828,6 +2847,8 @@ func TestEIBCFulfillment_ignore_hub_to_RA_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { @@ -3085,4 +3106,7 @@ func TestEIBCFulfillment_ignore_hub_to_RA_Wasm(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_nobalance_test.go b/tests/eibc_nobalance_test.go index 80405a14..d196158b 100644 --- a/tests/eibc_nobalance_test.go +++ b/tests/eibc_nobalance_test.go @@ -225,4 +225,7 @@ func TestEIBCNoBalanceToFulfillOrder_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_not_fulfillment_test.go b/tests/eibc_not_fulfillment_test.go index efe68fa8..dd2dcfb2 100644 --- a/tests/eibc_not_fulfillment_test.go +++ b/tests/eibc_not_fulfillment_test.go @@ -301,6 +301,8 @@ func TestEIBCNotFulfillment_EVM(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCNotFulfillment_Wasm(t *testing.T) { @@ -579,4 +581,7 @@ func TestEIBCNotFulfillment_Wasm(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_pfm_test.go b/tests/eibc_pfm_test.go index 26518838..33ab550f 100644 --- a/tests/eibc_pfm_test.go +++ b/tests/eibc_pfm_test.go @@ -300,6 +300,8 @@ func TestEIBCPFM_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, secondHopIBCDenom, zeroBal) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCPFM_Wasm(t *testing.T) { @@ -579,4 +581,6 @@ func TestEIBCPFM_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, firstHopIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, rollapp2, rollapp2UserAddr, secondHopIBCDenom, zeroBal) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/eibc_timeout_test.go b/tests/eibc_timeout_test.go index 8f08683c..4164a390 100644 --- a/tests/eibc_timeout_test.go +++ b/tests/eibc_timeout_test.go @@ -277,6 +277,9 @@ func TestEIBCTimeoutDymToRollapp_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestEIBCTimeoutFulFillDymToRollapp test send 3rd party IBC denom from dymension to rollapp with timeout @@ -673,6 +676,9 @@ func TestEIBCTimeoutFulFillDymToRollapp_EVM(t *testing.T) { resp, err := dymension.GetNode().QueryPacketCommitments(ctx, "transfer", dymRollAppChan.ChannelID) require.NoError(t, err) require.Equal(t, len(resp.Commitments) == 0, true, "packet commitments still exist") + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { @@ -1065,4 +1071,7 @@ func TestEIBCTimeoutFulFillDymToRollapp_Wasm(t *testing.T) { resp, err := dymension.GetNode().QueryPacketCommitments(ctx, "transfer", dymRollAppChan.ChannelID) require.NoError(t, err) require.Equal(t, len(resp.Commitments) == 0, true, "packet commitments still exist") + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/erc20_ibc_transfer_test.go b/tests/erc20_ibc_transfer_test.go index 090894f1..f4fb6dfa 100644 --- a/tests/erc20_ibc_transfer_test.go +++ b/tests/erc20_ibc_transfer_test.go @@ -251,6 +251,9 @@ func TestERC20HubToRollAppWithoutRegister_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { @@ -537,4 +540,7 @@ func TestERC20RollAppToHubWithRegister_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/frozen_test.go b/tests/frozen_test.go index 84dd9756..58f53c03 100644 --- a/tests/frozen_test.go +++ b/tests/frozen_test.go @@ -372,6 +372,9 @@ func TestRollAppFreeze_EVM(t *testing.T) { // IBC balance should not change require.Equal(t, dymUserOriginBal, dymUserUpdateBal, "dym hub still get transfer from frozen rollapp") + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestRollAppFreeze ensure upon freeze gov proposal passed, no updates can be made to the rollapp and not IBC txs are passing. @@ -740,6 +743,8 @@ func TestRollAppFreeze_Wasm(t *testing.T) { // IBC balance should not change require.Equal(t, dymUserOriginBal, dymUserUpdateBal, "dym hub still get transfer from frozen rollapp") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestOtherRollappNotAffected_EVM ensure upon freeze gov proposal passed, no updates can be made to the rollapp and not IBC txs are passing and other rollapp works fine. @@ -1167,6 +1172,8 @@ func TestOtherRollappNotAffected_EVM(t *testing.T) { require.NoError(t, err) require.Equal(t, true, dymUserUpdateBal2.Equal(dymUserOriginBal2.Add(transferAmount).Sub(bridgingFee)), "dym hub balance did not change") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestOtherRollappNotAffected_Wasm ensure upon freeze gov proposal passed, no updates can be made to the rollapp and not IBC txs are passing and other rollapp works fine. @@ -1607,6 +1614,8 @@ func TestOtherRollappNotAffected_Wasm(t *testing.T) { // Minus 0.1% for bridge fee require.Equal(t, true, dymUserUpdateBal2.Equal(dymUserOriginBal2.Add(transferAmount.Sub(transferAmount.Quo(math.NewInt(1000))))), "dym hub balance did not change") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestPacketRollbacked_EVM ensure upon freeze gov proposal passed, ibc-transfer that not yet finalized's packets will be reverted. @@ -1887,6 +1896,7 @@ func TestPacketRollbacked_EVM(t *testing.T) { // SEND IBC transfer right before vote dymUserOriginBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) _, err = dymension.SendIBCTransfer(ctx, channDymRollApp1.ChannelID, dymensionUserAddr, transferDataFromDym, ibc.TransferOptions{}) require.NoError(t, err) @@ -1904,9 +1914,11 @@ func TestPacketRollbacked_EVM(t *testing.T) { require.NoError(t, err, "proposal status did not change to passed") latestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) testutil.WaitForBlocks(ctx, 10, dymension, rollapp1) // after Grace period, the latest index should be the same lalatestIndex, err := dymension.GetNode().QueryLatestStateIndex(ctx, rollapp1.Config().ChainID) + require.NoError(t, err) require.Equal(t, latestIndex, lalatestIndex, "rollapp state index still increment after grace period. Rerun") // Check if rollapp1 has frozen or not @@ -1920,7 +1932,10 @@ func TestPacketRollbacked_EVM(t *testing.T) { // After rollapp frozen, fund should return dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) require.Equal(t, dymUserOriginBal, dymUserUpdateBal, "funds aren't sent back to sender") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestPacketRollbacked_Wasm ensure upon freeze gov proposal passed, ibc-transfer that not yet finalized's packets will be reverted. @@ -2250,7 +2265,11 @@ func TestPacketRollbacked_Wasm(t *testing.T) { // After rollapp frozen, fund should return dymUserUpdateBal, err := dymension.GetBalance(ctx, dymensionUserAddr, dymension.Config().Denom) + require.NoError(t, err) require.Equal(t, dymUserOriginBal, dymUserUpdateBal, "funds aren't sent back to sender") + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestRollAppFreezeNoBrokenInvariants_EVM ensure upon freeze gov proposal passed, no updates can be made to the rollapp evm. No invariants broken. @@ -2586,6 +2605,9 @@ func TestRollAppFreezeNoBrokenInvariants_EVM(t *testing.T) { // Run invariant check _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "block-height-to-finalization-queue") require.NoError(t, err) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestRollAppFreezeNoBrokenInvariants_Wasm ensure upon freeze gov proposal passed, no updates can be made to the rollapp wasm. No invariants broken. @@ -2921,6 +2943,9 @@ func TestRollAppFreezeNoBrokenInvariants_Wasm(t *testing.T) { // Run invariant check _, err = dymension.GetNode().CrisisInvariant(ctx, dymensionUser.KeyName(), "rollapp", "block-height-to-finalization-queue") require.NoError(t, err) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestRollAppSqcSlashedJailed_EVM ensure upon freeze gov proposal passed, Sequencer should be slashed with all the bond and jailed. Inability to register a new sequencer @@ -3330,6 +3355,9 @@ func TestRollAppSqcSlashedJailed_EVM(t *testing.T) { require.Equal(t, true, sequencerStatus.Sequencers[0].Jailed, "sequencer should have been jailed") require.Equal(t, false, sequencerStatus.Sequencers[0].Tokens.AmountOf("adym").IsPositive(), "sequencer should have been slashed and have zero bond") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) + // TODO: Make sure we can not register a new sequencer } @@ -3740,6 +3768,8 @@ func TestRollAppSqcSlashedJailed_Wasm(t *testing.T) { require.Equal(t, true, sequencerStatus.Sequencers[0].Jailed, "sequencer should have been jailed") require.Equal(t, false, sequencerStatus.Sequencers[0].Tokens.AmountOf("adym").IsPositive(), "sequencer should have been slashed and have zero bond") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) // TODO: Make sure we can not register a new sequencer } @@ -4068,6 +4098,8 @@ func TestRollAppFreezeStateNotProgressing_EVM(t *testing.T) { // Check rollapp1 state index not increment require.NoError(t, err) require.Equal(t, fmt.Sprint(targetIndex), latestIndex.StateIndex.Index, "rollapp state index still increment") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { @@ -4389,6 +4421,8 @@ func TestRollAppFreezeStateNotProgressing_Wasm(t *testing.T) { // Check rollapp1 state index not increment require.NoError(t, err) require.Equal(t, fmt.Sprint(targetIndex), latestIndex.StateIndex.Index, "rollapp state index still increment") + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollAppFreezeEibcPending_EVM(t *testing.T) { @@ -4731,6 +4765,8 @@ func TestRollAppFreezeEibcPending_EVM(t *testing.T) { balanceOfDymUserAddr, err := dymension.GetBalance(ctx, dymensionUserAddr, rollappIbcDenom) require.NoError(t, err) require.Equal(t, (transferAmount.Sub(bridgingFee)), balanceOfDymUserAddr) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { @@ -5073,4 +5109,7 @@ func TestRollAppFreezeEibcPending_Wasm(t *testing.T) { balanceOfDymUserAddr, err := dymension.GetBalance(ctx, dymensionUserAddr, rollappIbcDenom) require.NoError(t, err) require.Equal(t, (transferAmount.Sub(bridgingFee)), balanceOfDymUserAddr) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/genesis_transfer_test.go b/tests/genesis_transfer_test.go index 32b183b9..6f78dde4 100644 --- a/tests/genesis_transfer_test.go +++ b/tests/genesis_transfer_test.go @@ -167,6 +167,9 @@ func TestGenesisTransferBridgeBlocking_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestGenesisTransferBridgeBlocking_Wasm(t *testing.T) { @@ -317,6 +320,9 @@ func TestGenesisTransferBridgeBlocking_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestGenesisTransferConnectionBlock_EVM(t *testing.T) { @@ -476,6 +482,9 @@ func TestGenesisTransferConnectionBlock_EVM(t *testing.T) { connections, err := r.GetConnections(ctx, eRep, dymension.Config().ChainID) require.NoError(t, err) require.Equal(t, 2, len(connections)) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestGenesisTransferConnectionBlock_Wasm(t *testing.T) { @@ -635,4 +644,7 @@ func TestGenesisTransferConnectionBlock_Wasm(t *testing.T) { connections, err := r.GetConnections(ctx, eRep, dymension.Config().ChainID) require.NoError(t, err) require.Equal(t, 2, len(connections)) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/hardfork_test.go b/tests/hardfork_test.go index c1fc54b7..47ef32a0 100644 --- a/tests/hardfork_test.go +++ b/tests/hardfork_test.go @@ -550,6 +550,8 @@ func TestHardFork_EVM(t *testing.T) { // check assets balance testutil.AssertBalance(t, ctx, newRollApp, newRollAppUserAddr, newRollApp.Config().Denom, newRollAppBalanceBefore.Sub(transferDataFromNewRollApp.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, newRollAppIbcDenom, transferAmount.Add(transferAmount).Sub(bridgeFee).Sub(bridgeFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestHardFork_Wasm(t *testing.T) { @@ -1077,6 +1079,8 @@ func TestHardFork_Wasm(t *testing.T) { // check assets balance testutil.AssertBalance(t, ctx, newRollApp, newRollAppUserAddr, newRollApp.Config().Denom, newRollAppBalanceBefore.Sub(transferDataFromNewRollApp.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, newRollAppIbcDenom, transferAmount.Add(transferAmount).Sub(bridgeFee).Sub(bridgeFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestHardForkRecoverIbcClient_EVM(t *testing.T) { @@ -1632,4 +1636,6 @@ func TestHardForkRecoverIbcClient_EVM(t *testing.T) { // check assets balance testutil.AssertBalance(t, ctx, newRollApp, newRollAppUserAddr, newRollApp.Config().Denom, newRollAppBalanceBefore.Sub(transferDataFromNewRollApp.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, newRollAppIbcDenom, transferAmount.Add(transferAmount).Sub(bridgeFee).Sub(bridgeFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/ibc_finalize_block_test.go b/tests/ibc_finalize_block_test.go index 1d9f37f2..ff5b2baf 100644 --- a/tests/ibc_finalize_block_test.go +++ b/tests/ibc_finalize_block_test.go @@ -200,6 +200,9 @@ func TestDymFinalizeBlock_OnRecvPacket_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and fail on ack. @@ -401,6 +404,9 @@ func TestDymFinalizeBlock_OnAckPacket_EVM(t *testing.T) { // Make sure that the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and timeout. @@ -582,6 +588,9 @@ func TestDymFinalizeBlock_OnTimeOutPacket_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and ack failed. @@ -770,6 +779,9 @@ func TestDymFinalizeBlock_OnRecvPacket_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and fail on ack. @@ -972,6 +984,9 @@ func TestDymFinalizeBlock_OnAckPacket_Wasm(t *testing.T) { // Make sure that the ack contains error require.True(t, bytes.Contains(ack.Acknowledgement, []byte("error"))) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the dym and timeout. @@ -1149,4 +1164,7 @@ func TestDymFinalizeBlock_OnTimeOutPacket_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/ibc_grace_period_test.go b/tests/ibc_grace_period_test.go index 9f1f85dc..64789a2c 100644 --- a/tests/ibc_grace_period_test.go +++ b/tests/ibc_grace_period_test.go @@ -307,6 +307,9 @@ func TestIBCGracePeriodCompliance_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestIBCGracePeriodCompliance ensures that the grace period for transaction finalization is correctly enforced on hub and rollapp. @@ -593,6 +596,8 @@ func TestIBCGracePeriodCompliance_Wasm(t *testing.T) { } }, ) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { @@ -847,6 +852,9 @@ func TestDelayedAck_NoFinalizedStates_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { @@ -1100,6 +1108,9 @@ func TestDelayedAck_NoFinalizedStates_Wasm(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestDelayedAck_RelayerDown_EVM(t *testing.T) { @@ -1407,6 +1418,9 @@ func TestDelayedAck_RelayerDown_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { @@ -1701,4 +1715,7 @@ func TestDelayedAck_RelayerDown_Wasm(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/ibc_timeout_test.go b/tests/ibc_timeout_test.go index a0402482..0fb412e9 100644 --- a/tests/ibc_timeout_test.go +++ b/tests/ibc_timeout_test.go @@ -268,6 +268,9 @@ func TestIBCTransferTimeout_EVM(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // This test case verifies the system's behavior when an IBC packet sent from the rollapp to the hub times out. @@ -507,4 +510,7 @@ func TestIBCTransferTimeout_Wasm(t *testing.T) { // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, zeroBal) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/ibc_transfer_test.go b/tests/ibc_transfer_test.go index 3e988680..fd045f81 100644 --- a/tests/ibc_transfer_test.go +++ b/tests/ibc_transfer_test.go @@ -274,6 +274,9 @@ func TestIBCTransferSuccess_EVM(t *testing.T) { require.NoError(t, err) erc20MAccAddr := erc20MAcc.Account.BaseAccount.Address testutil.AssertBalance(t, ctx, rollapp1, erc20MAccAddr, dymensionIBCDenom, transferData.Amount) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestIBCTransferSuccess ensure that the transfer between Hub and Rollapp is accurate. @@ -445,6 +448,9 @@ func TestIBCTransferSuccess_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, dymensionOrigBal.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestGenesisIBCTransferWithReservedMemo_EVM ensure that after the genesis transfer phase for rollapp is completed, transfer memo contain a reserved name field cannot be used. @@ -601,6 +607,8 @@ func TestGenesisIBCTransferReservedMemo_EVM(t *testing.T) { // Assert fund was not transferred testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } // TestGenesisIBCTransferWithReservedMemo_Wasm ensure that after the genesis transfer phase for rollapp is completed, transfer memo contain a reserved name field cannot be used. @@ -758,4 +766,7 @@ func TestGenesisIBCTransferReservedMemo_Wasm(t *testing.T) { // Assert fund was not transferred testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/rollapp_upgrade_test.go b/tests/rollapp_upgrade_test.go index 233d1e0e..08755aa8 100644 --- a/tests/rollapp_upgrade_test.go +++ b/tests/rollapp_upgrade_test.go @@ -225,6 +225,8 @@ func TestRollappUpgradeNonStateBreaking_EVM(t *testing.T) { testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount).Sub(transferAmount)) // minus 0.1% of transfer amount for bridge fee testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, (transferAmount.Sub(bridgingFee)).MulRaw(2)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { @@ -435,6 +437,9 @@ func TestRollappUpgradeNonStateBreaking_Wasm(t *testing.T) { testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, dymension.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, dymensionIBCDenom, transferAmount) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollapp_EVM_Upgrade(t *testing.T) { @@ -688,6 +693,8 @@ func TestRollapp_EVM_Upgrade(t *testing.T) { // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func TestRollapp_Wasm_Upgrade(t *testing.T) { @@ -941,4 +948,6 @@ func TestRollapp_Wasm_Upgrade(t *testing.T) { // Assert funds were returned to the sender after the timeout has occured testutil.AssertBalance(t, ctx, rollapp1, rollappUserAddr, rollapp1.Config().Denom, walletAmount.Sub(transferData.Amount)) testutil.AssertBalance(t, ctx, dymension, dymensionUserAddr, rollappIBCDenom, transferAmount.Sub(bridgingFee)) + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } diff --git a/tests/setup.go b/tests/setup.go index 136079c8..492df1ab 100644 --- a/tests/setup.go +++ b/tests/setup.go @@ -84,12 +84,12 @@ type ForwardMetadata struct { } const ( - ibcPath = "dymension-demo" - anotherIbcPath = "dymension-demo2" - BLOCK_FINALITY_PERIOD = 30 - EventDemandOrderCreated = "dymensionxyz.dymension.eibc.EventDemandOrderCreated" - EventDemandOrderFulfilled = "dymensionxyz.dymension.eibc.EventDemandOrderFulfilled" - EventDemandOrderFeeUpdated = "dymensionxyz.dymension.eibc.EventDemandOrderFeeUpdated" + ibcPath = "dymension-demo" + anotherIbcPath = "dymension-demo2" + BLOCK_FINALITY_PERIOD = 30 + EventDemandOrderCreated = "dymensionxyz.dymension.eibc.EventDemandOrderCreated" + EventDemandOrderFulfilled = "dymensionxyz.dymension.eibc.EventDemandOrderFulfilled" + EventDemandOrderFeeUpdated = "dymensionxyz.dymension.eibc.EventDemandOrderFeeUpdated" EventDemandOrderPacketStatusUpdated = "dymensionxyz.dymension.eibc.EventDemandOrderPacketStatusUpdated" ) @@ -943,3 +943,31 @@ func getEibcEventsOfType(chain *cosmos.CosmosChain, startHeight int64, endHeight func BuildEIbcMemo(eibcFee math.Int) string { return fmt.Sprintf(`{"eibc": {"fee": "%s"}}`, eibcFee.String()) } +func CheckInvariant(t *testing.T, ctx context.Context, dymension *dym_hub.DymHub, keyName string) { + _, err := dymension.GetNode().CrisisInvariant(ctx, keyName, "eibc", "demand-order-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "eibc", "underlying-packet-exist") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "rollapp", "rollapp-state-index") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "rollapp", "rollapp-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "rollapp", "block-height-to-finalization-queue") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "rollapp", "rollapp-by-eip155-key") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "rollapp", "rollapp-finalized-state") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "sequencer", "sequencers-count") + require.NoError(t, err) + + _, err = dymension.GetNode().CrisisInvariant(ctx, keyName, "sequencer", "sequencers-per-rollapp") + require.NoError(t, err) +} diff --git a/tests/tx_batch_finalization_test.go b/tests/tx_batch_finalization_test.go index cb7355ae..3d9ebcd2 100644 --- a/tests/tx_batch_finalization_test.go +++ b/tests/tx_batch_finalization_test.go @@ -303,6 +303,9 @@ func TestBatchFinalization_Wasm(t *testing.T) { require.True(t, (currentFinalizedRollappDymHeight > BLOCK_FINALITY_PERIOD) && (lastFinalizedRollappHeight > rollappHeight), fmt.Sprintf("Mismatch in batch finalization check. Current finalization hub height: %d. Dispute period: %d. Last finalized rollapp height: %d. Rollapp height asserted: %d", currentFinalizedRollappDymHeight, BLOCK_FINALITY_PERIOD, lastFinalizedRollappHeight, rollappHeight)) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser.KeyName()) } func IsAnyRollappStateFinalized(ctx context.Context, dymension *dym_hub.DymHub, rollappChainID string, timeoutSecs int) (bool, error) { diff --git a/tests/upgrade_hub_test.go b/tests/upgrade_hub_test.go index 75346e2e..0ca39819 100644 --- a/tests/upgrade_hub_test.go +++ b/tests/upgrade_hub_test.go @@ -588,4 +588,7 @@ func TestHubUpgrade(t *testing.T) { } }, ) + + // Run invariant check + CheckInvariant(t, ctx, dymension, dymensionUser1.KeyName()) }