@@ -127,6 +127,57 @@ func TestRunParamsWithDisableHeartbeatVerify(t *testing.T) {
127
127
assert .True (t , params .disableHeartbeatVerify )
128
128
}
129
129
130
+ func TestRunParamsWithProtectedPeers (t * testing.T ) {
131
+ priv , _ , err := p2pcrypto .GenerateKeyPair (p2pcrypto .Ed25519 , - 1 )
132
+ require .NoError (t , err )
133
+ gst := common .NewGuardianSetState (nil )
134
+ _ , rootCtxCancel := context .WithCancel (context .Background ())
135
+ defer rootCtxCancel ()
136
+
137
+ protectedPeers := []string {"peer1" , "peer2" , "peer3" }
138
+ params , err := NewRunParams (
139
+ bootstrapPeers ,
140
+ networkId ,
141
+ priv ,
142
+ gst ,
143
+ rootCtxCancel ,
144
+ WithProtectedPeers (protectedPeers ),
145
+ )
146
+
147
+ require .NoError (t , err )
148
+ require .NotNil (t , params )
149
+
150
+ require .Equal (t , len (protectedPeers ), len (params .protectedPeers ))
151
+ assert .Equal (t , protectedPeers [0 ], params .protectedPeers [0 ])
152
+ assert .Equal (t , protectedPeers [1 ], params .protectedPeers [1 ])
153
+ assert .Equal (t , protectedPeers [2 ], params .protectedPeers [2 ])
154
+ }
155
+
156
+ func TestRunParamsWithCcqProtectedPeers (t * testing.T ) {
157
+ priv , _ , err := p2pcrypto .GenerateKeyPair (p2pcrypto .Ed25519 , - 1 )
158
+ require .NoError (t , err )
159
+ gst := common .NewGuardianSetState (nil )
160
+ _ , rootCtxCancel := context .WithCancel (context .Background ())
161
+ defer rootCtxCancel ()
162
+
163
+ ccqProtectedPeers := []string {"peerA" , "peerB" }
164
+ params , err := NewRunParams (
165
+ bootstrapPeers ,
166
+ networkId ,
167
+ priv ,
168
+ gst ,
169
+ rootCtxCancel ,
170
+ WithCcqProtectedPeers (ccqProtectedPeers ),
171
+ )
172
+
173
+ require .NoError (t , err )
174
+ require .NotNil (t , params )
175
+
176
+ require .Equal (t , len (ccqProtectedPeers ), len (params .ccqProtectedPeers ))
177
+ assert .Equal (t , ccqProtectedPeers [0 ], params .ccqProtectedPeers [0 ])
178
+ assert .Equal (t , ccqProtectedPeers [1 ], params .ccqProtectedPeers [1 ])
179
+ }
180
+
130
181
func TestRunParamsWithGuardianOptions (t * testing.T ) {
131
182
priv , _ , err := p2pcrypto .GenerateKeyPair (p2pcrypto .Ed25519 , - 1 )
132
183
require .NoError (t , err )
@@ -159,6 +210,8 @@ func TestRunParamsWithGuardianOptions(t *testing.T) {
159
210
ccqBootstrapPeers := "some bootstrap string"
160
211
ccqPort := uint (4242 )
161
212
ccqAllowedPeers := "some allowed peers"
213
+ protectedPeers := []string {"peer1" , "peer2" , "peer3" }
214
+ ccqProtectedPeers := []string {"peerA" , "peerB" }
162
215
163
216
params , err := NewRunParams (
164
217
bootstrapPeers ,
@@ -187,7 +240,10 @@ func TestRunParamsWithGuardianOptions(t *testing.T) {
187
240
queryResponseReadC ,
188
241
ccqBootstrapPeers ,
189
242
ccqPort ,
190
- ccqAllowedPeers ),
243
+ ccqAllowedPeers ,
244
+ protectedPeers ,
245
+ ccqProtectedPeers ,
246
+ ),
191
247
)
192
248
193
249
require .NoError (t , err )
@@ -210,4 +266,13 @@ func TestRunParamsWithGuardianOptions(t *testing.T) {
210
266
assert .Equal (t , ccqBootstrapPeers , params .ccqBootstrapPeers )
211
267
assert .Equal (t , ccqPort , params .ccqPort )
212
268
assert .Equal (t , ccqAllowedPeers , params .ccqAllowedPeers )
269
+
270
+ require .Equal (t , len (protectedPeers ), len (params .protectedPeers ))
271
+ assert .Equal (t , protectedPeers [0 ], params .protectedPeers [0 ])
272
+ assert .Equal (t , protectedPeers [1 ], params .protectedPeers [1 ])
273
+ assert .Equal (t , protectedPeers [2 ], params .protectedPeers [2 ])
274
+
275
+ require .Equal (t , len (ccqProtectedPeers ), len (params .ccqProtectedPeers ))
276
+ assert .Equal (t , ccqProtectedPeers [0 ], params .ccqProtectedPeers [0 ])
277
+ assert .Equal (t , ccqProtectedPeers [1 ], params .ccqProtectedPeers [1 ])
213
278
}
0 commit comments