From 85c64fd3c43b8ab9efb820ac2c0afbf4e3223690 Mon Sep 17 00:00:00 2001 From: Marcel Moura <5615598+marcelstanley@users.noreply.github.com> Date: Thu, 1 Aug 2024 19:00:59 -0300 Subject: [PATCH] fix(config): disable claimer on experimental mode --- build/compose-node.yaml | 2 ++ internal/node/config/config.go | 3 ++- internal/node/config/config_test.go | 36 +++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 internal/node/config/config_test.go diff --git a/build/compose-node.yaml b/build/compose-node.yaml index b157b4482..fc85e759d 100644 --- a/build/compose-node.yaml +++ b/build/compose-node.yaml @@ -17,3 +17,5 @@ services: CARTESI_FEATURE_DISABLE_CLAIMER: "false" CARTESI_HTTP_ADDRESS: "0.0.0.0" CARTESI_HTTP_PORT: "10000" + CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED: true + CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT: redis://default:VERY_SECRET_PASWORD@rollups-nodes-redis.internal:6379 diff --git a/internal/node/config/config.go b/internal/node/config/config.go index 6f9d6391d..a207917de 100644 --- a/internal/node/config/config.go +++ b/internal/node/config/config.go @@ -100,8 +100,9 @@ func FromEnv() NodeConfig { if getExperimentalSunodoValidatorEnabled() { config.ExperimentalSunodoValidatorRedisEndpoint = getExperimentalSunodoValidatorRedisEndpoint() + config.FeatureDisableClaimer = true } - if !getFeatureDisableClaimer() && !getExperimentalSunodoValidatorEnabled() { + if !config.FeatureDisableClaimer && !getExperimentalSunodoValidatorEnabled() { config.Auth = authFromEnv() } return config diff --git a/internal/node/config/config_test.go b/internal/node/config/config_test.go new file mode 100644 index 000000000..7f8b0ebc1 --- /dev/null +++ b/internal/node/config/config_test.go @@ -0,0 +1,36 @@ +package config + +import ( + "os" + "testing" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/suite" +) + +type ConfigTestSuite struct { + suite.Suite +} + +func (s *ConfigTestSuite) SetupSuite() { + os.Setenv("CARTESI_BLOCKCHAIN_ID", "31337") + os.Setenv("CARTESI_BLOCKCHAIN_HTTP_ENDPOINT", "http://localhost:8545") + os.Setenv("CARTESI_BLOCKCHAIN_WS_ENDPOINT", "ws://localhost:8545") + os.Setenv("CARTESI_CONTRACTS_APPLICATION_ADDRESS", "0x") + os.Setenv("CARTESI_CONTRACTS_HISTORY_ADDRESS", "0x") + os.Setenv("CARTESI_CONTRACTS_AUTHORITY_ADDRESS", "0x") + os.Setenv("CARTESI_CONTRACTS_INPUT_BOX_ADDRESS", "0x") + os.Setenv("CARTESI_CONTRACTS_INPUT_BOX_DEPLOYMENT_BLOCK_NUMBER", "0") + os.Setenv("CARTESI_SNAPSHOT_DIR", "/tmp") +} + +func TestConfigTest(t *testing.T) { + suite.Run(t, new(ConfigTestSuite)) +} + +func (s *ConfigTestSuite) TestSunodoExperimentalModeDisablesClaimer() { + os.Setenv("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_ENABLED", "true") + os.Setenv("CARTESI_EXPERIMENTAL_SUNODO_VALIDATOR_REDIS_ENDPOINT", "redis://") + c := FromEnv() + assert.Equal(s.T(), true, c.FeatureDisableClaimer) +}