Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FABGW-6 Enchance scenario tests for discovery #31

Merged
merged 1 commit into from
Jan 8, 2021

Conversation

andrew-coleman
Copy link
Member

Enhance the cucumber test framework to allow discovery testing.
Test network now comprises 5 peers across 3 orgs
Peers can be stopped and started to test different signature policy scenarios

Signed-off-by: andrew-coleman andrew_coleman@uk.ibm.com

Copy link
Member

@bestbeforetoday bestbeforetoday left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there are a couple of things worth tweaking but the starting/stopping of peers in the tests is great. I like moving the expected fail to the transaction invocation too, so we can resubmit exactly the same transaction after restarting peers.

.gitignore Outdated
@@ -5,3 +5,6 @@ cover.out
fabric-protos/
protos/gateway.pb.go
protos/gateway_grpc.pb.go
node/src/protos/protos.js
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything in node/src/protos should already be covered by node/.gitignore so no need for it here

java/pom.xml Outdated
@@ -239,10 +239,11 @@
<show>public</show>
<doctitle>Hyperledger Fabric Gateway SDK for Java</doctitle>
<nohelp>true</nohelp>
<failOnError>true</failOnError>
<failOnError>false</failOnError>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't leave it allowing Javadoc build failures

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, didn't mean to commit this!

endorsers := gs.registry.GetEndorsers(proposedTransaction.ChannelId)
channel, chaincodeID, err := getChannelAndChaincodeFromSignedProposal(proposedTransaction.Proposal)
if err != nil {
return nil, errors.Wrap(err, "Failed to unpack channel header: ")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure we should be continuing to use the github.com/pkg/errors package. It seems to be effectively deprecated and the wrapping of errors was introduced into the core Go libraries in v1.13: https://blog.golang.org/go1.13-errors

}

func getChannelHeaderFromSignedProposal(signedProposal *peer.SignedProposal) (*common.ChannelHeader, error) {
func getChannelAndChaincodeFromSignedProposal(signedProposal *peer.SignedProposal) (string, string, error) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The channel name is a top-level property of the ProposedTransaction so we don't need to deserialise and dig into the proposal to get it. I guess we should either:

  1. Also move the chaincode name to the top-level of the ProposedTransaction, which means we can save a whole bunch of expensive deserialisation on the proposals within the Gateway; or
  2. Just take the hit on deserialising the proposal and remove any ProposedTransaction properties that are duplicates of content in the proposal for simplicity.

But we could do that work outside of this PR, just as long as we actually do it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, this will all need revisiting anyway when we decide exactly what goes into the top-level message


require (
github.com/hyperledger/fabric-contract-api-go v1.1.1
github.com/pkg/errors v0.9.1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As per previous comments, I'm not sure it's a good idea to use this package when the core libraries give us similar functionality

exec("docker", "start", peer);
} catch (IOException e) {
e.printStackTrace();
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this fails the tests are broken so I think we'd be better throwing an Exception and failing fast instead of continuing on for the tests to behave unexpectedly later

"--sequence", "1",
"--waitForEvent",
"--peerAddresses", "peer0.org1.example.com:7051",
"--peerAddresses",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we also need org3 here now we're a 3 org network?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add it, but don't need to. It just needs a majority of endorsers

const transaction = await proposal.endorse();
this.txn.result = await transaction.submit();
} else {
//throw new Error(`Unknown transaction type: ${this.txn.type}`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are broken if we get here so we should throw

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, most of this function is a duplicate of the implementation of When('I invoke the transaction'). Perhaps we could factor out some common code

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tests are broken if we get here so we should throw

It will throw, but admittedly with a misleading message - I'll fix that.

@bestbeforetoday
Copy link
Member

There is some overlap with #32. Your call on which one looks easier to get in first and rebase the other one on.

Enhance the cucumber test framework to allow discovery testing.
Test network now comprises 5 peers across 3 orgs
Peers can be stopped and started to test different signature policy scenarios

Signed-off-by: andrew-coleman <andrew_coleman@uk.ibm.com>
@bestbeforetoday bestbeforetoday merged commit 9d7b10e into hyperledger:master Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants