@@ -35,16 +35,19 @@ import (
35
35
"github.com/hyperledger/fabric/protos/msp"
36
36
"github.com/hyperledger/fabric/protos/peer"
37
37
transientstore2 "github.com/hyperledger/fabric/protos/transientstore"
38
- "github.com/spf13/viper"
39
38
"github.com/stretchr/testify/assert"
40
39
"github.com/stretchr/testify/mock"
41
40
)
42
41
43
42
func init () {
44
- viper .Set ("peer.gossip.pvtData.pullRetryThreshold" , time .Second * 3 )
45
43
factory .InitFactories (nil )
46
44
}
47
45
46
+ var testConfig = CoordinatorConfig {
47
+ PullRetryThreshold : time .Second * 3 ,
48
+ TransientBlockRetention : TransientBlockRetentionDefault ,
49
+ }
50
+
48
51
// CollectionCriteria aggregates criteria of
49
52
// a collection
50
53
type CollectionCriteria struct {
@@ -670,7 +673,7 @@ func TestCoordinatorStoreInvalidBlock(t *testing.T) {
670
673
Fetcher : fetcher ,
671
674
TransientStore : store ,
672
675
Validator : & validatorMock {},
673
- }, peerSelfSignedData , metrics )
676
+ }, peerSelfSignedData , metrics , testConfig )
674
677
err := coordinator .StoreBlock (block , pvtData )
675
678
assert .Error (t , err )
676
679
assert .Contains (t , err .Error (), "Block.Metadata is nil or Block.Metadata lacks a Tx filter bitmap" )
@@ -684,7 +687,7 @@ func TestCoordinatorStoreInvalidBlock(t *testing.T) {
684
687
Fetcher : fetcher ,
685
688
TransientStore : store ,
686
689
Validator : & validatorMock {fmt .Errorf ("failed validating block" )},
687
- }, peerSelfSignedData , metrics )
690
+ }, peerSelfSignedData , metrics , testConfig )
688
691
err = coordinator .StoreBlock (block , pvtData )
689
692
assert .Error (t , err )
690
693
assert .Contains (t , err .Error (), "failed validating block" )
@@ -698,7 +701,7 @@ func TestCoordinatorStoreInvalidBlock(t *testing.T) {
698
701
Fetcher : fetcher ,
699
702
TransientStore : store ,
700
703
Validator : & validatorMock {},
701
- }, peerSelfSignedData , metrics )
704
+ }, peerSelfSignedData , metrics , testConfig )
702
705
err = coordinator .StoreBlock (block , pvtData )
703
706
assert .Error (t , err )
704
707
assert .Contains (t , err .Error (), "Block data size" )
@@ -732,7 +735,7 @@ func TestCoordinatorStoreInvalidBlock(t *testing.T) {
732
735
Fetcher : fetcher ,
733
736
TransientStore : store ,
734
737
Validator : & validatorMock {},
735
- }, peerSelfSignedData , metrics )
738
+ }, peerSelfSignedData , metrics , testConfig )
736
739
err = coordinator .StoreBlock (block , pvtData )
737
740
assert .NoError (t , err )
738
741
assertCommitHappened ()
@@ -814,7 +817,7 @@ func TestCoordinatorToFilterOutPvtRWSetsWithWrongHash(t *testing.T) {
814
817
Fetcher : fetcher ,
815
818
TransientStore : store ,
816
819
Validator : & validatorMock {},
817
- }, peerSelfSignedData , metrics )
820
+ }, peerSelfSignedData , metrics , testConfig )
818
821
819
822
fetcher .On ("fetch" , mock .Anything ).expectingDigests ([]privdatacommon.DigKey {
820
823
{
@@ -913,7 +916,7 @@ func TestCoordinatorStoreBlock(t *testing.T) {
913
916
Fetcher : fetcher ,
914
917
TransientStore : store ,
915
918
Validator : & validatorMock {},
916
- }, peerSelfSignedData , metrics )
919
+ }, peerSelfSignedData , metrics , testConfig )
917
920
err := coordinator .StoreBlock (block , pvtData )
918
921
assert .NoError (t , err )
919
922
assertCommitHappened ()
@@ -1002,7 +1005,7 @@ func TestCoordinatorStoreBlock(t *testing.T) {
1002
1005
Fetcher : fetcher ,
1003
1006
TransientStore : store ,
1004
1007
Validator : & validatorMock {},
1005
- }, peerSelfSignedData , metrics )
1008
+ }, peerSelfSignedData , metrics , testConfig )
1006
1009
err = coordinator .StoreBlock (block , nil )
1007
1010
assert .Error (t , err )
1008
1011
assert .Equal (t , "test error" , err .Error ())
@@ -1051,7 +1054,7 @@ func TestCoordinatorStoreBlock(t *testing.T) {
1051
1054
Fetcher : fetcher ,
1052
1055
TransientStore : store ,
1053
1056
Validator : & validatorMock {},
1054
- }, peerSelfSignedData , metrics )
1057
+ }, peerSelfSignedData , metrics , testConfig )
1055
1058
err = coordinator .StoreBlock (block , nil )
1056
1059
assertPurged ("tx3" )
1057
1060
assert .NoError (t , err )
@@ -1089,7 +1092,7 @@ func TestCoordinatorStoreBlock(t *testing.T) {
1089
1092
Fetcher : fetcher ,
1090
1093
TransientStore : store ,
1091
1094
Validator : & validatorMock {},
1092
- }, peerSelfSignedData , metrics )
1095
+ }, peerSelfSignedData , metrics , testConfig )
1093
1096
1094
1097
pvtData = pdFactory .addRWSet ().addNSRWSet ("ns3" , "c3" ).create ()
1095
1098
err = coordinator .StoreBlock (block , pvtData )
@@ -1178,7 +1181,7 @@ func TestProceedWithoutPrivateData(t *testing.T) {
1178
1181
Fetcher : fetcher ,
1179
1182
TransientStore : store ,
1180
1183
Validator : & validatorMock {},
1181
- }, peerSelfSignedData , metrics )
1184
+ }, peerSelfSignedData , metrics , testConfig )
1182
1185
err := coordinator .StoreBlock (block , pvtData )
1183
1186
assert .NoError (t , err )
1184
1187
assertCommitHappened ()
@@ -1229,7 +1232,7 @@ func TestProceedWithInEligiblePrivateData(t *testing.T) {
1229
1232
Fetcher : nil ,
1230
1233
TransientStore : nil ,
1231
1234
Validator : & validatorMock {},
1232
- }, peerSelfSignedData , metrics )
1235
+ }, peerSelfSignedData , metrics , testConfig )
1233
1236
err := coordinator .StoreBlock (block , nil )
1234
1237
assert .NoError (t , err )
1235
1238
assertCommitHappened ()
@@ -1252,7 +1255,7 @@ func TestCoordinatorGetBlocks(t *testing.T) {
1252
1255
Fetcher : fetcher ,
1253
1256
TransientStore : store ,
1254
1257
Validator : & validatorMock {},
1255
- }, sd , metrics )
1258
+ }, sd , metrics , testConfig )
1256
1259
1257
1260
hash := util2 .ComputeSHA256 ([]byte ("rws-pre-image" ))
1258
1261
bf := & blockFactory {
@@ -1279,7 +1282,7 @@ func TestCoordinatorGetBlocks(t *testing.T) {
1279
1282
Fetcher : fetcher ,
1280
1283
TransientStore : store ,
1281
1284
Validator : & validatorMock {},
1282
- }, sd , metrics )
1285
+ }, sd , metrics , testConfig )
1283
1286
expectedPrivData := (& pvtDataFactory {}).addRWSet ().addNSRWSet ("ns1" , "c2" ).create ()
1284
1287
block2 , returnedPrivateData , err := coordinator .GetPvtDataAndBlockByNum (1 , sd )
1285
1288
assert .NoError (t , err )
@@ -1330,7 +1333,7 @@ func TestPurgeByHeight(t *testing.T) {
1330
1333
Fetcher : fetcher ,
1331
1334
TransientStore : store ,
1332
1335
Validator : & validatorMock {},
1333
- }, peerSelfSignedData , metrics )
1336
+ }, peerSelfSignedData , metrics , testConfig )
1334
1337
1335
1338
for i := 0 ; i <= 3000 ; i ++ {
1336
1339
block := bf .create ()
@@ -1359,7 +1362,7 @@ func TestCoordinatorStorePvtData(t *testing.T) {
1359
1362
Fetcher : fetcher ,
1360
1363
TransientStore : store ,
1361
1364
Validator : & validatorMock {},
1362
- }, common.SignedData {}, metrics )
1365
+ }, common.SignedData {}, metrics , testConfig )
1363
1366
pvtData := (& pvtDataFactory {}).addRWSet ().addNSRWSet ("ns1" , "c1" ).create ()
1364
1367
// Green path: ledger height can be retrieved from ledger/committer
1365
1368
err := coordinator .StorePvtData ("tx1" , & transientstore2.TxPvtReadWriteSetWithConfigInfo {
@@ -1430,7 +1433,7 @@ func TestIgnoreReadOnlyColRWSets(t *testing.T) {
1430
1433
Fetcher : fetcher ,
1431
1434
TransientStore : store ,
1432
1435
Validator : & validatorMock {},
1433
- }, peerSelfSignedData , metrics )
1436
+ }, peerSelfSignedData , metrics , testConfig )
1434
1437
// We pass a nil private data slice to indicate no pre-images though the block contains
1435
1438
// private data reads.
1436
1439
err := coordinator .StoreBlock (block , nil )
@@ -1473,7 +1476,7 @@ func TestCoordinatorMetrics(t *testing.T) {
1473
1476
TransientStore : store ,
1474
1477
Validator : & validatorMock {},
1475
1478
ChainID : "test" ,
1476
- }, peerSelfSignedData , metrics )
1479
+ }, peerSelfSignedData , metrics , testConfig )
1477
1480
err := coordinator .StoreBlock (block , pvtData )
1478
1481
assert .NoError (t , err )
1479
1482
0 commit comments