Skip to content

Commit

Permalink
CR fix
Browse files Browse the repository at this point in the history
  • Loading branch information
jelacamarko committed Oct 5, 2023
1 parent c8a0cf9 commit c92c5f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
2 changes: 1 addition & 1 deletion e2e-polybft/e2e/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,6 @@ func TestE2E_Migration(t *testing.T) {
_, err = cluster.InitSecrets("test-chain-8", 1)
require.NoError(t, err)

cluster.InitTestServer(t, "test-chain-8", cluster.Bridge.JSONRPCAddr(), 0 /* no flags */)
cluster.InitTestServer(t, "test-chain-8", cluster.Bridge.JSONRPCAddr(), frameworkpolybft.None)
require.NoError(t, cluster.WaitForBlock(33, time.Minute))
}
29 changes: 18 additions & 11 deletions e2e-polybft/framework/test-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,20 @@ const (
nonValidatorPrefix = "test-non-validator-"
)

type NodeType int

const (
Validator = 1 << iota
Relayer
None NodeType = 0
Validator NodeType = 1 << iota
Relayer NodeType = 2
)

func HasFlag(flags int, flag int) bool {
return flags&flag == flag
func (nt NodeType) IsSet(value NodeType) bool {
return nt&value == value
}

func (nt *NodeType) Append(value NodeType) {
*nt |= value
}

var (
Expand Down Expand Up @@ -648,25 +655,25 @@ func NewTestCluster(t *testing.T, validatorsCount int, opts ...ClusterOption) *T
require.NoError(t, err)

for i := 1; i <= int(cluster.Config.ValidatorSetSize); i++ {
flags := Validator
nodeType := Validator
if i == 1 {
flags = flags | Relayer
nodeType.Append(Relayer)
}

dir := cluster.Config.ValidatorPrefix + strconv.Itoa(i)
cluster.InitTestServer(t, dir, cluster.Bridge.JSONRPCAddr(), flags)
cluster.InitTestServer(t, dir, cluster.Bridge.JSONRPCAddr(), nodeType)
}

for i := 1; i <= cluster.Config.NonValidatorCount; i++ {
dir := nonValidatorPrefix + strconv.Itoa(i)
cluster.InitTestServer(t, dir, cluster.Bridge.JSONRPCAddr(), 0 /* no flags */)
cluster.InitTestServer(t, dir, cluster.Bridge.JSONRPCAddr(), None)
}

return cluster
}

func (c *TestCluster) InitTestServer(t *testing.T,
dataDir string, bridgeJSONRPC string, flags int) {
dataDir string, bridgeJSONRPC string, nodeType NodeType) {
t.Helper()

logLevel := os.Getenv(envLogLevel)
Expand All @@ -681,11 +688,11 @@ func (c *TestCluster) InitTestServer(t *testing.T,

srv := NewTestServer(t, c.Config, bridgeJSONRPC, func(config *TestServerConfig) {
config.DataDir = dataDir
config.Seal = HasFlag(flags, Validator)
config.Seal = nodeType.IsSet(Validator)
config.Chain = c.Config.Dir("genesis.json")
config.P2PPort = c.getOpenPort()
config.LogLevel = logLevel
config.Relayer = HasFlag(flags, Relayer)
config.Relayer = nodeType.IsSet(Relayer)
config.NumBlockConfirmations = c.Config.NumBlockConfirmations
config.BridgeJSONRPC = bridgeJSONRPC
config.RelayerTrackerPollInterval = c.Config.RelayerTrackerPollInterval
Expand Down

0 comments on commit c92c5f8

Please sign in to comment.