@@ -21,10 +21,10 @@ import (
21
21
"github.com/hyperledger/fabric/core/chaincode/platforms/node"
22
22
"github.com/hyperledger/fabric/core/common/ccprovider"
23
23
"github.com/hyperledger/fabric/core/common/privdata"
24
- . "github.com/hyperledger/fabric/core/handlers/validation/api/capabilities"
25
- . "github.com/hyperledger/fabric/core/handlers/validation/api/identities"
26
- . "github.com/hyperledger/fabric/core/handlers/validation/api/policies"
27
- . "github.com/hyperledger/fabric/core/handlers/validation/api/state"
24
+ vc "github.com/hyperledger/fabric/core/handlers/validation/api/capabilities"
25
+ vi "github.com/hyperledger/fabric/core/handlers/validation/api/identities"
26
+ vp "github.com/hyperledger/fabric/core/handlers/validation/api/policies"
27
+ vs "github.com/hyperledger/fabric/core/handlers/validation/api/state"
28
28
"github.com/hyperledger/fabric/core/handlers/validation/builtin/internal/car"
29
29
"github.com/hyperledger/fabric/core/ledger/kvledger/txmgmt/rwsetutil"
30
30
"github.com/hyperledger/fabric/core/scc/lscc"
@@ -44,14 +44,37 @@ const (
44
44
45
45
var validCollectionNameRegex = regexp .MustCompile (ccmetadata .AllowedCharsCollectionName )
46
46
47
- //go:generate mockery -dir ../../api/capabilities/ -name Capabilities -case underscore -output mocks/
48
- //go:generate mockery -dir ../../api/state/ -name StateFetcher -case underscore -output mocks/
49
- //go:generate mockery -dir ../../api/identities/ -name IdentityDeserializer -case underscore -output mocks/
50
- //go:generate mockery -dir ../../api/policies/ -name PolicyEvaluator -case underscore -output mocks/
47
+ //go:generate mockery -dir . -name Capabilities -case underscore -output mocks/
48
+
49
+ // Capabilities is the local interface that used to generate mocks for foreign interface.
50
+ type Capabilities interface {
51
+ vc.Capabilities
52
+ }
53
+
54
+ //go:generate mockery -dir . -name StateFetcher -case underscore -output mocks/
55
+
56
+ // StateFetcher is the local interface that used to generate mocks for foreign interface.
57
+ type StateFetcher interface {
58
+ vs.StateFetcher
59
+ }
60
+
61
+ //go:generate mockery -dir . -name IdentityDeserializer -case underscore -output mocks/
62
+
63
+ // IdentityDeserializer is the local interface that used to generate mocks for foreign interface.
64
+ type IdentityDeserializer interface {
65
+ vi.IdentityDeserializer
66
+ }
67
+
68
+ //go:generate mockery -dir . -name PolicyEvaluator -case underscore -output mocks/
69
+
70
+ // PolicyEvaluator is the local interface that used to generate mocks for foreign interface.
71
+ type PolicyEvaluator interface {
72
+ vp.PolicyEvaluator
73
+ }
51
74
52
75
// New creates a new instance of the default VSCC
53
- // Typically this will only be invoked once per peer
54
- func New (c Capabilities , s StateFetcher , d IdentityDeserializer , pe PolicyEvaluator ) * Validator {
76
+ // Typically this will only be invoked once per peer.
77
+ func New (c vc. Capabilities , s vs. StateFetcher , d vi. IdentityDeserializer , pe vp. PolicyEvaluator ) * Validator {
55
78
return & Validator {
56
79
capabilities : c ,
57
80
stateFetcher : s ,
@@ -63,16 +86,16 @@ func New(c Capabilities, s StateFetcher, d IdentityDeserializer, pe PolicyEvalua
63
86
// Validator implements the default transaction validation policy,
64
87
// which is to check the correctness of the read-write set and the endorsement
65
88
// signatures against an endorsement policy that is supplied as argument to
66
- // every invoke
89
+ // every invoke.
67
90
type Validator struct {
68
- deserializer IdentityDeserializer
69
- capabilities Capabilities
70
- stateFetcher StateFetcher
71
- policyEvaluator PolicyEvaluator
91
+ deserializer vi. IdentityDeserializer
92
+ capabilities vc. Capabilities
93
+ stateFetcher vs. StateFetcher
94
+ policyEvaluator vp. PolicyEvaluator
72
95
}
73
96
74
97
// Validate validates the given envelope corresponding to a transaction with an endorsement
75
- // policy as given in its serialized form
98
+ // policy as given in its serialized form.
76
99
func (vscc * Validator ) Validate (
77
100
block * common.Block ,
78
101
namespace string ,
@@ -147,7 +170,7 @@ func (vscc *Validator) Validate(
147
170
return nil
148
171
}
149
172
150
- // checkInstantiationPolicy evaluates an instantiation policy against a signed proposal
173
+ // checkInstantiationPolicy evaluates an instantiation policy against a signed proposal.
151
174
func (vscc * Validator ) checkInstantiationPolicy (chainName string , env * common.Envelope , instantiationPolicy []byte , payl * common.Payload ) commonerrors.TxValidationError {
152
175
// get the signature header
153
176
shdr , err := protoutil .GetSignatureHeader (payl .Header .SignatureHeader )
@@ -214,7 +237,7 @@ func validateNewCollectionConfigs(newCollectionConfigs []*common.CollectionConfi
214
237
return nil
215
238
}
216
239
217
- // validateSpOrConcat checks if the supplied signature policy is just an OR-concatenation of identities
240
+ // validateSpOrConcat checks if the supplied signature policy is just an OR-concatenation of identities.
218
241
func validateSpOrConcat (sp * common.SignaturePolicy ) error {
219
242
if sp .GetNOutOf () == nil {
220
243
return nil
@@ -329,13 +352,13 @@ func validateCollectionName(collectionName string) error {
329
352
330
353
// validateRWSetAndCollection performs validation of the rwset
331
354
// of an LSCC deploy operation and then it validates any collection
332
- // configuration
355
+ // configuration.
333
356
func (vscc * Validator ) validateRWSetAndCollection (
334
357
lsccrwset * kvrwset.KVRWSet ,
335
358
cdRWSet * ccprovider.ChaincodeData ,
336
359
lsccArgs [][]byte ,
337
360
lsccFunc string ,
338
- ac Capabilities ,
361
+ ac vc. Capabilities ,
339
362
channelName string ,
340
363
) commonerrors.TxValidationError {
341
364
/********************************************/
@@ -455,7 +478,7 @@ func (vscc *Validator) ValidateLSCCInvocation(
455
478
env * common.Envelope ,
456
479
cap * pb.ChaincodeActionPayload ,
457
480
payl * common.Payload ,
458
- ac Capabilities ,
481
+ ac vc. Capabilities ,
459
482
) commonerrors.TxValidationError {
460
483
cpp , err := protoutil .GetChaincodeProposalPayload (cap .ChaincodeProposalPayload )
461
484
if err != nil {
@@ -776,10 +799,10 @@ func (vscc *Validator) deduplicateIdentity(cap *pb.ChaincodeActionPayload) ([]*p
776
799
}
777
800
778
801
type state struct {
779
- State
802
+ vs. State
780
803
}
781
804
782
- // GetState retrieves the value for the given key in the given namespace
805
+ // GetState retrieves the value for the given key in the given namespace.
783
806
func (s * state ) GetState (namespace string , key string ) ([]byte , error ) {
784
807
values , err := s .GetStateMultipleKeys (namespace , []string {key })
785
808
if err != nil {
0 commit comments