Skip to content

Commit d2b5aed

Browse files
committed
[FAB-8950]: Remove env from txVSCCValidator
vsccValidator interface introduces VSCCVAlidate function which accepts payload, marshaled and unmarshaled transaction envelop. While there is no functional use of unmarshaled Envelop except for using in debug message. This commit removes this parameter from declaration due its redundancy. Change-Id: I280854768b5c4e67104ebb4e6ff06852eb2fea7e Signed-off-by: Artem Barger <bartem@il.ibm.com>
1 parent bb5ad88 commit d2b5aed

File tree

3 files changed

+6
-27
lines changed

3 files changed

+6
-27
lines changed

core/committer/txvalidator/txvalidator_test.go

-21
Original file line numberDiff line numberDiff line change
@@ -81,27 +81,6 @@ func testValidationWithNTXes(t *testing.T, ledger ledger2.PeerLedger, gbHash []b
8181
for i := 0; i < nBlocks; i++ {
8282
assert.True(t, txsfltr.IsSetTo(i, peer.TxValidationCode_VALID))
8383
}
84-
85-
/*
86-
87-
a better way of testing this without all of the mocking was
88-
implemented in validator_test.go
89-
90-
newMockVsccValidator := &validator.MockVsccValidator{
91-
CIns: upgradeChaincodeIns,
92-
RespPayl: prespPaylBytes,
93-
}
94-
newTxValidator := &txValidator{&mocktxvalidator.Support{LedgerVal: ledger}, newMockVsccValidator}
95-
96-
// generate new block
97-
newBlock := testutil.ConstructBlock(t, 2, block.Header.Hash(), [][]byte{simRes}, true) // contains one tx with chaincode version v1
98-
99-
newTxValidator.Validate(newBlock)
100-
101-
// tx should be invalided because of chaincode upgrade
102-
txsfltr = util.TxValidationFlags(newBlock.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER])
103-
assert.True(t, txsfltr.IsSetTo(0, peer.TxValidationCode_EXPIRED_CHAINCODE))
104-
*/
10584
}
10685

10786
func TestDetectTXIdDuplicates(t *testing.T) {

core/committer/txvalidator/validator.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type Validator interface {
6969
// and vscc execution, in order to increase
7070
// testability of txValidator
7171
type vsccValidator interface {
72-
VSCCValidateTx(payload *common.Payload, envBytes []byte, env *common.Envelope) (error, peer.TxValidationCode)
72+
VSCCValidateTx(payload *common.Payload, envBytes []byte) (error, peer.TxValidationCode)
7373
}
7474

7575
// vsccValidator implementation which used to call
@@ -343,7 +343,7 @@ func validateTx(req *blockValidationRequest, results chan<- *blockValidationResu
343343

344344
// Validate tx with vscc and policy
345345
logger.Debug("Validating transaction vscc tx validate")
346-
err, cde := v.vscc.VSCCValidateTx(payload, d, env)
346+
err, cde := v.vscc.VSCCValidateTx(payload, d)
347347
if err != nil {
348348
logger.Errorf("VSCCValidateTx for transaction txId = %s returned error: %s", txID, err)
349349
switch err.(type) {
@@ -641,9 +641,9 @@ func (v *vsccValidatorImpl) txWritesToNamespace(ns *rwsetutil.NsRwSet) bool {
641641
return false
642642
}
643643

644-
func (v *vsccValidatorImpl) VSCCValidateTx(payload *common.Payload, envBytes []byte, env *common.Envelope) (error, peer.TxValidationCode) {
645-
logger.Debugf("VSCCValidateTx starts for env %p envbytes %p", env, envBytes)
646-
defer logger.Debugf("VSCCValidateTx completes for env %p envbytes %p", env, envBytes)
644+
func (v *vsccValidatorImpl) VSCCValidateTx(payload *common.Payload, envBytes []byte) (error, peer.TxValidationCode) {
645+
logger.Debugf("VSCCValidateTx starts for bytes %p", envBytes)
646+
defer logger.Debugf("VSCCValidateTx completes env bytes %p", envBytes)
647647

648648
// get header extensions so we have the chaincode ID
649649
hdrExt, err := utils.GetChaincodeHeaderExtension(payload.Header)

core/mocks/validator/validator.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,6 @@ type MockVsccValidator struct {
4040
}
4141

4242
// VSCCValidateTx does nothing
43-
func (v *MockVsccValidator) VSCCValidateTx(payload *common.Payload, envBytes []byte, env *common.Envelope) (error, peer.TxValidationCode) {
43+
func (v *MockVsccValidator) VSCCValidateTx(payload *common.Payload, envBytes []byte) (error, peer.TxValidationCode) {
4444
return nil, peer.TxValidationCode_VALID
4545
}

0 commit comments

Comments
 (0)