@@ -25,7 +25,6 @@ import (
25
25
"github.com/hyperledger/fabric/core/aclmgmt/resources"
26
26
"github.com/hyperledger/fabric/core/chaincode/shim"
27
27
"github.com/hyperledger/fabric/core/common/ccprovider"
28
- "github.com/hyperledger/fabric/core/common/sysccprovider"
29
28
cutil "github.com/hyperledger/fabric/core/container/util"
30
29
"github.com/hyperledger/fabric/core/ledger/cceventmgmt"
31
30
"github.com/hyperledger/fabric/core/mocks/scc/lscc"
@@ -98,7 +97,7 @@ func TestInstall(t *testing.T) {
98
97
// TODO cceventmgmt singleton should be refactored out of peer in the future. See CR 16549 for details.
99
98
cceventmgmt .Initialize ()
100
99
101
- scc := New ()
100
+ scc := New (NewMockProvider () )
102
101
scc .support = & lscc.MockSupport {}
103
102
stub := shim .NewMockStub ("lscc" , scc )
104
103
res := stub .MockInit ("1" , nil )
@@ -175,7 +174,7 @@ func TestDeploy(t *testing.T) {
175
174
testDeploy (t , "example02" , "1{}0" , path , false , false , true , InvalidVersionErr ("1{}0" ).Error (), nil , nil )
176
175
testDeploy (t , "example02" , "0" , path , true , true , true , EmptyChaincodeNameErr ("" ).Error (), nil , nil )
177
176
178
- scc := New ()
177
+ scc := New (NewMockProvider () )
179
178
scc .support = & lscc.MockSupport {}
180
179
stub := shim .NewMockStub ("lscc" , scc )
181
180
res := stub .MockInit ("1" , nil )
@@ -193,7 +192,7 @@ func TestDeploy(t *testing.T) {
193
192
testDeploy (t , "example02" , "1.0" , path , false , false , true , "" , scc , stub )
194
193
testDeploy (t , "example02" , "1.0" , path , false , false , true , "chaincode exists example02" , scc , stub )
195
194
196
- scc = New ()
195
+ scc = New (NewMockProvider () )
197
196
scc .support = & lscc.MockSupport {}
198
197
stub = shim .NewMockStub ("lscc" , scc )
199
198
res = stub .MockInit ("1" , nil )
@@ -202,7 +201,7 @@ func TestDeploy(t *testing.T) {
202
201
203
202
testDeploy (t , "example02" , "1.0" , path , false , false , true , "barf" , scc , stub )
204
203
205
- scc = New ()
204
+ scc = New (NewMockProvider () )
206
205
scc .support = & lscc.MockSupport {}
207
206
stub = shim .NewMockStub ("lscc" , scc )
208
207
res = stub .MockInit ("1" , nil )
@@ -211,7 +210,7 @@ func TestDeploy(t *testing.T) {
211
210
212
211
testDeploy (t , "example02" , "1.0" , path , false , false , true , "barf" , scc , stub )
213
212
214
- scc = New ()
213
+ scc = New (NewMockProvider () )
215
214
scc .support = & lscc.MockSupport {}
216
215
stub = shim .NewMockStub ("lscc" , scc )
217
216
res = stub .MockInit ("1" , nil )
@@ -220,7 +219,7 @@ func TestDeploy(t *testing.T) {
220
219
221
220
testDeploy (t , "example02" , "1.0" , path , false , false , true , "escc is not a valid endorsement system chaincode" , scc , stub )
222
221
223
- scc = New ()
222
+ scc = New (NewMockProvider () )
224
223
scc .support = & lscc.MockSupport {}
225
224
stub = shim .NewMockStub ("lscc" , scc )
226
225
res = stub .MockInit ("1" , nil )
@@ -232,7 +231,7 @@ func TestDeploy(t *testing.T) {
232
231
233
232
func testDeploy (t * testing.T , ccname string , version string , path string , forceBlankCCName bool , forceBlankVersion bool , install bool , expectedErrorMsg string , scc * lifeCycleSysCC , stub * shim.MockStub ) {
234
233
if scc == nil {
235
- scc = New ()
234
+ scc = New (NewMockProvider () )
236
235
scc .support = & lscc.MockSupport {}
237
236
stub = shim .NewMockStub ("lscc" , scc )
238
237
res := stub .MockInit ("1" , nil )
@@ -320,7 +319,7 @@ func TestUpgrade(t *testing.T) {
320
319
testUpgrade (t , "example02" , "0" , "example*02" , "1{}0" , path , InvalidChaincodeNameErr ("example*02" ).Error (), nil , nil )
321
320
testUpgrade (t , "example02" , "0" , "" , "1" , path , EmptyChaincodeNameErr ("" ).Error (), nil , nil )
322
321
323
- scc := New ()
322
+ scc := New (NewMockProvider () )
324
323
scc .support = & lscc.MockSupport {}
325
324
stub := shim .NewMockStub ("lscc" , scc )
326
325
res := stub .MockInit ("1" , nil )
@@ -330,15 +329,15 @@ func TestUpgrade(t *testing.T) {
330
329
331
330
testUpgrade (t , "example02" , "0" , "example02" , "1" , path , "barf" , scc , stub )
332
331
333
- scc = New ()
332
+ scc = New (NewMockProvider () )
334
333
scc .support = & lscc.MockSupport {}
335
334
stub = shim .NewMockStub ("lscc" , scc )
336
335
res = stub .MockInit ("1" , nil )
337
336
assert .Equal (t , res .Status , int32 (shim .OK ), res .Message )
338
337
339
338
testUpgrade (t , "example02" , "0" , "example02" , "1" , path , "instantiation policy missing" , scc , stub )
340
339
341
- scc = New ()
340
+ scc = New (NewMockProvider () )
342
341
scc .support = & lscc.MockSupport {}
343
342
stub = shim .NewMockStub ("lscc" , scc )
344
343
res = stub .MockInit ("1" , nil )
@@ -349,7 +348,7 @@ func TestUpgrade(t *testing.T) {
349
348
350
349
testUpgrade (t , "example02" , "0" , "example02" , "1" , path , "barf" , scc , stub )
351
350
352
- scc = New ()
351
+ scc = New (NewMockProvider () )
353
352
scc .support = & lscc.MockSupport {}
354
353
stub = shim .NewMockStub ("lscc" , scc )
355
354
res = stub .MockInit ("1" , nil )
@@ -363,7 +362,7 @@ func TestUpgrade(t *testing.T) {
363
362
364
363
func testUpgrade (t * testing.T , ccname string , version string , newccname string , newversion string , path string , expectedErrorMsg string , scc * lifeCycleSysCC , stub * shim.MockStub ) {
365
364
if scc == nil {
366
- scc = New ()
365
+ scc = New (NewMockProvider () )
367
366
scc .support = & lscc.MockSupport {}
368
367
stub = shim .NewMockStub ("lscc" , scc )
369
368
res := stub .MockInit ("1" , nil )
@@ -409,7 +408,7 @@ func testUpgrade(t *testing.T, ccname string, version string, newccname string,
409
408
}
410
409
411
410
func TestGETCCINFO (t * testing.T ) {
412
- scc := New ()
411
+ scc := New (NewMockProvider () )
413
412
scc .support = & lscc.MockSupport {}
414
413
stub := shim .NewMockStub ("lscc" , scc )
415
414
res := stub .MockInit ("1" , nil )
@@ -445,7 +444,7 @@ func TestGETCCINFO(t *testing.T) {
445
444
}
446
445
447
446
func TestGETCHAINCODES (t * testing.T ) {
448
- scc := New ()
447
+ scc := New (NewMockProvider () )
449
448
scc .support = & lscc.MockSupport {}
450
449
stub := shim .NewMockStub ("lscc" , scc )
451
450
res := stub .MockInit ("1" , nil )
@@ -474,7 +473,7 @@ func TestGETCHAINCODES(t *testing.T) {
474
473
}
475
474
476
475
func TestGETINSTALLEDCHAINCODES (t * testing.T ) {
477
- scc := New ()
476
+ scc := New (NewMockProvider () )
478
477
scc .support = & lscc.MockSupport {}
479
478
stub := shim .NewMockStub ("lscc" , scc )
480
479
res := stub .MockInit ("1" , nil )
@@ -533,7 +532,7 @@ func TestGETINSTALLEDCHAINCODES(t *testing.T) {
533
532
}
534
533
535
534
func TestNewLifeCycleSysCC (t * testing.T ) {
536
- scc := New ()
535
+ scc := New (NewMockProvider () )
537
536
assert .NotNil (t , scc )
538
537
stub := shim .NewMockStub ("lscc" , scc )
539
538
res := stub .MockInit ("1" , nil )
@@ -544,7 +543,7 @@ func TestNewLifeCycleSysCC(t *testing.T) {
544
543
}
545
544
546
545
func TestGetChaincodeData (t * testing.T ) {
547
- scc := New ()
546
+ scc := New (NewMockProvider () )
548
547
assert .NotNil (t , scc )
549
548
stub := shim .NewMockStub ("lscc" , scc )
550
549
res := stub .MockInit ("1" , nil )
@@ -559,7 +558,7 @@ func TestGetChaincodeData(t *testing.T) {
559
558
}
560
559
561
560
func TestExecuteInstall (t * testing.T ) {
562
- scc := New ()
561
+ scc := New (NewMockProvider () )
563
562
assert .NotNil (t , scc )
564
563
stub := shim .NewMockStub ("lscc" , scc )
565
564
res := stub .MockInit ("1" , nil )
@@ -624,6 +623,15 @@ var id msp.SigningIdentity
624
623
var chainid string = util .GetTestChainID ()
625
624
var mockAclProvider * mocks.MockACLProvider
626
625
626
+ func NewMockProvider () * mscc.MocksccProviderImpl {
627
+ return (& mscc.MocksccProviderFactory {
628
+ ApplicationConfigBool : true ,
629
+ ApplicationConfigRv : & config.MockApplication {
630
+ CapabilitiesRv : & config.MockApplicationCapabilities {},
631
+ },
632
+ }).NewSystemChaincodeProvider ().(* mscc.MocksccProviderImpl )
633
+ }
634
+
627
635
func TestMain (m * testing.M ) {
628
636
var err error
629
637
msptesttools .LoadMSPSetupForTesting ()
@@ -635,15 +643,6 @@ func TestMain(m *testing.M) {
635
643
636
644
mockAclProvider = & mocks.MockACLProvider {}
637
645
mockAclProvider .Reset ()
638
-
639
- sysccprovider .RegisterSystemChaincodeProviderFactory (
640
- & mscc.MocksccProviderFactory {
641
- ApplicationConfigBool : true ,
642
- ApplicationConfigRv : & config.MockApplication {
643
- CapabilitiesRv : & config.MockApplicationCapabilities {},
644
- },
645
- },
646
- )
647
646
aclmgmt .RegisterACLProvider (mockAclProvider )
648
647
649
648
os .Exit (m .Run ())
0 commit comments