From fab7dce7d0eea7908cbbbfcd10ef65bee6cfed60 Mon Sep 17 00:00:00 2001 From: lumtis Date: Wed, 10 Apr 2024 12:52:00 +0200 Subject: [PATCH] fix tests --- .../core_context/zeta_core_context_test.go | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/zetaclient/core_context/zeta_core_context_test.go b/zetaclient/core_context/zeta_core_context_test.go index 46152b5d48..93b0e1c57f 100644 --- a/zetaclient/core_context/zeta_core_context_test.go +++ b/zetaclient/core_context/zeta_core_context_test.go @@ -7,6 +7,7 @@ import ( "github.com/stretchr/testify/require" "github.com/zeta-chain/zetacore/pkg/chains" "github.com/zeta-chain/zetacore/testutil/sample" + lightclienttypes "github.com/zeta-chain/zetacore/x/lightclient/types" observertypes "github.com/zeta-chain/zetacore/x/observer/types" clientcommon "github.com/zeta-chain/zetacore/zetaclient/common" "github.com/zeta-chain/zetacore/zetaclient/config" @@ -26,7 +27,9 @@ func assertPanic(t *testing.T, f func(), errorLog string) { func getTestCoreContext( evmChain chains.Chain, evmChainParams *observertypes.ChainParams, - ccFlags observertypes.CrosschainFlags) *corecontext.ZetaCoreContext { + ccFlags observertypes.CrosschainFlags, + verificationFlags lightclienttypes.VerificationFlags, +) *corecontext.ZetaCoreContext { // create config cfg := config.NewConfig() cfg.EVMChainConfigs[evmChain.ChainId] = config.EVMConfig{ @@ -45,6 +48,7 @@ func getTestCoreContext( nil, "", ccFlags, + verificationFlags, true, zerolog.Logger{}, ) @@ -318,13 +322,14 @@ func TestIsOutboundObservationEnabled(t *testing.T) { // create test chain params and flags evmChain := chains.EthChain() ccFlags := *sample.CrosschainFlags() + verificationFlags := sample.VerificationFlags() chainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, IsSupported: true, } t.Run("should return true if chain is supported and outbound flag is enabled", func(t *testing.T) { - coreCTX := getTestCoreContext(evmChain, chainParams, ccFlags) + coreCTX := getTestCoreContext(evmChain, chainParams, ccFlags, verificationFlags) require.True(t, corecontext.IsOutboundObservationEnabled(coreCTX, *chainParams)) }) t.Run("should return false if chain is not supported yet", func(t *testing.T) { @@ -332,13 +337,13 @@ func TestIsOutboundObservationEnabled(t *testing.T) { ChainId: evmChain.ChainId, IsSupported: false, } - coreCTXUnsupported := getTestCoreContext(evmChain, paramsUnsupported, ccFlags) + coreCTXUnsupported := getTestCoreContext(evmChain, paramsUnsupported, ccFlags, verificationFlags) require.False(t, corecontext.IsOutboundObservationEnabled(coreCTXUnsupported, *paramsUnsupported)) }) t.Run("should return false if outbound flag is disabled", func(t *testing.T) { flagsDisabled := ccFlags flagsDisabled.IsOutboundEnabled = false - coreCTXDisabled := getTestCoreContext(evmChain, chainParams, flagsDisabled) + coreCTXDisabled := getTestCoreContext(evmChain, chainParams, flagsDisabled, verificationFlags) require.False(t, corecontext.IsOutboundObservationEnabled(coreCTXDisabled, *chainParams)) }) } @@ -347,13 +352,14 @@ func TestIsInboundObservationEnabled(t *testing.T) { // create test chain params and flags evmChain := chains.EthChain() ccFlags := *sample.CrosschainFlags() + verificationFlags := sample.VerificationFlags() chainParams := &observertypes.ChainParams{ ChainId: evmChain.ChainId, IsSupported: true, } t.Run("should return true if chain is supported and inbound flag is enabled", func(t *testing.T) { - coreCTX := getTestCoreContext(evmChain, chainParams, ccFlags) + coreCTX := getTestCoreContext(evmChain, chainParams, ccFlags, verificationFlags) require.True(t, corecontext.IsInboundObservationEnabled(coreCTX, *chainParams)) }) t.Run("should return false if chain is not supported yet", func(t *testing.T) { @@ -361,13 +367,13 @@ func TestIsInboundObservationEnabled(t *testing.T) { ChainId: evmChain.ChainId, IsSupported: false, } - coreCTXUnsupported := getTestCoreContext(evmChain, paramsUnsupported, ccFlags) + coreCTXUnsupported := getTestCoreContext(evmChain, paramsUnsupported, ccFlags, verificationFlags) require.False(t, corecontext.IsInboundObservationEnabled(coreCTXUnsupported, *paramsUnsupported)) }) t.Run("should return false if inbound flag is disabled", func(t *testing.T) { flagsDisabled := ccFlags flagsDisabled.IsInboundEnabled = false - coreCTXDisabled := getTestCoreContext(evmChain, chainParams, flagsDisabled) + coreCTXDisabled := getTestCoreContext(evmChain, chainParams, flagsDisabled, verificationFlags) require.False(t, corecontext.IsInboundObservationEnabled(coreCTXDisabled, *chainParams)) }) }