mirror of
https://github.com/OffchainLabs/prysm.git
synced 2026-01-10 05:47:59 -05:00
E2E: switching to run time generated yaml for web3signer (#10513)
* switching to run time generated yaml * fixing bazel * fixing unit test * fixing linter problems Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
This commit is contained in:
@@ -104,3 +104,8 @@ func E2EMainnetTestConfig() *BeaconChainConfig {
|
||||
func E2EMainnetConfigYaml() []byte {
|
||||
return ConfigToYaml(E2EMainnetTestConfig())
|
||||
}
|
||||
|
||||
// E2ETestConfigYaml returns the e2e config in yaml format.
|
||||
func E2ETestConfigYaml() []byte {
|
||||
return ConfigToYaml(E2ETestConfig())
|
||||
}
|
||||
|
||||
@@ -36,7 +36,6 @@ go_test(
|
||||
"//beacon-chain/db/testing:go_default_library",
|
||||
"//beacon-chain/operations/slashings/mock:go_default_library",
|
||||
"//beacon-chain/state/stategen/mock:go_default_library",
|
||||
"//build/bazel:go_default_library",
|
||||
"//config/params:go_default_library",
|
||||
"//crypto/bls:go_default_library",
|
||||
"//proto/prysm/v1alpha1:go_default_library",
|
||||
|
||||
@@ -63,6 +63,5 @@ go_test(
|
||||
"//config/params:go_default_library",
|
||||
"//testing/endtoend/params:go_default_library",
|
||||
"//testing/require:go_default_library",
|
||||
"@io_bazel_rules_go//go/tools/bazel:go_default_library",
|
||||
],
|
||||
)
|
||||
|
||||
@@ -10,6 +10,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"path"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
@@ -18,6 +19,7 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
"github.com/prysmaticlabs/prysm/config/params"
|
||||
"github.com/prysmaticlabs/prysm/crypto/bls"
|
||||
"github.com/prysmaticlabs/prysm/io/file"
|
||||
"github.com/prysmaticlabs/prysm/runtime/interop"
|
||||
e2e "github.com/prysmaticlabs/prysm/testing/endtoend/params"
|
||||
e2etypes "github.com/prysmaticlabs/prysm/testing/endtoend/types"
|
||||
@@ -37,16 +39,14 @@ type rawKeyFile struct {
|
||||
}
|
||||
|
||||
type Web3RemoteSigner struct {
|
||||
ctx context.Context
|
||||
started chan struct{}
|
||||
configFilePath string
|
||||
cmd *exec.Cmd
|
||||
ctx context.Context
|
||||
started chan struct{}
|
||||
cmd *exec.Cmd
|
||||
}
|
||||
|
||||
func NewWeb3RemoteSigner(configFilePath string) *Web3RemoteSigner {
|
||||
func NewWeb3RemoteSigner() *Web3RemoteSigner {
|
||||
return &Web3RemoteSigner{
|
||||
started: make(chan struct{}, 1),
|
||||
configFilePath: configFilePath,
|
||||
started: make(chan struct{}, 1),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -69,10 +69,15 @@ func (w *Web3RemoteSigner) Start(ctx context.Context) error {
|
||||
return err
|
||||
}
|
||||
|
||||
testDir, err := w.createTestnetDir()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
network := "minimal"
|
||||
if len(w.configFilePath) > 0 {
|
||||
if len(testDir) > 0 {
|
||||
// A file path to yaml config file is acceptable network argument.
|
||||
network = w.configFilePath
|
||||
network = testDir
|
||||
}
|
||||
|
||||
args := []string{
|
||||
@@ -231,3 +236,21 @@ func writeKeystoreKeys(ctx context.Context, keystorePath string, numKeys uint64)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (w *Web3RemoteSigner) createTestnetDir() (string, error) {
|
||||
testNetDir := e2e.TestParams.TestPath + "/web3signer-testnet"
|
||||
configPath := filepath.Join(testNetDir, "config.yaml")
|
||||
rawYaml := params.E2ETestConfigYaml()
|
||||
// Add in deposit contract in yaml
|
||||
depContractStr := fmt.Sprintf("\nDEPOSIT_CONTRACT_ADDRESS: %#x", e2e.TestParams.ContractAddress)
|
||||
rawYaml = append(rawYaml, []byte(depContractStr)...)
|
||||
|
||||
if err := file.MkdirAll(testNetDir); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := file.WriteFile(configPath, rawYaml); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
return configPath, nil
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/bazelbuild/rules_go/go/tools/bazel"
|
||||
"github.com/prysmaticlabs/prysm/config/params"
|
||||
"github.com/prysmaticlabs/prysm/testing/endtoend/components"
|
||||
e2eparams "github.com/prysmaticlabs/prysm/testing/endtoend/params"
|
||||
@@ -14,11 +13,8 @@ import (
|
||||
|
||||
func TestWeb3RemoteSigner_StartsAndReturnsPublicKeys(t *testing.T) {
|
||||
require.NoError(t, e2eparams.Init(0))
|
||||
fp, err := bazel.Runfile("config/params/testdata/e2e_config.yaml")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
wsc := components.NewWeb3RemoteSigner(fp)
|
||||
|
||||
wsc := components.NewWeb3RemoteSigner()
|
||||
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
|
||||
defer cancel()
|
||||
|
||||
@@ -17,7 +17,6 @@ import (
|
||||
"github.com/pkg/errors"
|
||||
types "github.com/prysmaticlabs/eth2-types"
|
||||
"github.com/prysmaticlabs/prysm/beacon-chain/core/transition"
|
||||
"github.com/prysmaticlabs/prysm/build/bazel"
|
||||
"github.com/prysmaticlabs/prysm/config/params"
|
||||
eth "github.com/prysmaticlabs/prysm/proto/prysm/v1alpha1"
|
||||
"github.com/prysmaticlabs/prysm/testing/assert"
|
||||
@@ -92,11 +91,7 @@ func (r *testRunner) run() {
|
||||
|
||||
var web3RemoteSigner *components.Web3RemoteSigner
|
||||
if config.UseWeb3RemoteSigner {
|
||||
cfg, err := bazel.Runfile("config/params/testdata/e2e_config.yaml")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
web3RemoteSigner = components.NewWeb3RemoteSigner(cfg)
|
||||
web3RemoteSigner = components.NewWeb3RemoteSigner()
|
||||
g.Go(func() error {
|
||||
if err := web3RemoteSigner.Start(ctx); err != nil {
|
||||
return errors.Wrap(err, "failed to start web3 remote signer")
|
||||
|
||||
Reference in New Issue
Block a user