github.com/kaituanwang/hyperledger@v2.0.1+incompatible/core/ledger/pvtdatapolicy/testutil/util.go (about) 1 /* 2 Copyright IBM Corp. All Rights Reserved. 3 4 SPDX-License-Identifier: Apache-2.0 5 */ 6 7 package testutil 8 9 import ( 10 "github.com/hyperledger/fabric-protos-go/peer" 11 "github.com/hyperledger/fabric/core/ledger/pvtdatapolicy" 12 "github.com/hyperledger/fabric/core/ledger/pvtdatapolicy/mock" 13 ) 14 15 // SampleBTLPolicy helps tests create a sample BTLPolicy 16 // The example input entry is [2]string{ns, coll}:btl 17 func SampleBTLPolicy(m map[[2]string]uint64) pvtdatapolicy.BTLPolicy { 18 ccInfoRetriever := &mock.CollectionInfoProvider{} 19 ccInfoRetriever.CollectionInfoStub = func(ccName, collName string) (*peer.StaticCollectionConfig, error) { 20 btl := m[[2]string{ccName, collName}] 21 return &peer.StaticCollectionConfig{BlockToLive: btl}, nil 22 } 23 return pvtdatapolicy.ConstructBTLPolicy(ccInfoRetriever) 24 }