|
17 | 17 | package validator |
18 | 18 |
|
19 | 19 | import ( |
| 20 | + "fmt" |
20 | 21 | "reflect" |
21 | 22 | "strings" |
22 | 23 | "testing" |
@@ -136,39 +137,39 @@ func testEmptyValSet(t *testing.T) { |
136 | 137 |
|
137 | 138 | func testAddAndRemoveValidator(t *testing.T) { |
138 | 139 | valSet := NewSet(ExtractValidators([]byte{}), istanbul.RoundRobin) |
139 | | - if !valSet.AddValidator(common.StringToAddress(string(2))) { |
| 140 | + if !valSet.AddValidator(common.StringToAddress(fmt.Sprint("2"))) { |
140 | 141 | t.Error("the validator should be added") |
141 | 142 | } |
142 | | - if valSet.AddValidator(common.StringToAddress(string(2))) { |
| 143 | + if valSet.AddValidator(common.StringToAddress(fmt.Sprint("2"))) { |
143 | 144 | t.Error("the existing validator should not be added") |
144 | 145 | } |
145 | | - valSet.AddValidator(common.StringToAddress(string(1))) |
146 | | - valSet.AddValidator(common.StringToAddress(string(0))) |
| 146 | + valSet.AddValidator(common.StringToAddress(fmt.Sprint("1"))) |
| 147 | + valSet.AddValidator(common.StringToAddress(fmt.Sprint("0"))) |
147 | 148 | if len(valSet.List()) != 3 { |
148 | 149 | t.Error("the size of validator set should be 3") |
149 | 150 | } |
150 | 151 |
|
151 | 152 | for i, v := range valSet.List() { |
152 | | - expected := common.StringToAddress(string(i)) |
| 153 | + expected := common.StringToAddress((fmt.Sprint(i))) |
153 | 154 | if v.Address() != expected { |
154 | 155 | t.Errorf("the order of validators is wrong: have %v, want %v", v.Address().Hex(), expected.Hex()) |
155 | 156 | } |
156 | 157 | } |
157 | 158 |
|
158 | | - if !valSet.RemoveValidator(common.StringToAddress(string(2))) { |
| 159 | + if !valSet.RemoveValidator(common.StringToAddress(fmt.Sprint("2"))) { |
159 | 160 | t.Error("the validator should be removed") |
160 | 161 | } |
161 | | - if valSet.RemoveValidator(common.StringToAddress(string(2))) { |
| 162 | + if valSet.RemoveValidator(common.StringToAddress(fmt.Sprint("2"))) { |
162 | 163 | t.Error("the non-existing validator should not be removed") |
163 | 164 | } |
164 | 165 | if len(valSet.List()) != 2 { |
165 | 166 | t.Error("the size of validator set should be 2") |
166 | 167 | } |
167 | | - valSet.RemoveValidator(common.StringToAddress(string(1))) |
| 168 | + valSet.RemoveValidator(common.StringToAddress(fmt.Sprint("1"))) |
168 | 169 | if len(valSet.List()) != 1 { |
169 | 170 | t.Error("the size of validator set should be 1") |
170 | 171 | } |
171 | | - valSet.RemoveValidator(common.StringToAddress(string(0))) |
| 172 | + valSet.RemoveValidator(common.StringToAddress(fmt.Sprint("0"))) |
172 | 173 | if len(valSet.List()) != 0 { |
173 | 174 | t.Error("the size of validator set should be 0") |
174 | 175 | } |
|
0 commit comments