@@ -24,15 +24,20 @@ import (
24
24
"github.com/stretchr/testify/assert"
25
25
)
26
26
27
+ var (
28
+ addr1 = common .HexToAddress ("0xc53f2189bf6d7bf56722731787127f90d319e112" )
29
+ addr2 = common .HexToAddress ("0xed2d479591fe2c5626ce09bca4ed2a62e00e5bc2" )
30
+ addr3 = common .HexToAddress ("0xc8417f834995aaeb35f342a67a4961e19cd4735c" )
31
+ addr4 = common .HexToAddress ("0x784ae51f5013b51c8360afdf91c6bc5a16f586ea" )
32
+ addr5 = common .HexToAddress ("0xecf0974e6f0630fd91ea4da8399cdb3f59e5220f" )
33
+ addr6 = common .HexToAddress ("0x411c4d11acd714b82a5242667e36de14b9e1d10b" )
34
+ addr7 = common .HexToAddress ("0x681381b3D0DaaC179d95aCc9e22E23da2DA670f6" )
35
+ addrSet = []common.Address {addr1 , addr2 , addr3 , addr4 , addr5 , addr6 }
36
+ addrSet2 = []common.Address {addr7 , addr1 , addr2 , addr3 , addr4 , addr5 }
37
+ )
38
+
27
39
func TestProposerPolicy (t * testing.T ) {
28
- addr1 := common .HexToAddress ("0xc53f2189bf6d7bf56722731787127f90d319e112" )
29
- addr2 := common .HexToAddress ("0xed2d479591fe2c5626ce09bca4ed2a62e00e5bc2" )
30
- addr3 := common .HexToAddress ("0xc8417f834995aaeb35f342a67a4961e19cd4735c" )
31
- addr4 := common .HexToAddress ("0x784ae51f5013b51c8360afdf91c6bc5a16f586ea" )
32
- addr5 := common .HexToAddress ("0xecf0974e6f0630fd91ea4da8399cdb3f59e5220f" )
33
- addr6 := common .HexToAddress ("0x411c4d11acd714b82a5242667e36de14b9e1d10b" )
34
-
35
- addrSet := []common.Address {addr1 , addr2 , addr3 , addr4 , addr5 , addr6 }
40
+
36
41
addressSortedByByte := []common.Address {addr6 , addr4 , addr1 , addr3 , addr5 , addr2 }
37
42
addressSortedByString := []common.Address {addr6 , addr4 , addr1 , addr2 , addr5 , addr3 }
38
43
@@ -51,3 +56,17 @@ func TestProposerPolicy(t *testing.T) {
51
56
assert .Equal (t , addressSortedByString [i ].Hex (), valList [i ].String (), "validatorSet not string sorted" )
52
57
}
53
58
}
59
+
60
+ func TestProposerPolicyRegistration (t * testing.T ) {
61
+ // test that registration can't go beyond MaxValidatorSetInRegistry limit
62
+ pp := istanbul .NewRoundRobinProposerPolicy ()
63
+ pp2 := istanbul .NewRoundRobinProposerPolicy ()
64
+ valSet := NewSet (addrSet , pp )
65
+ valSet2 := NewSet (addrSet2 , pp2 )
66
+
67
+ for i := 0 ; i < istanbul .MaxValidatorSetInRegistry + 100 ; i ++ {
68
+ pp .RegisterValidatorSet (valSet )
69
+ }
70
+ pp .RegisterValidatorSet (valSet2 )
71
+ assert .Equal (t , istanbul .MaxValidatorSetInRegistry , pp .GetRegistrySize (), "validator set not dropped" )
72
+ }
0 commit comments