-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsyncer_test.go
60 lines (49 loc) · 1.53 KB
/
syncer_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
package e2e
import (
"context"
"fmt"
"testing"
"time"
"github.com/Mind-chain/mind/e2e/framework"
"github.com/Mind-chain/mind/validators"
)
func TestClusterBlockSync(t *testing.T) {
const (
numNonValidators = 2
desiredHeight = 10
)
runTest := func(t *testing.T, validatorType validators.ValidatorType) {
t.Helper()
// Start NLG-IBFT cluster (4 Validator + 2 Non-Validator)
ibftManager := framework.NewIBFTServersManager(
t,
IBFTMinNodes+numNonValidators,
IBFTDirPrefix, func(i int, config *framework.TestServerConfig) {
config.SetValidatorType(validatorType)
if i >= IBFTMinNodes {
// Other nodes should not be in the validator set
dirPrefix := "polygon-edge-non-validator-"
config.SetIBFTDirPrefix(dirPrefix)
config.SetIBFTDir(fmt.Sprintf("%s%d", dirPrefix, i))
}
})
startContext, startCancelFn := context.WithTimeout(context.Background(), time.Minute)
defer startCancelFn()
ibftManager.StartServers(startContext)
servers := make([]*framework.TestServer, 0)
for i := 0; i < IBFTMinNodes+numNonValidators; i++ {
servers = append(servers, ibftManager.GetServer(i))
}
// All nodes should have mined the same block eventually
waitErrors := framework.WaitForServersToSeal(servers, desiredHeight)
if len(waitErrors) != 0 {
t.Fatalf("Unable to wait for all nodes to seal blocks, %v", waitErrors)
}
}
t.Run("ECDSA", func(t *testing.T) {
runTest(t, validators.ECDSAValidatorType)
})
t.Run("BLS", func(t *testing.T) {
runTest(t, validators.BLSValidatorType)
})
}