github.com/prysmaticlabs/prysm@v1.4.4/endtoend/params/params.go (about) 1 // Package params defines all custom parameter configurations 2 // for running end to end tests. 3 package params 4 5 import ( 6 "errors" 7 "fmt" 8 "os" 9 "path/filepath" 10 "strconv" 11 12 "github.com/bazelbuild/rules_go/go/tools/bazel" 13 "github.com/ethereum/go-ethereum/common" 14 ) 15 16 // params struct defines the parameters needed for running E2E tests to properly handle test sharding. 17 type params struct { 18 TestPath string 19 LogPath string 20 TestShardIndex int 21 BeaconNodeCount int 22 Eth1RPCPort int 23 ContractAddress common.Address 24 BootNodePort int 25 BeaconNodeRPCPort int 26 BeaconNodeMetricsPort int 27 ValidatorMetricsPort int 28 ValidatorGatewayPort int 29 SlasherRPCPort int 30 SlasherMetricsPort int 31 } 32 33 // TestParams is the globally accessible var for getting config elements. 34 var TestParams *params 35 36 // BootNodeLogFileName is the file name used for the beacon chain node logs. 37 var BootNodeLogFileName = "bootnode.log" 38 39 // BeaconNodeLogFileName is the file name used for the beacon chain node logs. 40 var BeaconNodeLogFileName = "beacon-%d.log" 41 42 // SlasherLogFileName is the file name used for the slasher client logs. 43 var SlasherLogFileName = "slasher-%d.log" 44 45 // ValidatorLogFileName is the file name used for the validator client logs. 46 var ValidatorLogFileName = "vals-%d.log" 47 48 // StandardBeaconCount is a global constant for the count of beacon nodes of standard E2E tests. 49 var StandardBeaconCount = 2 50 51 // DepositCount is the amount of deposits E2E makes on a separate validator client. 52 var DepositCount = uint64(64) 53 54 // Init initializes the E2E config, properly handling test sharding. 55 func Init(beaconNodeCount int) error { 56 testPath := bazel.TestTmpDir() 57 logPath, ok := os.LookupEnv("TEST_UNDECLARED_OUTPUTS_DIR") 58 if !ok { 59 return errors.New("expected TEST_UNDECLARED_OUTPUTS_DIR to be defined") 60 } 61 testIndexStr, ok := os.LookupEnv("TEST_SHARD_INDEX") 62 if !ok { 63 testIndexStr = "0" 64 } 65 testIndex, err := strconv.Atoi(testIndexStr) 66 if err != nil { 67 return err 68 } 69 testPath = filepath.Join(testPath, fmt.Sprintf("shard-%d", testIndex)) 70 71 TestParams = ¶ms{ 72 TestPath: testPath, 73 LogPath: logPath, 74 TestShardIndex: testIndex, 75 BeaconNodeCount: beaconNodeCount, 76 Eth1RPCPort: 3100 + testIndex*100, // Multiplying 100 here so the test index doesn't conflict with the other node ports. 77 BootNodePort: 4100 + testIndex*100, 78 BeaconNodeRPCPort: 4150 + testIndex*100, 79 BeaconNodeMetricsPort: 5100 + testIndex*100, 80 ValidatorMetricsPort: 6100 + testIndex*100, 81 ValidatorGatewayPort: 7150 + testIndex*100, 82 SlasherRPCPort: 7100 + testIndex*100, 83 SlasherMetricsPort: 8100 + testIndex*100, 84 } 85 return nil 86 }