@@ -24,6 +24,7 @@ import (
24
24
cb "github.com/hyperledger/fabric/protos/common"
25
25
26
26
"github.com/golang/protobuf/proto"
27
+ "errors"
27
28
)
28
29
29
30
var defaultChain = "DefaultChainID"
@@ -43,7 +44,7 @@ type mockPolicy struct {
43
44
44
45
func (mp * mockPolicy ) Evaluate (headers [][]byte , payload []byte , identities [][]byte , signatures [][]byte ) error {
45
46
if mp == nil {
46
- return fmt . Errorf ("Invoked nil policy" )
47
+ return errors . New ("Invoked nil policy" )
47
48
}
48
49
return mp .policyResult
49
50
}
@@ -85,7 +86,7 @@ func TestOmittedHandler(t *testing.T) {
85
86
}, & mockPolicyManager {& mockPolicy {}}, map [cb.ConfigurationItem_ConfigurationType ]Handler {})
86
87
87
88
if err == nil {
88
- t .Fatalf ("Should have failed to construct manager because handlers were missing" )
89
+ t .Fatal ("Should have failed to construct manager because handlers were missing" )
89
90
}
90
91
}
91
92
@@ -105,12 +106,12 @@ func TestWrongChainID(t *testing.T) {
105
106
106
107
err = cm .Validate (newConfig )
107
108
if err == nil {
108
- t .Errorf ("Should have errored when validating a new configuration set the wrong chain ID" )
109
+ t .Error ("Should have errored when validating a new configuration set the wrong chain ID" )
109
110
}
110
111
111
112
err = cm .Apply (newConfig )
112
113
if err == nil {
113
- t .Errorf ("Should have errored when applying a new configuration with the wrong chain ID" )
114
+ t .Error ("Should have errored when applying a new configuration with the wrong chain ID" )
114
115
}
115
116
}
116
117
@@ -130,12 +131,12 @@ func TestOldConfigReplay(t *testing.T) {
130
131
131
132
err = cm .Validate (newConfig )
132
133
if err == nil {
133
- t .Errorf ("Should have errored when validating a configuration that is not a newer sequence number" )
134
+ t .Error ("Should have errored when validating a configuration that is not a newer sequence number" )
134
135
}
135
136
136
137
err = cm .Apply (newConfig )
137
138
if err == nil {
138
- t .Errorf ("Should have errored when applying a configuration that is not a newer sequence number" )
139
+ t .Error ("Should have errored when applying a configuration that is not a newer sequence number" )
139
140
}
140
141
}
141
142
@@ -148,7 +149,7 @@ func TestInvalidInitialConfigByStructure(t *testing.T) {
148
149
}, & mockPolicyManager {& mockPolicy {}}, defaultHandlers ())
149
150
150
151
if err == nil {
151
- t .Fatalf ("Should have failed to construct configuration by policy" )
152
+ t .Fatal ("Should have failed to construct configuration by policy" )
152
153
}
153
154
}
154
155
@@ -197,12 +198,12 @@ func TestConfigChangeRegressedSequence(t *testing.T) {
197
198
198
199
err = cm .Validate (newConfig )
199
200
if err == nil {
200
- t .Errorf ("Should have errored validating config because foo's sequence number regressed" )
201
+ t .Error ("Should have errored validating config because foo's sequence number regressed" )
201
202
}
202
203
203
204
err = cm .Apply (newConfig )
204
205
if err == nil {
205
- t .Errorf ("Should have errored applying config because foo's sequence number regressed" )
206
+ t .Error ("Should have errored applying config because foo's sequence number regressed" )
206
207
}
207
208
}
208
209
@@ -226,12 +227,12 @@ func TestConfigChangeOldSequence(t *testing.T) {
226
227
227
228
err = cm .Validate (newConfig )
228
229
if err == nil {
229
- t .Errorf ("Should have errored validating config because bar was new but its sequence number was old" )
230
+ t .Error ("Should have errored validating config because bar was new but its sequence number was old" )
230
231
}
231
232
232
233
err = cm .Apply (newConfig )
233
234
if err == nil {
234
- t .Errorf ("Should have errored applying config because bar was new but its sequence number was old" )
235
+ t .Error ("Should have errored applying config because bar was new but its sequence number was old" )
235
236
}
236
237
}
237
238
@@ -257,12 +258,12 @@ func TestConfigImplicitDelete(t *testing.T) {
257
258
258
259
err = cm .Validate (newConfig )
259
260
if err == nil {
260
- t .Errorf ("Should have errored validating config because foo was implicitly deleted" )
261
+ t .Error ("Should have errored validating config because foo was implicitly deleted" )
261
262
}
262
263
263
264
err = cm .Apply (newConfig )
264
265
if err == nil {
265
- t .Errorf ("Should have errored applying config because foo was implicitly deleted" )
266
+ t .Error ("Should have errored applying config because foo was implicitly deleted" )
266
267
}
267
268
}
268
269
@@ -280,12 +281,12 @@ func TestEmptyConfigUpdate(t *testing.T) {
280
281
281
282
err = cm .Validate (newConfig )
282
283
if err == nil {
283
- t .Errorf ("Should not errored validating config because new config is empty" )
284
+ t .Error ("Should not errored validating config because new config is empty" )
284
285
}
285
286
286
287
err = cm .Apply (newConfig )
287
288
if err == nil {
288
- t .Errorf ("Should not errored applying config because new config is empty" )
289
+ t .Error ("Should not errored applying config because new config is empty" )
289
290
}
290
291
}
291
292
@@ -313,12 +314,12 @@ func TestSilentConfigModification(t *testing.T) {
313
314
314
315
err = cm .Validate (newConfig )
315
316
if err == nil {
316
- t .Errorf ("Should not errored validating config because foo was silently modified (despite modification allowed by policy)" )
317
+ t .Error ("Should not errored validating config because foo was silently modified (despite modification allowed by policy)" )
317
318
}
318
319
319
320
err = cm .Apply (newConfig )
320
321
if err == nil {
321
- t .Errorf ("Should not errored applying config because foo was silently modified (despite modification allowed by policy)" )
322
+ t .Error ("Should not errored applying config because foo was silently modified (despite modification allowed by policy)" )
322
323
}
323
324
}
324
325
@@ -331,7 +332,7 @@ func TestInvalidInitialConfigByPolicy(t *testing.T) {
331
332
// mockPolicyManager will return non-validating defualt policy
332
333
333
334
if err == nil {
334
- t .Fatalf ("Should have failed to construct configuration by policy" )
335
+ t .Fatal ("Should have failed to construct configuration by policy" )
335
336
}
336
337
}
337
338
@@ -355,12 +356,12 @@ func TestConfigChangeViolatesPolicy(t *testing.T) {
355
356
356
357
err = cm .Validate (newConfig )
357
358
if err == nil {
358
- t .Errorf ("Should have errored validating config because policy rejected modification" )
359
+ t .Error ("Should have errored validating config because policy rejected modification" )
359
360
}
360
361
361
362
err = cm .Apply (newConfig )
362
363
if err == nil {
363
- t .Errorf ("Should have errored applying config because policy rejected modification" )
364
+ t .Error ("Should have errored applying config because policy rejected modification" )
364
365
}
365
366
}
366
367
@@ -370,7 +371,7 @@ func (fh failHandler) BeginConfig() {}
370
371
func (fh failHandler ) RollbackConfig () {}
371
372
func (fh failHandler ) CommitConfig () {}
372
373
func (fh failHandler ) ProposeConfig (item * cb.ConfigurationItem ) error {
373
- return fmt . Errorf ("Fail" )
374
+ return errors . New ("Fail" )
374
375
}
375
376
376
377
// TestInvalidProposal checks that even if the policy allows the transaction and the sequence etc. is well formed,
@@ -393,12 +394,12 @@ func TestInvalidProposal(t *testing.T) {
393
394
394
395
err = cm .Validate (newConfig )
395
396
if err == nil {
396
- t .Errorf ("Should have errored validating config because the handler rejected it" )
397
+ t .Error ("Should have errored validating config because the handler rejected it" )
397
398
}
398
399
399
400
err = cm .Apply (newConfig )
400
401
if err == nil {
401
- t .Errorf ("Should have errored applying config because the handler rejected it" )
402
+ t .Error ("Should have errored applying config because the handler rejected it" )
402
403
}
403
404
}
404
405
@@ -413,7 +414,7 @@ func TestMissingHeader(t *testing.T) {
413
414
}, & mockPolicyManager {& mockPolicy {}}, handlers )
414
415
415
416
if err == nil {
416
- t .Errorf ("Should have errored creating the configuration manager because of the missing header" )
417
+ t .Error ("Should have errored creating the configuration manager because of the missing header" )
417
418
}
418
419
}
419
420
@@ -425,7 +426,7 @@ func TestMissingChainID(t *testing.T) {
425
426
}, & mockPolicyManager {& mockPolicy {}}, handlers )
426
427
427
428
if err == nil {
428
- t .Errorf ("Should have errored creating the configuration manager because of the missing header" )
429
+ t .Error ("Should have errored creating the configuration manager because of the missing header" )
429
430
}
430
431
}
431
432
@@ -440,6 +441,6 @@ func TestMismatchedChainID(t *testing.T) {
440
441
}, & mockPolicyManager {& mockPolicy {}}, handlers )
441
442
442
443
if err == nil {
443
- t .Errorf ("Should have errored creating the configuration manager because of the missing header" )
444
+ t .Error ("Should have errored creating the configuration manager because of the missing header" )
444
445
}
445
446
}
0 commit comments