Skip to content

Commit

Permalink
[FAB-8950]: Remove env from txVSCCValidator
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
C0rWin committed Mar 19, 2018
1 parent bb5ad88 commit d2b5aed
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 27 deletions.
21 changes: 0 additions & 21 deletions core/committer/txvalidator/txvalidator_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,27 +81,6 @@ func testValidationWithNTXes(t *testing.T, ledger ledger2.PeerLedger, gbHash []b
for i := 0; i < nBlocks; i++ {
assert.True(t, txsfltr.IsSetTo(i, peer.TxValidationCode_VALID))
}

/*
a better way of testing this without all of the mocking was
implemented in validator_test.go
newMockVsccValidator := &validator.MockVsccValidator{
CIns: upgradeChaincodeIns,
RespPayl: prespPaylBytes,
}
newTxValidator := &txValidator{&mocktxvalidator.Support{LedgerVal: ledger}, newMockVsccValidator}
// generate new block
newBlock := testutil.ConstructBlock(t, 2, block.Header.Hash(), [][]byte{simRes}, true) // contains one tx with chaincode version v1
newTxValidator.Validate(newBlock)
// tx should be invalided because of chaincode upgrade
txsfltr = util.TxValidationFlags(newBlock.Metadata.Metadata[common.BlockMetadataIndex_TRANSACTIONS_FILTER])
assert.True(t, txsfltr.IsSetTo(0, peer.TxValidationCode_EXPIRED_CHAINCODE))
*/
}

func TestDetectTXIdDuplicates(t *testing.T) {
Expand Down
10 changes: 5 additions & 5 deletions core/committer/txvalidator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ type Validator interface {
// and vscc execution, in order to increase
// testability of txValidator
type vsccValidator interface {
VSCCValidateTx(payload *common.Payload, envBytes []byte, env *common.Envelope) (error, peer.TxValidationCode)
VSCCValidateTx(payload *common.Payload, envBytes []byte) (error, peer.TxValidationCode)
}

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

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

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

// get header extensions so we have the chaincode ID
hdrExt, err := utils.GetChaincodeHeaderExtension(payload.Header)
Expand Down
2 changes: 1 addition & 1 deletion core/mocks/validator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ type MockVsccValidator struct {
}

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

0 comments on commit d2b5aed

Please sign in to comment.