Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

After cloning Fabric, you can can test fabric binaries using a sample configuration. Using the binaries and sample configuration makes it simple and quick to iteratively make code changes, rebuild fabric, and test your changes from an end-to-end consumer perspective.

...

Add fabric /build/bin to your PATH so that you can easily execute the binaries.
Set FABRIC_CFG_PATH to fabric /sampleconfig directory, which contains sample orderer.yaml, peer.yaml, configtx.yaml, and msp for a SampleOrg. Make sure that the listen addresses in orderer.yaml and peer.yaml do not overlap. By default, Admin.ListenAddress of orderer.yaml and operations.ListenAddress of peer.yaml are set to port 9443. It is recommended to change the port of operations.ListenAddress to 9444.

Open three terminal windows, one each for orderer, peer, and CLI. cd to /fabric directory in each terminal.

...

   peer chaincode invoke -o 127.0.0.1:7050 -C mychannel -n marbles -c '{"Args":["initMarble","marble1","blue","35","tom"]}' --waitForEvent

...

   peer chaincode invoke -o 127.0.0.1:7050 -C mychannel -n marbles -c '{"Args":["transferMarble","marble1","jerry"]}' --waitForEvent

...

Cleanup data, chaincode containers and images

rm -rf /var/hyperledger/production/

rm marbles.tar.gz
rm mychannel.*
rm sampleconfig/genesisblock

docker rm -f $(docker ps -aq)

docker rmi -f $(docker images -q --filter=reference='*dev*')


The CLI commands can be scripted or copy/pasted to expedite execution:

...

peer chaincode install -n marbles -p github.com/hyperledger/fabric/integration/chaincode/marbles/cmd-v 1
peer chaincode instantiate -C mychannel -n marbles -c '{"Args":["init"]}' -v 1 -o 127.0.0.1:7050

...