Skip to content

Commit

Permalink
fix(validator,example): fix bugs of sample code and README of validators
Browse files Browse the repository at this point in the history
Signed-off-by: KeitaieK <keita-cheers@jp.fujitsu.com>
  • Loading branch information
KeitatieK authored and takeutak committed Dec 4, 2020
1 parent dcdfcf5 commit 83f93da
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 6 deletions.
5 changes: 3 additions & 2 deletions packages/ledger-plugin/fabric/validator/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
- Specify URL of the ledger node to connect to in "PluginConfig.js"

## Execution
<pre>
```
./setup.sh
cd core
node ./bin/www.js
</pre>
```
80 changes: 80 additions & 0 deletions packages/ledger-plugin/fabric/validator/unit-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<!--
Copyright 2020 Fujitsu Ltd.
SPDX-License-Identifier: Apache-2.0
README.md
-->

# Validator Driver

## The point of this document
This document describes the procedures for runnning fabric validator unit-test.

## Assumption
- Validator for fabric ledger is already running
- ProcedureURL: https://github.com/hyperledger/cactus/blob/master/packages/ledger-plugin/fabric/validator/src/README.md
- The fabcar container is already running
- ProcedureURL: https://github.com/hyperledger/cactus/blob/master/packages/ledger-plugin/fabric/validator/unit-test/fabric-docker/README.md

## (a) Get car information
- Target source: "queryCar.js"
- This script is for getting car information recorded in fabcar.

1) Run
<pre>
node queryCar.js</pre>

- Sample output
<pre>
Transaction has been evaluated, result is: [{"Key":"CAR0", "Record":{"colour":"blue","make":"Toyota","model":"Prius","owner":"Tomoko"}},{"Key":"CAR1", "Record":{"colour":"red","make":"Ford","model":"Mustang","owner":"Brad"}},{"Key":"CAR2", "Record":{"colour":"green","make":"Hyundai","model":"Tucson","owner":"Jin Soo"}},{"Key":"CAR3", "Record":{"colour":"yellow","make":"Volkswagen","model":"Passat","owner":"Max"}},{"Key":"CAR4", "Record":{"colour":"black","make":"Tesla","model":"S","owner":"Adriana"}},{"Key":"CAR5", "Record":{"colour":"purple","make":"Peugeot","model":"205","owner":"Michel"}},{"Key":"CAR6", "Record":{"colour":"white","make":"Chery","model":"S22L","owner":"Aarav"}},{"Key":"CAR7", "Record":{"colour":"violet","make":"Fiat","model":"Punto","owner":"Pari"}},{"Key":"CAR8", "Record":{"colour":"indigo","make":"Tata","model":"Nano","owner":"Valeria"}},{"Key":"CAR9", "Record":{"colour":"brown","make":"Holden","model":"Barina","owner":"Shotaro"}}]</pre>

## (b) Asset transfer
- Target source: "validatorDriver_signTransactionOffline.js"
- This script is for changing owner information.

1) Check the private key of wallet/admin
- Get the filename which is replaced `-pub` with `-priv` in `unit-test/wallet/admin/`.
<pre>
$ find (fabric unit-test path)/wallet/admin/ -type f -name '*-pub' | sed -e "s/-pub\$/-priv/"
6adbd1d5df2852efc1447f91effadbc2c8b5f1c6577c644441905f05e9551018-priv</pre>


2) Specify the parameters in the target source
- Before
<pre>
const privateKeyPath = walletPath + '/admin/39dff34541b3ebc034474ed3b68cde6477f319bd67d01bb771e99b6f7595b4cf-priv';</pre>

- After
<pre>
const privateKeyPath = walletPath + '/admin/< xxx-priv checked by step1 >';</pre>


3) Run
<pre>
node validatorDriver_sendSignedTransaction.js </pre>

- Sample output
<pre>
keita@keita-VirtualBox:~/cactusProject/cactus/packages/ledger-plugin/fabric/validator/unit-test$ node validatorDriver_signTransactionOffline.js
validatorUrl: https://localhost:5040
##exec requestStartMonitor()
exec sendRequest()
#[send]requestData: {"func":"changeCarOwner","args":{"carId":"CAR101","newOwner":"Charlie"}}
setupChannel start
tlssetup start
#[recv]eventReceived, res: {"status":200,"blockData":[]}
{
fcn: 'changeCarOwner',
args: [ 'CAR101', 'Charlie' ],
chaincodeId: 'fabcar',
channelId: 'mychannel'
}
proposal end
##txId: 2a143227120188314fe2255ac22192f85ddb6af80a715f2f64f5d02ad052d8aa
signProposal start
successfully send signedProposal
Successfully build commit transaction proposal
signProposal start
Successfully build endorse transaction proposal
emit request
#[recv]eventReceived, res: {"status":200,"blockData":[]}
##exec requestStopMonitor()</pre>
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,13 @@ Copy and extract wallet.tar to the following target directory:

$ tar xvf wallet.tar

## Remarks

- According to the report from some contributor, in some environment the command `curl -sSL https://bit.ly/2ysbOFE | bash -s -- 1.4.0 1.4.0` fails to download coachdb and the following steps are failed. If you encount the same situation, please execute the commands instead of that:
```
curl -sSL https://bit.ly/2ysbOFE | bash -s -- 1.4.0 1.4.0
docker pull hyperledger/fabric-couchdb:0.4.14
docker tag hyperledger/fabric-couchdb:0.4.14 hyperledger/fabric-couchdb:latest
```


Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const walletPath = path.resolve(__dirname, 'wallet');

//Key and certificate issued by msp (User1@example.com)
//const basic_network_path = "./fabric-docker/basic-network";
const basic_network_path = path.resolve(__dirname, 'fabric-docker/basic-network');
const basic_network_path = path.resolve(__dirname, 'fabric-docker/fabric-samples/basic-network');
const privateKeyPath0 = basic_network_path + '/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/keystore/c75bd6911aca808941c3557ee7c97e90f3952e379497dc55eb903f31b50abc83_sk';
const privateKeyPem0 = fs.readFileSync(privateKeyPath0, 'utf8');
const certPath0 = basic_network_path + '/crypto-config/peerOrganizations/org1.example.com/users/User1@org1.example.com/msp/signcerts/User1@org1.example.com-cert.pem';
Expand Down Expand Up @@ -420,4 +420,3 @@ function sendRequest() {

setTimeout(requestStartMonitor, 2000); // TODO:
setTimeout(sendRequest, 4000);

5 changes: 3 additions & 2 deletions packages/ledger-plugin/go-ethereum/validator/src/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
- Specify URL of the ledger node to connect to in "provider" of "PluginConfig.js"

## Execution
<pre>
```
./setup.sh
cd core
node ./bin/www.js
</pre>
```

0 comments on commit 83f93da

Please sign in to comment.