@@ -134,14 +134,9 @@ func TestDifferentChainID(t *testing.T) {
134
134
135
135
newConfig := makeConfigUpdateEnvelope ("wrongChain" , makeConfigPair ("foo" , "foo" , 1 , []byte ("foo" )))
136
136
137
- err = cm .Validate (newConfig )
137
+ _ , err = cm .ProposeConfigUpdate (newConfig )
138
138
if err == nil {
139
- t .Error ("Should have errored when validating a new config set the wrong chain ID" )
140
- }
141
-
142
- err = cm .Apply (newConfig )
143
- if err == nil {
144
- t .Error ("Should have errored when applying a new config with the wrong chain ID" )
139
+ t .Error ("Should have errored when proposing a new config set the wrong chain ID" )
145
140
}
146
141
}
147
142
@@ -157,14 +152,9 @@ func TestOldConfigReplay(t *testing.T) {
157
152
158
153
newConfig := makeConfigUpdateEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 0 , []byte ("foo" )))
159
154
160
- err = cm .Validate (newConfig )
155
+ _ , err = cm .ProposeConfigUpdate (newConfig )
161
156
if err == nil {
162
- t .Error ("Should have errored when validating a config that is not a newer sequence number" )
163
- }
164
-
165
- err = cm .Apply (newConfig )
166
- if err == nil {
167
- t .Error ("Should have errored when applying a config that is not a newer sequence number" )
157
+ t .Error ("Should have errored when proposing a config that is not a newer sequence number" )
168
158
}
169
159
}
170
160
@@ -180,12 +170,17 @@ func TestValidConfigChange(t *testing.T) {
180
170
181
171
newConfig := makeConfigUpdateEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 1 , []byte ("foo" )))
182
172
183
- err = cm .Validate (newConfig )
173
+ configEnv , err := cm .ProposeConfigUpdate (newConfig )
174
+ if err != nil {
175
+ t .Errorf ("Should not have errored proposing config: %s" , err )
176
+ }
177
+
178
+ err = cm .Validate (configEnv )
184
179
if err != nil {
185
180
t .Errorf ("Should not have errored validating config: %s" , err )
186
181
}
187
182
188
- err = cm .Apply (newConfig )
183
+ err = cm .Apply (configEnv )
189
184
if err != nil {
190
185
t .Errorf ("Should not have errored applying config: %s" , err )
191
186
}
@@ -208,14 +203,9 @@ func TestConfigChangeRegressedSequence(t *testing.T) {
208
203
makeConfigPair ("bar" , "bar" , 2 , []byte ("bar" )),
209
204
)
210
205
211
- err = cm .Validate (newConfig )
206
+ _ , err = cm .ProposeConfigUpdate (newConfig )
212
207
if err == nil {
213
- t .Error ("Should have errored validating config because foo's sequence number regressed" )
214
- }
215
-
216
- err = cm .Apply (newConfig )
217
- if err == nil {
218
- t .Error ("Should have errored applying config because foo's sequence number regressed" )
208
+ t .Error ("Should have errored proposing config because foo's sequence number regressed" )
219
209
}
220
210
}
221
211
@@ -236,14 +226,9 @@ func TestConfigChangeOldSequence(t *testing.T) {
236
226
makeConfigPair ("bar" , "bar" , 1 , []byte ("bar" )),
237
227
)
238
228
239
- err = cm .Validate (newConfig )
240
- if err == nil {
241
- t .Error ("Should have errored validating config because bar was new but its sequence number was old" )
242
- }
243
-
244
- err = cm .Apply (newConfig )
229
+ _ , err = cm .ProposeConfigUpdate (newConfig )
245
230
if err == nil {
246
- t .Error ("Should have errored applying config because bar was new but its sequence number was old" )
231
+ t .Error ("Should have errored proposing config because bar was new but its sequence number was old" )
247
232
}
248
233
}
249
234
@@ -267,14 +252,9 @@ func TestConfigImplicitDelete(t *testing.T) {
267
252
makeConfigPair ("bar" , "bar" , 1 , []byte ("bar" )),
268
253
)
269
254
270
- err = cm .Validate (newConfig )
255
+ _ , err = cm .ProposeConfigUpdate (newConfig )
271
256
if err == nil {
272
- t .Error ("Should have errored validating config because foo was implicitly deleted" )
273
- }
274
-
275
- err = cm .Apply (newConfig )
276
- if err == nil {
277
- t .Error ("Should have errored applying config because foo was implicitly deleted" )
257
+ t .Error ("Should have errored proposing config because foo was implicitly deleted" )
278
258
}
279
259
}
280
260
@@ -290,14 +270,9 @@ func TestEmptyConfigUpdate(t *testing.T) {
290
270
291
271
newConfig := & cb.Envelope {}
292
272
293
- err = cm .Validate (newConfig )
294
- if err == nil {
295
- t .Error ("Should not errored validating config because new config is empty" )
296
- }
297
-
298
- err = cm .Apply (newConfig )
273
+ _ , err = cm .ProposeConfigUpdate (newConfig )
299
274
if err == nil {
300
- t .Error ("Should not errored applying config because new config is empty" )
275
+ t .Error ("Should not errored proposing config because new config is empty" )
301
276
}
302
277
}
303
278
@@ -323,14 +298,9 @@ func TestSilentConfigModification(t *testing.T) {
323
298
makeConfigPair ("bar" , "bar" , 1 , []byte ("bar" )),
324
299
)
325
300
326
- err = cm .Validate (newConfig )
301
+ _ , err = cm .ProposeConfigUpdate (newConfig )
327
302
if err == nil {
328
- t .Error ("Should not errored validating config because foo was silently modified (despite modification allowed by policy)" )
329
- }
330
-
331
- err = cm .Apply (newConfig )
332
- if err == nil {
333
- t .Error ("Should not errored applying config because foo was silently modified (despite modification allowed by policy)" )
303
+ t .Error ("Should have errored proposing config because foo was silently modified (despite modification allowed by policy)" )
334
304
}
335
305
}
336
306
@@ -350,14 +320,9 @@ func TestConfigChangeViolatesPolicy(t *testing.T) {
350
320
351
321
newConfig := makeConfigUpdateEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 1 , []byte ("foo" )))
352
322
353
- err = cm .Validate (newConfig )
354
- if err == nil {
355
- t .Error ("Should have errored validating config because policy rejected modification" )
356
- }
357
-
358
- err = cm .Apply (newConfig )
323
+ _ , err = cm .ProposeConfigUpdate (newConfig )
359
324
if err == nil {
360
- t .Error ("Should have errored applying config because policy rejected modification" )
325
+ t .Error ("Should have errored proposing config because policy rejected modification" )
361
326
}
362
327
}
363
328
@@ -383,12 +348,17 @@ func TestUnchangedConfigViolatesPolicy(t *testing.T) {
383
348
makeConfigPair ("bar" , "bar" , 1 , []byte ("foo" )),
384
349
)
385
350
386
- err = cm .Validate (newConfig )
351
+ configEnv , err := cm .ProposeConfigUpdate (newConfig )
352
+ if err != nil {
353
+ t .Errorf ("Should not have errored proposing config, but got %s" , err )
354
+ }
355
+
356
+ err = cm .Validate (configEnv )
387
357
if err != nil {
388
358
t .Errorf ("Should not have errored validating config, but got %s" , err )
389
359
}
390
360
391
- err = cm .Apply (newConfig )
361
+ err = cm .Apply (configEnv )
392
362
if err != nil {
393
363
t .Errorf ("Should not have errored applying config, but got %s" , err )
394
364
}
@@ -410,14 +380,9 @@ func TestInvalidProposal(t *testing.T) {
410
380
411
381
newConfig := makeConfigUpdateEnvelope (defaultChain , makeConfigPair ("foo" , "foo" , 1 , []byte ("foo" )))
412
382
413
- err = cm .Validate (newConfig )
414
- if err == nil {
415
- t .Error ("Should have errored validating config because the handler rejected it" )
416
- }
417
-
418
- err = cm .Apply (newConfig )
383
+ _ , err = cm .ProposeConfigUpdate (newConfig )
419
384
if err == nil {
420
- t .Error ("Should have errored applying config because the handler rejected it" )
385
+ t .Error ("Should have errored proposing config because the handler rejected it" )
421
386
}
422
387
}
423
388
0 commit comments