-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[FAB-6229] validator accepts RESOURCE_UPDATE txes
This change set introudces support (and tests) to handle incoming txes with the new type HeaderType_PEER_RESOURCE_UPDATE. Change-Id: I12e615a911d9210cf5dbb696d4f9ff03d166d60c Signed-off-by: Alessandro Sorniotti <ale.linux@sopit.net>
- Loading branch information
Showing
7 changed files
with
137 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
Copyright IBM Corp. 2016 All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package validation | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/docker/docker/pkg/testutil/assert" | ||
"github.com/hyperledger/fabric/common/mocks/config" | ||
"github.com/hyperledger/fabric/common/util" | ||
cb "github.com/hyperledger/fabric/protos/common" | ||
"github.com/hyperledger/fabric/protos/peer" | ||
"github.com/hyperledger/fabric/protos/utils" | ||
) | ||
|
||
func TestValidateResourceUpdateTx(t *testing.T) { | ||
chainID := util.GetTestChainID() | ||
|
||
updateResult := &cb.Envelope{ | ||
Payload: utils.MarshalOrPanic(&cb.Payload{Header: &cb.Header{ | ||
ChannelHeader: utils.MarshalOrPanic(&cb.ChannelHeader{ | ||
Type: int32(cb.HeaderType_PEER_RESOURCE_UPDATE), | ||
ChannelId: chainID, | ||
}), | ||
SignatureHeader: utils.MarshalOrPanic(&cb.SignatureHeader{ | ||
Creator: signerSerialized, | ||
Nonce: utils.CreateNonceOrPanic(), | ||
}), | ||
}, | ||
Data: utils.MarshalOrPanic(&cb.ConfigEnvelope{LastUpdate: &cb.Envelope{}}), | ||
}), | ||
} | ||
updateResult.Signature, _ = signer.Sign(updateResult.Payload) | ||
_, txResult := ValidateTransaction(updateResult, &config.MockApplicationCapabilities{}) | ||
assert.Equal(t, txResult, peer.TxValidationCode_UNSUPPORTED_TX_PAYLOAD) | ||
_, txResult = ValidateTransaction(updateResult, &config.MockApplicationCapabilities{LifecycleViaConfigRv: true}) | ||
assert.Equal(t, txResult, peer.TxValidationCode_VALID) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters