@@ -67,8 +67,10 @@ func TestEndorserNilProp(t *testing.T) {
67
67
GetTxSimulatorRv : & ccprovider.MockTxSim {& ledger.TxSimulationResults {PubSimulationResults : & rwset.TxReadWriteSet {}}},
68
68
})
69
69
70
- _ , err := es .ProcessProposal (context .Background (), nil )
70
+ pResp , err := es .ProcessProposal (context .Background (), nil )
71
71
assert .Error (t , err )
72
+ assert .EqualValues (t , 500 , pResp .Response .Status )
73
+ assert .Equal (t , "nil arguments" , pResp .Response .Message )
72
74
}
73
75
74
76
func TestEndorserUninvokableSysCC (t * testing.T ) {
@@ -83,8 +85,10 @@ func TestEndorserUninvokableSysCC(t *testing.T) {
83
85
84
86
signedProp := getSignedProp ("ccid" , "0" , t )
85
87
86
- _ , err := es .ProcessProposal (context .Background (), signedProp )
88
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
87
89
assert .Error (t , err )
90
+ assert .EqualValues (t , 500 , pResp .Response .Status )
91
+ assert .Equal (t , "chaincode ccid cannot be invoked through a proposal" , pResp .Response .Message )
88
92
}
89
93
90
94
func TestEndorserCCInvocationFailed (t * testing.T ) {
@@ -95,14 +99,16 @@ func TestEndorserCCInvocationFailed(t *testing.T) {
95
99
GetApplicationConfigRv : & mc.MockApplication {CapabilitiesRv : & mc.MockApplicationCapabilities {}},
96
100
GetTransactionByIDErr : errors .New ("" ),
97
101
ChaincodeDefinitionRv : & resourceconfig.MockChaincodeDefinition {EndorsementStr : "ESCC" },
98
- ExecuteResp : & pb.Response {Status : 1000 , Payload : utils .MarshalOrPanic (& pb.ProposalResponse {Response : & pb.Response {}})},
102
+ ExecuteResp : & pb.Response {Status : 1000 , Payload : utils .MarshalOrPanic (& pb.ProposalResponse {Response : & pb.Response {}}), Message : "Chaincode Error" },
99
103
GetTxSimulatorRv : & ccprovider.MockTxSim {& ledger.TxSimulationResults {PubSimulationResults : & rwset.TxReadWriteSet {}}},
100
104
})
101
105
102
106
signedProp := getSignedProp ("ccid" , "0" , t )
103
107
104
- _ , err := es .ProcessProposal (context .Background (), signedProp )
105
- assert .Error (t , err )
108
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
109
+ assert .NoError (t , err )
110
+ assert .EqualValues (t , 1000 , pResp .Response .Status )
111
+ assert .Regexp (t , "Chaincode Error" , pResp .Response .Message )
106
112
}
107
113
108
114
func TestEndorserNoCCDef (t * testing.T ) {
@@ -119,8 +125,10 @@ func TestEndorserNoCCDef(t *testing.T) {
119
125
120
126
signedProp := getSignedProp ("ccid" , "0" , t )
121
127
122
- _ , err := es .ProcessProposal (context .Background (), signedProp )
123
- assert .Error (t , err )
128
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
129
+ assert .NoError (t , err )
130
+ assert .EqualValues (t , 500 , pResp .Response .Status )
131
+ assert .Regexp (t , "make sure the chaincode" , pResp .Response .Message )
124
132
}
125
133
126
134
func TestEndorserBadInstPolicy (t * testing.T ) {
@@ -138,8 +146,9 @@ func TestEndorserBadInstPolicy(t *testing.T) {
138
146
139
147
signedProp := getSignedProp ("ccid" , "0" , t )
140
148
141
- _ , err := es .ProcessProposal (context .Background (), signedProp )
142
- assert .Error (t , err )
149
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
150
+ assert .NoError (t , err )
151
+ assert .EqualValues (t , 500 , pResp .Response .Status )
143
152
}
144
153
145
154
func TestEndorserSysCC (t * testing.T ) {
@@ -157,8 +166,9 @@ func TestEndorserSysCC(t *testing.T) {
157
166
158
167
signedProp := getSignedProp ("ccid" , "0" , t )
159
168
160
- _ , err := es .ProcessProposal (context .Background (), signedProp )
169
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
161
170
assert .NoError (t , err )
171
+ assert .EqualValues (t , 200 , pResp .Response .Status )
162
172
}
163
173
164
174
func TestEndorserCCInvocationError (t * testing.T ) {
@@ -175,8 +185,9 @@ func TestEndorserCCInvocationError(t *testing.T) {
175
185
176
186
signedProp := getSignedProp ("ccid" , "0" , t )
177
187
178
- _ , err := es .ProcessProposal (context .Background (), signedProp )
179
- assert .Error (t , err )
188
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
189
+ assert .NoError (t , err )
190
+ assert .EqualValues (t , 500 , pResp .Response .Status )
180
191
}
181
192
182
193
func TestEndorserLSCCBadType (t * testing.T ) {
@@ -201,8 +212,10 @@ func TestEndorserLSCCBadType(t *testing.T) {
201
212
)
202
213
signedProp := getSignedPropWithCHIdAndArgs (util .GetTestChainID (), "lscc" , "0" , [][]byte {[]byte ("deploy" ), []byte ("a" ), cds }, t )
203
214
204
- _ , err := es .ProcessProposal (context .Background (), signedProp )
205
- assert .Error (t , err )
215
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
216
+ assert .NoError (t , err )
217
+ assert .EqualValues (t , 500 , pResp .Response .Status )
218
+ assert .Equal (t , "Unknown chaincodeType: UNDEFINED" , pResp .Response .Message )
206
219
}
207
220
208
221
func TestEndorserDupTXId (t * testing.T ) {
@@ -218,8 +231,10 @@ func TestEndorserDupTXId(t *testing.T) {
218
231
219
232
signedProp := getSignedProp ("ccid" , "0" , t )
220
233
221
- _ , err := es .ProcessProposal (context .Background (), signedProp )
234
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
222
235
assert .Error (t , err )
236
+ assert .EqualValues (t , 500 , pResp .Response .Status )
237
+ assert .Regexp (t , "duplicate transaction found" , pResp .Response .Message )
223
238
}
224
239
225
240
func TestEndorserBadACL (t * testing.T ) {
@@ -237,8 +252,9 @@ func TestEndorserBadACL(t *testing.T) {
237
252
238
253
signedProp := getSignedProp ("ccid" , "0" , t )
239
254
240
- _ , err := es .ProcessProposal (context .Background (), signedProp )
255
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
241
256
assert .Error (t , err )
257
+ assert .EqualValues (t , 500 , pResp .Response .Status )
242
258
}
243
259
244
260
func TestEndorserGoodPathEmptyChannel (t * testing.T ) {
@@ -255,8 +271,9 @@ func TestEndorserGoodPathEmptyChannel(t *testing.T) {
255
271
256
272
signedProp := getSignedPropWithCHIdAndArgs ("" , "ccid" , "0" , [][]byte {[]byte ("args" )}, t )
257
273
258
- _ , err := es .ProcessProposal (context .Background (), signedProp )
274
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
259
275
assert .NoError (t , err )
276
+ assert .EqualValues (t , 200 , pResp .Response .Status )
260
277
}
261
278
262
279
func TestEndorserLSCCInitFails (t * testing.T ) {
@@ -282,8 +299,9 @@ func TestEndorserLSCCInitFails(t *testing.T) {
282
299
)
283
300
signedProp := getSignedPropWithCHIdAndArgs (util .GetTestChainID (), "lscc" , "0" , [][]byte {[]byte ("deploy" ), []byte ("a" ), cds }, t )
284
301
285
- _ , err := es .ProcessProposal (context .Background (), signedProp )
286
- assert .Error (t , err )
302
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
303
+ assert .NoError (t , err )
304
+ assert .EqualValues (t , 500 , pResp .Response .Status )
287
305
}
288
306
289
307
func TestEndorserLSCCDeploySysCC (t * testing.T ) {
@@ -312,8 +330,10 @@ func TestEndorserLSCCDeploySysCC(t *testing.T) {
312
330
)
313
331
signedProp := getSignedPropWithCHIdAndArgs (util .GetTestChainID (), "lscc" , "0" , [][]byte {[]byte ("deploy" ), []byte ("a" ), cds }, t )
314
332
315
- _ , err := es .ProcessProposal (context .Background (), signedProp )
316
- assert .Error (t , err )
333
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
334
+ assert .NoError (t , err )
335
+ assert .EqualValues (t , 500 , pResp .Response .Status )
336
+ assert .Equal (t , "attempting to deploy a system chaincode barf/testchainid" , pResp .Response .Message )
317
337
}
318
338
319
339
func TestEndorserLSCCJava1 (t * testing.T ) {
@@ -343,8 +363,10 @@ func TestEndorserLSCCJava1(t *testing.T) {
343
363
)
344
364
signedProp := getSignedPropWithCHIdAndArgs (util .GetTestChainID (), "lscc" , "0" , [][]byte {[]byte ("deploy" ), []byte ("a" ), cds }, t )
345
365
346
- _ , err := es .ProcessProposal (context .Background (), signedProp )
347
- assert .Error (t , err )
366
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
367
+ assert .NoError (t , err )
368
+ assert .EqualValues (t , 500 , pResp .Response .Status )
369
+ assert .Equal (t , "Java chaincode is work-in-progress and disabled" , pResp .Response .Message )
348
370
}
349
371
350
372
func TestEndorserLSCCJava2 (t * testing.T ) {
@@ -374,8 +396,9 @@ func TestEndorserLSCCJava2(t *testing.T) {
374
396
)
375
397
signedProp := getSignedPropWithCHIdAndArgs (util .GetTestChainID (), "lscc" , "0" , [][]byte {[]byte ("deploy" ), []byte ("a" ), cds }, t )
376
398
377
- _ , err := es .ProcessProposal (context .Background (), signedProp )
378
- assert .Error (t , err )
399
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
400
+ assert .NoError (t , err )
401
+ assert .EqualValues (t , 500 , pResp .Response .Status )
379
402
}
380
403
381
404
func TestEndorserGoodPathWEvents (t * testing.T ) {
@@ -393,8 +416,9 @@ func TestEndorserGoodPathWEvents(t *testing.T) {
393
416
394
417
signedProp := getSignedProp ("ccid" , "0" , t )
395
418
396
- _ , err := es .ProcessProposal (context .Background (), signedProp )
419
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
397
420
assert .NoError (t , err )
421
+ assert .EqualValues (t , 200 , pResp .Response .Status )
398
422
}
399
423
400
424
func TestEndorserBadChannel (t * testing.T ) {
@@ -411,8 +435,10 @@ func TestEndorserBadChannel(t *testing.T) {
411
435
412
436
signedProp := getSignedPropWithCHID ("ccid" , "0" , "barfchain" , t )
413
437
414
- _ , err := es .ProcessProposal (context .Background (), signedProp )
438
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
415
439
assert .Error (t , err )
440
+ assert .EqualValues (t , 500 , pResp .Response .Status )
441
+ assert .Equal (t , "access denied: channel [barfchain] creator org [SampleOrg]" , pResp .Response .Message )
416
442
}
417
443
418
444
func TestEndorserGoodPath (t * testing.T ) {
@@ -429,8 +455,9 @@ func TestEndorserGoodPath(t *testing.T) {
429
455
430
456
signedProp := getSignedProp ("ccid" , "0" , t )
431
457
432
- _ , err := es .ProcessProposal (context .Background (), signedProp )
458
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
433
459
assert .NoError (t , err )
460
+ assert .EqualValues (t , 200 , pResp .Response .Status )
434
461
}
435
462
436
463
func TestEndorserLSCC (t * testing.T ) {
@@ -455,8 +482,9 @@ func TestEndorserLSCC(t *testing.T) {
455
482
)
456
483
signedProp := getSignedPropWithCHIdAndArgs (util .GetTestChainID (), "lscc" , "0" , [][]byte {[]byte ("deploy" ), []byte ("a" ), cds }, t )
457
484
458
- _ , err := es .ProcessProposal (context .Background (), signedProp )
485
+ pResp , err := es .ProcessProposal (context .Background (), signedProp )
459
486
assert .NoError (t , err )
487
+ assert .EqualValues (t , 200 , pResp .Response .Status )
460
488
}
461
489
462
490
func TestSimulateProposal (t * testing.T ) {
@@ -501,11 +529,6 @@ func TestEndorserJavaChecks(t *testing.T) {
501
529
assert .Error (t , err )
502
530
}
503
531
504
- func TestChaincodeError_Error (t * testing.T ) {
505
- ce := & chaincodeError {status : 1 , msg : "foo" }
506
- assert .Equal (t , ce .Error (), "chaincode error (status: 1, message: foo)" )
507
- }
508
-
509
532
var signer msp.SigningIdentity
510
533
511
534
func TestMain (m * testing.M ) {
0 commit comments