@@ -10,11 +10,9 @@ import (
10
10
"encoding/gob"
11
11
"encoding/json"
12
12
"fmt"
13
- "os"
14
13
"strings"
15
14
"testing"
16
15
17
- "github.com/hyperledger/fabric/common/flogging"
18
16
"github.com/hyperledger/fabric/common/ledger/testutil"
19
17
"github.com/hyperledger/fabric/core/ledger"
20
18
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/privacyenabledstate"
@@ -27,21 +25,13 @@ import (
27
25
"github.com/stretchr/testify/assert"
28
26
)
29
27
30
- func TestMain (m * testing.M ) {
31
- flogging .ActivateSpec (
32
- "lockbasedtxmgr,statevalidator,statebasedval,statecouchdb,valimpl,pvtstatepurgemgmt,valinternal=debug" ,
33
- )
34
- os .Exit (m .Run ())
35
- }
36
-
37
28
func TestTxSimulatorWithNoExistingData (t * testing.T ) {
38
29
// run the tests for each environment configured in pkg_test.go
39
30
for _ , testEnv := range testEnvs {
40
31
t .Logf ("Running test for TestEnv = %s" , testEnv .getName ())
41
32
testLedgerID := "testtxsimulatorwithnoexistingdata"
42
33
testEnv .init (t , testLedgerID , nil )
43
34
testTxSimulatorWithNoExistingData (t , testEnv )
44
- testEnv .cleanup ()
45
35
}
46
36
}
47
37
@@ -68,7 +58,6 @@ func testTxSimulatorWithNoExistingData(t *testing.T, env testEnv) {
68
58
func TestTxSimulatorGetResults (t * testing.T ) {
69
59
testEnv := testEnvsMap [levelDBtestEnvName ]
70
60
testEnv .init (t , "testLedger" , nil )
71
- defer testEnv .cleanup ()
72
61
txMgr := testEnv .getTxMgr ()
73
62
populateCollConfigForTest (t , txMgr .(* LockBasedTxMgr ),
74
63
[]collConfigkey {
@@ -126,7 +115,6 @@ func TestTxSimulatorWithExistingData(t *testing.T) {
126
115
testLedgerID := "testtxsimulatorwithexistingdata"
127
116
testEnv .init (t , testLedgerID , nil )
128
117
testTxSimulatorWithExistingData (t , testEnv )
129
- testEnv .cleanup ()
130
118
})
131
119
}
132
120
}
@@ -179,7 +167,6 @@ func TestTxValidation(t *testing.T) {
179
167
testLedgerID := "testtxvalidation"
180
168
testEnv .init (t , testLedgerID , nil )
181
169
testTxValidation (t , testEnv )
182
- testEnv .cleanup ()
183
170
}
184
171
}
185
172
@@ -266,7 +253,6 @@ func TestTxPhantomValidation(t *testing.T) {
266
253
testLedgerID := "testtxphantomvalidation"
267
254
testEnv .init (t , testLedgerID , nil )
268
255
testTxPhantomValidation (t , testEnv )
269
- testEnv .cleanup ()
270
256
}
271
257
}
272
258
@@ -336,27 +322,22 @@ func TestIterator(t *testing.T) {
336
322
testLedgerID := "testiterator.1"
337
323
testEnv .init (t , testLedgerID , nil )
338
324
testIterator (t , testEnv , 10 , 2 , 7 )
339
- testEnv .cleanup ()
340
325
341
326
testLedgerID = "testiterator.2"
342
327
testEnv .init (t , testLedgerID , nil )
343
328
testIterator (t , testEnv , 10 , 1 , 11 )
344
- testEnv .cleanup ()
345
329
346
330
testLedgerID = "testiterator.3"
347
331
testEnv .init (t , testLedgerID , nil )
348
332
testIterator (t , testEnv , 10 , 0 , 0 )
349
- testEnv .cleanup ()
350
333
351
334
testLedgerID = "testiterator.4"
352
335
testEnv .init (t , testLedgerID , nil )
353
336
testIterator (t , testEnv , 10 , 5 , 0 )
354
- testEnv .cleanup ()
355
337
356
338
testLedgerID = "testiterator.5"
357
339
testEnv .init (t , testLedgerID , nil )
358
340
testIterator (t , testEnv , 10 , 0 , 5 )
359
- testEnv .cleanup ()
360
341
}
361
342
}
362
343
@@ -432,7 +413,6 @@ func TestIteratorPaging(t *testing.T) {
432
413
nextStartKey = testIteratorPaging (t , testEnv , 10 , nextStartKey , "key_007" , int32 (2 ), returnKeys )
433
414
returnKeys = []string {"key_006" }
434
415
testIteratorPaging (t , testEnv , 10 , nextStartKey , "key_007" , int32 (2 ), returnKeys )
435
- testEnv .cleanup ()
436
416
}
437
417
}
438
418
@@ -497,7 +477,6 @@ func TestIteratorWithDeletes(t *testing.T) {
497
477
testLedgerID := "testiteratorwithdeletes"
498
478
testEnv .init (t , testLedgerID , nil )
499
479
testIteratorWithDeletes (t , testEnv )
500
- testEnv .cleanup ()
501
480
}
502
481
}
503
482
@@ -539,7 +518,6 @@ func TestTxValidationWithItr(t *testing.T) {
539
518
testLedgerID := "testtxvalidationwithitr"
540
519
testEnv .init (t , testLedgerID , nil )
541
520
testTxValidationWithItr (t , testEnv )
542
- testEnv .cleanup ()
543
521
}
544
522
}
545
523
@@ -604,7 +582,6 @@ func TestGetSetMultipeKeys(t *testing.T) {
604
582
testLedgerID := "testgetsetmultipekeys"
605
583
testEnv .init (t , testLedgerID , nil )
606
584
testGetSetMultipeKeys (t , testEnv )
607
- testEnv .cleanup ()
608
585
}
609
586
}
610
587
@@ -667,7 +644,6 @@ func TestExecuteQuery(t *testing.T) {
667
644
testLedgerID := "testexecutequery"
668
645
testEnv .init (t , testLedgerID , nil )
669
646
testExecuteQuery (t , testEnv )
670
- testEnv .cleanup ()
671
647
}
672
648
}
673
649
}
@@ -742,7 +718,6 @@ func TestExecutePaginatedQuery(t *testing.T) {
742
718
testLedgerID := "testexecutepaginatedquery"
743
719
testEnv .init (t , testLedgerID , nil )
744
720
testExecutePaginatedQuery (t , testEnv )
745
- testEnv .cleanup ()
746
721
}
747
722
}
748
723
}
@@ -843,7 +818,6 @@ func TestValidateKey(t *testing.T) {
843
818
if testEnv .getName () == couchDBtestEnvName {
844
819
assert .Error (t , err )
845
820
}
846
- testEnv .cleanup ()
847
821
}
848
822
}
849
823
@@ -852,7 +826,6 @@ func TestValidateKey(t *testing.T) {
852
826
func TestTxSimulatorUnsupportedTx (t * testing.T ) {
853
827
testEnv := testEnvs [0 ]
854
828
testEnv .init (t , "testtxsimulatorunsupportedtx" , nil )
855
- defer testEnv .cleanup ()
856
829
txMgr := testEnv .getTxMgr ()
857
830
populateCollConfigForTest (t , txMgr .(* LockBasedTxMgr ),
858
831
[]collConfigkey {
@@ -907,7 +880,6 @@ func TestTxSimulatorQueryUnsupportedTx(t *testing.T) {
907
880
testLedgerID := "testtxsimulatorunsupportedtxqueries"
908
881
testEnv .init (t , testLedgerID , nil )
909
882
testTxSimulatorQueryUnsupportedTx (t , testEnv )
910
- testEnv .cleanup ()
911
883
}
912
884
}
913
885
}
@@ -1010,7 +982,6 @@ func TestFindAndRemoveStalePvtData(t *testing.T) {
1010
982
ledgerid := "TestFindAndRemoveStalePvtData"
1011
983
testEnv := testEnvs [0 ]
1012
984
testEnv .init (t , ledgerid , nil )
1013
- defer testEnv .cleanup ()
1014
985
db := testEnv .getVDB ()
1015
986
1016
987
batch := privacyenabledstate .NewUpdateBatch ()
@@ -1082,7 +1053,6 @@ func TestRemoveStaleAndCommitPvtDataOfOldBlocks(t *testing.T) {
1082
1053
for _ , testEnv := range testEnvs {
1083
1054
t .Logf ("Running test for TestEnv = %s" , testEnv .getName ())
1084
1055
testValidationAndCommitOfOldPvtData (t , testEnv )
1085
- testEnv .cleanup ()
1086
1056
}
1087
1057
}
1088
1058
@@ -1187,7 +1157,6 @@ func testValidationAndCommitOfOldPvtData(t *testing.T, env testEnv) {
1187
1157
func TestTxSimulatorMissingPvtdata (t * testing.T ) {
1188
1158
testEnv := testEnvs [0 ]
1189
1159
testEnv .init (t , "TestTxSimulatorUnsupportedTxQueries" , nil )
1190
- defer testEnv .cleanup ()
1191
1160
1192
1161
txMgr := testEnv .getTxMgr ()
1193
1162
populateCollConfigForTest (t , txMgr .(* LockBasedTxMgr ),
@@ -1233,7 +1202,6 @@ func TestRemoveStaleAndCommitPvtDataOfOldBlocksWithExpiry(t *testing.T) {
1233
1202
)
1234
1203
testEnv := testEnvs [0 ]
1235
1204
testEnv .init (t , ledgerid , btlPolicy )
1236
- defer testEnv .cleanup ()
1237
1205
1238
1206
txMgr := testEnv .getTxMgr ()
1239
1207
populateCollConfigForTest (t , txMgr .(* LockBasedTxMgr ),
@@ -1341,7 +1309,6 @@ func TestDeleteOnCursor(t *testing.T) {
1341
1309
cID := "cid"
1342
1310
env := testEnvs [0 ]
1343
1311
env .init (t , "TestDeleteOnCursor" , nil )
1344
- defer env .cleanup ()
1345
1312
1346
1313
txMgr := env .getTxMgr ()
1347
1314
txMgrHelper := newTxMgrTestHelper (t , txMgr )
@@ -1394,7 +1361,6 @@ func TestTxSimulatorMissingPvtdataExpiry(t *testing.T) {
1394
1361
},
1395
1362
)
1396
1363
testEnv .init (t , ledgerid , btlPolicy )
1397
- defer testEnv .cleanup ()
1398
1364
1399
1365
txMgr := testEnv .getTxMgr ()
1400
1366
populateCollConfigForTest (t , txMgr .(* LockBasedTxMgr ), []collConfigkey {{"ns" , "coll" }}, version .NewHeight (1 , 1 ))
@@ -1433,7 +1399,6 @@ func TestTxWithPubMetadata(t *testing.T) {
1433
1399
testLedgerID := "testtxwithpubmetadata"
1434
1400
testEnv .init (t , testLedgerID , nil )
1435
1401
testTxWithPubMetadata (t , testEnv )
1436
- testEnv .cleanup ()
1437
1402
}
1438
1403
}
1439
1404
@@ -1491,7 +1456,6 @@ func TestTxWithPvtdataMetadata(t *testing.T) {
1491
1456
t .Logf ("Running test for TestEnv = %s" , testEnv .getName ())
1492
1457
testEnv .init (t , ledgerid , btlPolicy )
1493
1458
testTxWithPvtdataMetadata (t , testEnv , ns , coll )
1494
- testEnv .cleanup ()
1495
1459
}
1496
1460
}
1497
1461
0 commit comments