prysm-pulse/endtoend/params/params.go
Preston Van Loon 7cc32c4dda
Various code inspection resolutions (#7438)
* remove unused code

* remove defer use in loop

* Remove unused methods and constants

* gofmt and gaz

* nilness check

* remove unused args

* Add TODO for refactoring subscribeWithBase to remove unused arg. It seems too involved to include in this sweeping PR. https://github.com/prysmaticlabs/prysm/issues/7437

* replace empty slice declaration

* Remove unnecessary type conversions

* remove redundant type declaration

* rename receivers to be consistent

* Remove bootnode query tool. It is now obsolete by discv5

* Remove relay node. It is no longer used or supported

* Revert "Remove relay node. It is no longer used or supported"

This reverts commit 4bd7717334dad85ef4766ed9bc4da711fb5fa810.

* Delete unused test directory

* Delete unsupported gcp startup script

* Delete old k8s script

* build fixes

* fix build

* go mod tidy

* revert slasher/db/kv/block_header.go

* fix build

* remove redundant nil check

* combine func args

Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com>
Co-authored-by: Victor Farazdagi <simple.square@gmail.com>
2020-10-12 08:11:05 +00:00

86 lines
2.7 KiB
Go

// Package params defines all custom parameter configurations
// for running end to end tests.
package params
import (
"errors"
"fmt"
"os"
"path"
"strconv"
"github.com/bazelbuild/rules_go/go/tools/bazel"
"github.com/ethereum/go-ethereum/common"
)
// Params struct defines the parameters needed for running E2E tests to properly handle test sharding.
type Params struct {
TestPath string
LogPath string
TestShardIndex int
BeaconNodeCount int
Eth1RPCPort int
ContractAddress common.Address
BootNodePort int
BeaconNodeRPCPort int
BeaconNodeMetricsPort int
ValidatorMetricsPort int
ValidatorGatewayPort int
SlasherRPCPort int
SlasherMetricsPort int
}
// TestParams is the globally accessible var for getting config elements.
var TestParams *Params
// BootNodeLogFileName is the file name used for the beacon chain node logs.
var BootNodeLogFileName = "bootnode.log"
// BeaconNodeLogFileName is the file name used for the beacon chain node logs.
var BeaconNodeLogFileName = "beacon-%d.log"
// SlasherLogFileName is the file name used for the slasher client logs.
var SlasherLogFileName = "slasher-%d.log"
// ValidatorLogFileName is the file name used for the validator client logs.
var ValidatorLogFileName = "vals-%d.log"
// StandardBeaconCount is a global constant for the count of beacon nodes of standard E2E tests.
var StandardBeaconCount = 2
// DepositCount is the amount of deposits E2E makes on a separate validator client.
var DepositCount = uint64(64)
// Init initializes the E2E config, properly handling test sharding.
func Init(beaconNodeCount int) error {
testPath := bazel.TestTmpDir()
logPath, ok := os.LookupEnv("TEST_UNDECLARED_OUTPUTS_DIR")
if !ok {
return errors.New("expected TEST_UNDECLARED_OUTPUTS_DIR to be defined")
}
testIndexStr, ok := os.LookupEnv("TEST_SHARD_INDEX")
if !ok {
testIndexStr = "0"
}
testIndex, err := strconv.Atoi(testIndexStr)
if err != nil {
return err
}
TestParams = &Params{
TestPath: path.Join(testPath, fmt.Sprintf("shard-%d", testIndex)),
LogPath: logPath,
TestShardIndex: testIndex,
BeaconNodeCount: beaconNodeCount,
Eth1RPCPort: 3100 + testIndex*100, // Multiplying 100 here so the test index doesn't conflict with the other node ports.
BootNodePort: 4100 + testIndex*100,
BeaconNodeRPCPort: 4150 + testIndex*100,
BeaconNodeMetricsPort: 5100 + testIndex*100,
ValidatorMetricsPort: 6100 + testIndex*100,
ValidatorGatewayPort: 7150 + testIndex*100,
SlasherRPCPort: 7100 + testIndex*100,
SlasherMetricsPort: 8100 + testIndex*100,
}
return nil
}