@@ -141,8 +141,8 @@ directory.
141
141
configtxgen -profile TwoOrgs -outputCreateChannelTx < cfg txn name> -channelID < channel-id>
142
142
# example: configtxgen -profile TwoOrgs -outputCreateChannelTx channel.tx -channelID mychannel
143
143
144
- Run the end-to-end test
145
- -----------------------
144
+ Run the end-to-end test with Docker
145
+ -----------------------------------
146
146
147
147
Make sure you are in the ``/e2e_cli `` directory. Then use docker-compose
148
148
to spawn the network entities and drive the tests.
@@ -305,8 +305,8 @@ output from each container:
305
305
ex02 Invoke
306
306
Query Response:{" Name" :" a" ," Amount" :" 90" }
307
307
308
- Manually create the channel and join peers through CLI
309
- ------------------------------------------------------
308
+ Run the end-to-end test manually with Docker
309
+ --------------------------------------------
310
310
311
311
From your vagrant environment exit the currently running containers:
312
312
@@ -369,15 +369,18 @@ Command syntax
369
369
370
370
Refer to the create and join commands in the ``script.sh ``.
371
371
372
- For any of the following commands to work, you need to preface the
373
- commands with the following environment variables.
372
+ For the following CLI commands against `peer0 ` to work, you need to set the
373
+ values for four environment variables, given below. Please make sure to override
374
+ the values accordingly when calling commands against other peers and the
375
+ orderer.
374
376
375
377
.. code :: bash
376
378
377
379
# Environment variables for PEER0
378
380
CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer0/localMspConfig
379
381
CORE_PEER_ADDRESS=peer0:7051
380
382
CORE_PEER_LOCALMSPID=" Org0MSP"
383
+ CORE_PEER_TLS_ROOTCERT_FILE=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer0/localMspConfig/cacerts/peerOrg0.pem
381
384
382
385
These environment variables for each peer are defined in the supplied
383
386
docker-compose file.
@@ -406,18 +409,20 @@ with a different name.
406
409
407
410
# the channel.tx and orderer.block are mounted in the crypto/orderer folder within your cli container
408
411
# as a result, we pass the full path for the file
409
- peer channel create -o orderer :7050 -c mychannel -f crypto/orderer/channel.tx
412
+ peer channel create -o orderer0 :7050 -c mychannel -f crypto/orderer/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem
410
413
411
- Recall that the environment variables are required for this manual
412
- operation . So the command in its entirety would be:
414
+ Since the ` channel create ` runs against the orderer, we need to override the
415
+ four environment variables set before . So the above command in its entirety would be:
413
416
414
417
.. code :: bash
415
418
416
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer0/localMspConfig CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_LOCALMSPID=" Org0MSP" peer channel create -o orderer:7050 -c mychannel -f crypto/orderer/channel.tx
419
+ CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig CORE_PEER_LOCALMSPID=" OrdererMSP" peer channel create -o orderer0:7050 -c mychannel -f crypto/orderer/channel.tx --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem
420
+
417
421
418
422
**Note **: You will remain in the CLI container for the remainder of
419
423
these manual commands. You must also remember to preface all commands
420
- with the corresponding env variables for the targeted peer.
424
+ with the corresponding environment variables for targetting a peer other than
425
+ `peer0 `.
421
426
422
427
Join channel
423
428
^^^^^^^^^^^^
@@ -426,14 +431,12 @@ Join specific peers to the channel
426
431
427
432
.. code :: bash
428
433
434
+ # By default, this joins PEER0 only
429
435
# the mychannel.block is also mounted in the crypto/orderer directory
430
436
peer channel join -b mychannel.block
431
437
432
- This command in its entirety would be:
433
-
434
- .. code :: bash
435
-
436
- CORE_PEER_MSPCONFIGPATH=/opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/peer/peer0/localMspConfig CORE_PEER_ADDRESS=peer0:7051 CORE_PEER_LOCALMSPID=" Org0MSP" peer channel join -b crypto/orderer/mychannel.block
438
+ You can make other peers join the channel as necessary by making appropriate
439
+ changes in the four environment variables.
437
440
438
441
Install chaincode onto a remote peer
439
442
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -450,13 +453,12 @@ Instantiate chaincode and define the endorsement policy
450
453
Instantiate the chaincode on a peer. This will launch a chaincode
451
454
container for the targeted peer and set the endorsement policy for the
452
455
chaincode. In this snippet, we define the policy as requiring an
453
- endorsement from one peer node that is a part of Org1. In our scenario,
454
- this is `` PEER2 `` or `` PEER3 ``
456
+ endorsement from one peer node that is a part of either ` Org0 ` or ` Org1 `.
457
+ The command is:
455
458
456
459
.. code :: bash
457
460
458
- #
459
- peer chaincode instantiate -o orderer:7050 -C mychannel -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c ' {"Args":["init","a", "100", "b","200"]}' -P " AND('Org1MSP.member')"
461
+ peer chaincode instantiate -o orderer0:7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c ' {"Args":["init","a", "100", "b","200"]}' -P " OR ('Org0MSP.member','Org1MSP.member')"
460
462
461
463
See the `endorsement
462
464
policies <http://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies/> `__
@@ -467,7 +469,7 @@ Invoke chaincode
467
469
468
470
.. code :: bash
469
471
470
- peer chaincode invoke -o orderer :7050 -C mychannel -n mycc -c ' {"Args":["invoke","a","b","10"]}'
472
+ peer chaincode invoke -o orderer0 :7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n mycc -c ' {"Args":["invoke","a","b","10"]}'
471
473
472
474
**NOTE **: Make sure to wait a few seconds for the operation to complete.
473
475
@@ -484,8 +486,8 @@ The result of the above command should be as below:
484
486
485
487
Query Result: 90
486
488
487
- Using the native binaries
488
- -------------------------
489
+ Run the end-to-end test using the native binaries
490
+ -------------------------------------------------
489
491
490
492
Open your vagrant environment:
491
493
@@ -568,7 +570,7 @@ Ask peer to create a channel with the configuration parameters in
568
570
569
571
.. code :: bash
570
572
571
- peer channel create -o orderer :7050 -c mychannel -f channel.tx
573
+ peer channel create -o 127.0.0.1 :7050 -c mychannel -f channel.tx
572
574
573
575
This will return a channel genesis block - ``mychannel.block `` - in your
574
576
current directory.
@@ -589,7 +591,7 @@ Install chaincode on the peer:
589
591
590
592
.. code :: bash
591
593
592
- peer chaincode install -o orderer :7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
594
+ peer chaincode install -o 127.0.0.1 :7050 -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02
593
595
594
596
Make sure the chaincode is in the filesystem:
595
597
@@ -606,7 +608,7 @@ Instantiate the chaincode:
606
608
607
609
.. code :: bash
608
610
609
- peer chaincode instantiate -o orderer :7050 -C mychannel -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c ' {"Args":["init","a", "100", "b","200"]}'
611
+ peer chaincode instantiate -o 127.0.0.1 :7050 -C mychannel -n mycc -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/chaincode_example02 -c ' {"Args":["init","a", "100", "b","200"]}'
610
612
611
613
Check your active containers:
612
614
@@ -628,7 +630,7 @@ Issue an invoke to move "10" from "a" to "b":
628
630
629
631
.. code :: bash
630
632
631
- peer chaincode invoke -o orderer :7050 -C mychannel -n mycc -c ' {"Args":["invoke","a","b","10"]}'
633
+ peer chaincode invoke -o 127.0.0.1 :7050 -C mychannel -n mycc -c ' {"Args":["invoke","a","b","10"]}'
632
634
633
635
Wait a few seconds for the operation to complete
634
636
@@ -640,7 +642,7 @@ Query for the value of "a":
640
642
.. code :: bash
641
643
642
644
# this should return 90
643
- peer chaincode query -o orderer :7050 -C mychannel -n mycc -c ' {"Args":["query","a"]}'
645
+ peer chaincode query -o 127.0.0.1 :7050 -C mychannel -n mycc -c ' {"Args":["query","a"]}'
644
646
645
647
Don't forget to clear ledger folder ``/var/hyperledger/ `` after each
646
648
run!
@@ -691,29 +693,27 @@ capabilities you will need to use a chaincode that has data modeled as JSON,
691
693
692
694
Install, instantiate, invoke, and query *marbles02 * chaincode by following the
693
695
same general steps outlined above for *chaincode_example02 * in the **Manually
694
- create the channel and join peers through CLI ** section . After the **Join
696
+ create the channel and join peers through CLI ** section. After the **Join
695
697
channel ** step, use the following steps to interact with the *marbles02 *
696
- chaincode:
698
+ chaincode:
697
699
698
- - Install and instantiate the chaincode in ``peer0 `` (replace ``$ORDERER_IP ``
699
- with the IP address of the orderer. One way to find the address is with the
700
- command ``docker inspect orderer | grep \"IPAddress\" ``):
700
+ - Install and instantiate the chaincode in ``peer0 ``:
701
701
702
702
.. code :: bash
703
703
704
- peer chaincode install -o $ORDERER_IP :7050 -n marbles -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/marbles02
705
- peer chaincode instantiate -o $ORDERER_IP :7050 -C $ mychannel -n marbles -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/marbles02 -c ' {"Args":["init"]}' -P " OR ('Org0MSP.member','Org1MSP.member')"
704
+ peer chaincode install -o orderer0 :7050 -n marbles -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/marbles02
705
+ peer chaincode instantiate -o orderer0 :7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -v 1.0 -p github.com/hyperledger/fabric/examples/chaincode/go/marbles02 -c ' {"Args":["init"]}' -P " OR ('Org0MSP.member','Org1MSP.member')"
706
706
707
707
- Create some marbles and move them around:
708
708
709
709
.. code :: bash
710
710
711
- peer chaincode invoke -o $ORDERER_IP :7050 -C mychannel -n marbles -c ' {"Args":["initMarble","marble1","blue","35","tom"]}'
712
- peer chaincode invoke -o $ORDERER_IP :7050 -C mychannel -n marbles -c ' {"Args":["initMarble","marble2","red","50","tom"]}'
713
- peer chaincode invoke -o $ORDERER_IP :7050 -C mychannel -n marbles -c ' {"Args":["initMarble","marble3","blue","70","tom"]}'
714
- peer chaincode invoke -o $ORDERER_IP :7050 -C mychannel -n marbles -c ' {"Args":["transferMarble","marble2","jerry"]}'
715
- peer chaincode invoke -o $ORDERER_IP :7050 -C mychannel -n marbles -c ' {"Args":["transferMarblesBasedOnColor","blue","jerry"]}'
716
- peer chaincode invoke -o $ORDERER_IP :7050 -C mychannel -n marbles -c ' {"Args":["delete","marble1"]}'
711
+ peer chaincode invoke -o orderer0 :7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c ' {"Args":["initMarble","marble1","blue","35","tom"]}'
712
+ peer chaincode invoke -o orderer0 :7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c ' {"Args":["initMarble","marble2","red","50","tom"]}'
713
+ peer chaincode invoke -o orderer0 :7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c ' {"Args":["initMarble","marble3","blue","70","tom"]}'
714
+ peer chaincode invoke -o orderer0 :7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c ' {"Args":["transferMarble","marble2","jerry"]}'
715
+ peer chaincode invoke -o orderer0 :7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c ' {"Args":["transferMarblesBasedOnColor","blue","jerry"]}'
716
+ peer chaincode invoke -o orderer0 :7050 --tls $CORE_PEER_TLS_ENABLED --cafile /opt/gopath/src/github.com/hyperledger/fabric/peer/crypto/orderer/localMspConfig/cacerts/ordererOrg0.pem -C mychannel -n marbles -c ' {"Args":["delete","marble1"]}'
717
717
718
718
719
719
@@ -723,12 +723,12 @@ chaincode:
723
723
724
724
For containers running in a vagrant environment:
725
725
726
- ``` http://localhost:15984/_utils` ``
726
+ ``http://localhost:15984/_utils ``
727
727
728
728
For non-vagrant environment, use the port address that was mapped in CouchDB
729
729
container specification:
730
730
731
- ``` http://localhost:5984/_utils` ``
731
+ ``http://localhost:5984/_utils ``
732
732
733
733
You should see a database named ``mychannel `` and the documents
734
734
inside it.
@@ -737,7 +737,7 @@ chaincode:
737
737
738
738
.. code :: bash
739
739
740
- peer chaincode query -o $ORDERER_IP :7050 - C mychannel -n marbles -c ' {"Args":["readMarble","marble2"]}'
740
+ peer chaincode query -C mychannel -n marbles -c ' {"Args":["readMarble","marble2"]}'
741
741
742
742
743
743
You should see the details of ``marble2 ``:
@@ -751,7 +751,7 @@ chaincode:
751
751
752
752
.. code :: bash
753
753
754
- peer chaincode query -o $ORDERER_IP :7050 - C mychannel -n marbles -c ' {"Args":["getHistoryForMarble","marble1"]}'
754
+ peer chaincode query -C mychannel -n marbles -c ' {"Args":["getHistoryForMarble","marble1"]}'
755
755
756
756
You should see the transactions on ``marble1 ``:
757
757
@@ -765,7 +765,7 @@ chaincode:
765
765
766
766
.. code :: bash
767
767
768
- peer chaincode query -o $ORDERER_IP :7050 -C myc1 -n marbles -c ' {"Args":["queryMarblesByOwner","jerry"]}'
768
+ peer chaincode query -C mychannel -n marbles -c ' {"Args":["queryMarblesByOwner","jerry"]}'
769
769
770
770
The output should display the two marbles owned by ``jerry ``:
771
771
@@ -777,7 +777,7 @@ chaincode:
777
777
778
778
.. code :: bash
779
779
780
- peer chaincode query -o $ORDERER_IP :7050 -C myc1 -n marbles -c ' {"Args":["queryMarbles","{\"selector\":{\"owner\":\"jerry\"}}"]}'
780
+ peer chaincode query -C mychannel -n marbles -c ' {"Args":["queryMarbles","{\"selector\":{\"owner\":\"jerry\"}}"]}'
781
781
782
782
The output should display:
783
783
0 commit comments