@@ -32,6 +32,7 @@ import (
32
32
"github.com/hyperledger/fabric/core/container"
33
33
"github.com/hyperledger/fabric/core/container/ccintf"
34
34
"github.com/hyperledger/fabric/core/crypto"
35
+ "github.com/hyperledger/fabric/core/db"
35
36
"github.com/hyperledger/fabric/core/ledger"
36
37
"github.com/hyperledger/fabric/core/util"
37
38
"github.com/hyperledger/fabric/membersrvc/ca"
@@ -46,6 +47,8 @@ import (
46
47
// attributes to request in the batch of tcerts while deploying, invoking or querying
47
48
var attributes = []string {"company" , "position" }
48
49
50
+ var testDBWrapper = db .NewTestDBWrapper ()
51
+
49
52
func getNowMillis () int64 {
50
53
nanos := time .Now ().UnixNano ()
51
54
return nanos / 1000000
@@ -355,6 +358,7 @@ func executeDeployTransaction(t *testing.T, url string) {
355
358
356
359
// Test deploy of a transaction
357
360
func TestExecuteDeployTransaction (t * testing.T ) {
361
+ testDBWrapper .CleanDB (t )
358
362
executeDeployTransaction (t , "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01" )
359
363
}
360
364
@@ -364,6 +368,7 @@ func TestGopathExecuteDeployTransaction(t *testing.T) {
364
368
// and a couple of elements - it doesn't matter what they are
365
369
os .Setenv ("GOPATH" , os .Getenv ("GOPATH" )+ string (os .PathSeparator )+ string (os .PathListSeparator )+ "/tmp/foo" + string (os .PathListSeparator )+ "/tmp/bar" )
366
370
fmt .Printf ("set GOPATH to: \" %s\" \n " , os .Getenv ("GOPATH" ))
371
+ testDBWrapper .CleanDB (t )
367
372
executeDeployTransaction (t , "github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example01" )
368
373
}
369
374
@@ -372,6 +377,7 @@ func TestHTTPExecuteDeployTransaction(t *testing.T) {
372
377
// The chaincode used here cannot be from the fabric repo
373
378
// itself or it won't be downloaded because it will be found
374
379
// in GOPATH, which would defeat the test
380
+ testDBWrapper .CleanDB (t )
375
381
executeDeployTransaction (t , "http://github.com/hyperledger/fabric-test-resources/examples/chaincode/go/chaincode_example01" )
376
382
}
377
383
@@ -465,6 +471,7 @@ func invokeExample02Transaction(ctxt context.Context, cID *pb.ChaincodeID, args
465
471
}
466
472
467
473
func TestExecuteInvokeTransaction (t * testing.T ) {
474
+ testDBWrapper .CleanDB (t )
468
475
var opts []grpc.ServerOption
469
476
470
477
//TLS is on by default. This is the ONLY test that does NOT use TLS
@@ -570,6 +577,7 @@ func exec(ctxt context.Context, chaincodeID string, numTrans int, numQueries int
570
577
571
578
// Test the execution of a query.
572
579
func TestExecuteQuery (t * testing.T ) {
580
+ testDBWrapper .CleanDB (t )
573
581
var opts []grpc.ServerOption
574
582
if viper .GetBool ("peer.tls.enabled" ) {
575
583
creds , err := credentials .NewServerTLSFromFile (viper .GetString ("peer.tls.cert.file" ), viper .GetString ("peer.tls.key.file" ))
@@ -653,6 +661,7 @@ func TestExecuteQuery(t *testing.T) {
653
661
654
662
// Test the execution of an invalid transaction.
655
663
func TestExecuteInvokeInvalidTransaction (t * testing.T ) {
664
+ testDBWrapper .CleanDB (t )
656
665
var opts []grpc.ServerOption
657
666
if viper .GetBool ("peer.tls.enabled" ) {
658
667
creds , err := credentials .NewServerTLSFromFile (viper .GetString ("peer.tls.cert.file" ), viper .GetString ("peer.tls.key.file" ))
@@ -714,6 +723,7 @@ func TestExecuteInvokeInvalidTransaction(t *testing.T) {
714
723
715
724
// Test the execution of an invalid query.
716
725
func TestExecuteInvalidQuery (t * testing.T ) {
726
+ testDBWrapper .CleanDB (t )
717
727
var opts []grpc.ServerOption
718
728
if viper .GetBool ("peer.tls.enabled" ) {
719
729
creds , err := credentials .NewServerTLSFromFile (viper .GetString ("peer.tls.cert.file" ), viper .GetString ("peer.tls.key.file" ))
@@ -785,6 +795,7 @@ func TestExecuteInvalidQuery(t *testing.T) {
785
795
786
796
// Test the execution of a chaincode that invokes another chaincode.
787
797
func TestChaincodeInvokeChaincode (t * testing.T ) {
798
+ testDBWrapper .CleanDB (t )
788
799
var opts []grpc.ServerOption
789
800
if viper .GetBool ("peer.tls.enabled" ) {
790
801
creds , err := credentials .NewServerTLSFromFile (viper .GetString ("peer.tls.cert.file" ), viper .GetString ("peer.tls.key.file" ))
@@ -898,6 +909,7 @@ func TestChaincodeInvokeChaincode(t *testing.T) {
898
909
// Test the execution of a chaincode that invokes another chaincode with wrong parameters. Should receive error from
899
910
// from the called chaincode
900
911
func TestChaincodeInvokeChaincodeErrorCase (t * testing.T ) {
912
+ testDBWrapper .CleanDB (t )
901
913
var opts []grpc.ServerOption
902
914
if viper .GetBool ("peer.tls.enabled" ) {
903
915
creds , err := credentials .NewServerTLSFromFile (viper .GetString ("peer.tls.cert.file" ), viper .GetString ("peer.tls.key.file" ))
@@ -1098,6 +1110,7 @@ func chaincodeQueryChaincode(user string) error {
1098
1110
1099
1111
// Test the execution of a chaincode query that queries another chaincode without security enabled
1100
1112
func TestChaincodeQueryChaincode (t * testing.T ) {
1113
+ testDBWrapper .CleanDB (t )
1101
1114
var peerLis net.Listener
1102
1115
var err error
1103
1116
if peerLis , err = initPeer (); err != nil {
@@ -1119,6 +1132,7 @@ func TestChaincodeQueryChaincode(t *testing.T) {
1119
1132
// Test the execution of a chaincode that queries another chaincode with invalid parameter. Should receive error from
1120
1133
// from the called chaincode
1121
1134
func TestChaincodeQueryChaincodeErrorCase (t * testing.T ) {
1135
+ testDBWrapper .CleanDB (t )
1122
1136
var opts []grpc.ServerOption
1123
1137
if viper .GetBool ("peer.tls.enabled" ) {
1124
1138
creds , err := credentials .NewServerTLSFromFile (viper .GetString ("peer.tls.cert.file" ), viper .GetString ("peer.tls.key.file" ))
@@ -1229,6 +1243,7 @@ func TestChaincodeQueryChaincodeErrorCase(t *testing.T) {
1229
1243
// Test the execution of a chaincode query that queries another chaincode with security enabled
1230
1244
// NOTE: this really needs to be a behave test. Remove when we have support in behave for multiple chaincodes
1231
1245
func TestChaincodeQueryChaincodeWithSec (t * testing.T ) {
1246
+ testDBWrapper .CleanDB (t )
1232
1247
viper .Set ("security.enabled" , "true" )
1233
1248
1234
1249
//Initialize crypto
@@ -1282,6 +1297,7 @@ func TestChaincodeQueryChaincodeWithSec(t *testing.T) {
1282
1297
1283
1298
// Test the invocation of a transaction.
1284
1299
func TestRangeQuery (t * testing.T ) {
1300
+ testDBWrapper .CleanDB (t )
1285
1301
var opts []grpc.ServerOption
1286
1302
if viper .GetBool ("peer.tls.enabled" ) {
1287
1303
creds , err := credentials .NewServerTLSFromFile (viper .GetString ("peer.tls.cert.file" ), viper .GetString ("peer.tls.key.file" ))
@@ -1352,6 +1368,7 @@ func TestRangeQuery(t *testing.T) {
1352
1368
}
1353
1369
1354
1370
func TestGetEvent (t * testing.T ) {
1371
+ testDBWrapper .CleanDB (t )
1355
1372
var opts []grpc.ServerOption
1356
1373
if viper .GetBool ("peer.tls.enabled" ) {
1357
1374
creds , err := credentials .NewServerTLSFromFile (viper .GetString ("peer.tls.cert.file" ), viper .GetString ("peer.tls.key.file" ))
0 commit comments