diff --git a/Taskfile.yml b/Taskfile.yml index 59bac0ee2..d7ab42ef5 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -190,7 +190,7 @@ tasks: desc: Start the dev environment(with testnet) without rebuilding docker image dir: test # different module cmds: - - go test ./integration -run ^TestLocalDevSetup$ -timeout 12h -dev -v + - go test ./integration -run ^TestLocalDevSetup$ -timeout 12h -dev -v {{.CLI_ARGS}} # ************ test ************ # test with build:docker task support passing CLI_ARGS to go test, e.g. task test:act -- -debug diff --git a/cmd/kwil-admin/nodecfg/generate.go b/cmd/kwil-admin/nodecfg/generate.go index 882dc621c..8f8c050ff 100644 --- a/cmd/kwil-admin/nodecfg/generate.go +++ b/cmd/kwil-admin/nodecfg/generate.go @@ -79,6 +79,7 @@ type TestnetGenerateConfig struct { SnapshotHeights uint64 Forks map[string]*uint64 PrivateMode bool + PrivateRPC bool } // ConfigOpts is a struct to alter the generation of the node config. @@ -389,6 +390,8 @@ func GenerateTestnetConfig(genCfg *TestnetGenerateConfig, opts *ConfigOpts) erro } } + cfg.AppConfig.PrivateRPC = genCfg.PrivateRPC + err = WriteConfigFile(kwildcfg.ConfigFilePath(nodeDir), cfg) if err != nil { return fmt.Errorf("failed to write config file: %w", err) diff --git a/test/acceptance/helper.go b/test/acceptance/helper.go index 3538d3c63..0269ec27e 100644 --- a/test/acceptance/helper.go +++ b/test/acceptance/helper.go @@ -53,8 +53,8 @@ type ActTestCfg struct { CreatorSigner auth.Signer VisitorSigner auth.Signer - GasEnabled bool - AuthenticateRPCs bool + GasEnabled bool + PrivateRPC bool } func (e *ActTestCfg) CreatorIdent() []byte { @@ -134,6 +134,9 @@ func (r *ActHelper) LoadConfig() *ActTestCfg { DockerComposeOverrideFile: getEnv("KACT_DOCKER_COMPOSE_OVERRIDE_FILE", "./docker-compose.override.yml"), } + cfg.PrivateRPC, err = strconv.ParseBool(getEnv("KACT_PRIVATE_RPC", "false")) + require.NoError(r.t, err, "invalid privateRPC bool") + cfg.GasEnabled, err = strconv.ParseBool(getEnv("KACT_GAS_ENABLED", "false")) require.NoError(r.t, err, "invalid gasEnabled bool") @@ -189,7 +192,7 @@ func (r *ActHelper) generateNodeConfig() { OutputDir: tmpPath, JoinExpiry: 14400, WithoutGasCosts: !r.cfg.GasEnabled, - AuthenticateRPCs: r.cfg.AuthenticateRPCs, + AuthenticateRPCs: r.cfg.PrivateRPC, Allocs: map[string]*big.Int{ creatorIdent: bal, }, diff --git a/test/acceptance/kwild_test.go b/test/acceptance/kwild_test.go index 720804245..7efdb5db5 100644 --- a/test/acceptance/kwild_test.go +++ b/test/acceptance/kwild_test.go @@ -254,7 +254,7 @@ func TestTypes(t *testing.T) { } } -func TestPrivateMode(t *testing.T) { +func TestDataPrivateMode(t *testing.T) { if testing.Short() { t.Skip() } @@ -270,7 +270,7 @@ func TestPrivateMode(t *testing.T) { // setup for each driver helper := acceptance.NewActHelper(t) cfg := helper.LoadConfig() - cfg.AuthenticateRPCs = true + cfg.PrivateRPC = true if !*remote { helper.Setup(ctx) } diff --git a/test/integration/helper.go b/test/integration/helper.go index d0742dd36..3f5c446ed 100644 --- a/test/integration/helper.go +++ b/test/integration/helper.go @@ -120,6 +120,7 @@ type IntTestConfig struct { WithGas bool PopulatePersistentPeers bool PrivateMode bool + PrivateRPC bool // The following options are mutually exclusive, as they are used to use // alternate docker images with kwild variants with differnet extensions. @@ -322,6 +323,12 @@ func WithPrivateMode() HelperOpt { } } +func WithPrivateRPC() HelperOpt { + return func(r *IntHelper) { + r.cfg.PrivateRPC = true + } +} + func WithWaitTimeout(timeout time.Duration) HelperOpt { return func(r *IntHelper) { r.cfg.WaitTimeout = timeout @@ -346,6 +353,9 @@ func (r *IntHelper) LoadConfig() { DockerComposeOverrideFile: getEnv("KIT_DOCKER_COMPOSE_OVERRIDE_FILE", "./docker-compose.override.yml"), } + r.cfg.PrivateRPC, err = strconv.ParseBool(getEnv("KIT_PRIVATE_RPC", "false")) + require.NoError(r.t, err, "invalid privateRPC bool") + creatorPk, err := crypto.Secp256k1PrivateKeyFromHex(r.cfg.CreatorRawPk) require.NoError(r.t, err, "invalid creator private key") @@ -359,7 +369,6 @@ func (r *IntHelper) LoadConfig() { r.cfg.VoteExpiry = 14400 r.cfg.JoinExpiry = 14400 r.cfg.PopulatePersistentPeers = true - r.cfg.PrivateMode = false r.cfg.AdminRPC = "/tmp/admin.socket" r.cfg.WaitTimeout = 30 * time.Second } @@ -449,6 +458,7 @@ func (r *IntHelper) generateNodeConfig(homeDir string) { HostnamePrefix: "kwil-", HostnameSuffix: "", PrivateMode: r.cfg.PrivateMode, + PrivateRPC: r.cfg.PrivateRPC, // use this to ease the process running test parallel // NOTE: need to match docker-compose kwild service name