forked from hyperledger-labs/fablo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
done with initial configuration for BFT, updated the templates for th…
…e same Signed-off-by: Sanket <[email protected]>
- Loading branch information
1 parent
7db1c55
commit e98306f
Showing
7 changed files
with
162 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -eux | ||
|
||
TEST_TMP="$(rm -rf "$0.tmpdir" && mkdir -p "$0.tmpdir" && (cd "$0.tmpdir" && pwd))" | ||
TEST_LOGS="$(mkdir -p "$0.logs" && (cd "$0.logs" && pwd))" | ||
FABLO_HOME="$TEST_TMP/../../.." | ||
|
||
export FABLO_HOME | ||
|
||
CONFIG="$FABLO_HOME/fablo-config-hlf3-bft-1orgs-1chaincode.json" | ||
|
||
networkUp() { | ||
"$FABLO_HOME/fablo-build.sh" | ||
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" generate "$CONFIG") | ||
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" up) | ||
} | ||
|
||
dumpLogs() { | ||
echo "Saving logs of $1 to $TEST_LOGS/$1.log" | ||
mkdir -p "$TEST_LOGS" | ||
docker logs "$1" >"$TEST_LOGS/$1.log" 2>&1 | ||
} | ||
|
||
networkDown() { | ||
rm -rf "$TEST_LOGS" | ||
(for name in $(docker ps --format '{{.Names}}'); do dumpLogs "$name"; done) | ||
dumpLogs orderer0.group1.orderer.example.com | ||
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" down) | ||
} | ||
|
||
waitForContainer() { | ||
sh "$TEST_TMP/../wait-for-container.sh" "$1" "$2" | ||
} | ||
|
||
waitForChaincode() { | ||
(cd "$TEST_TMP" && sh ../wait-for-chaincode.sh "$1" "$2" "$3" "$4") | ||
} | ||
|
||
expectInvoke() { | ||
(cd "$TEST_TMP" && sh ../expect-invoke-cli.sh "$1" "$2" "$3" "$4" "$5" "") | ||
} | ||
|
||
expectCommand() { | ||
sh "$TEST_TMP/../expect-command.sh" "$1" "$2" | ||
} | ||
|
||
trap networkDown EXIT | ||
trap 'networkDown ; echo "Test failed" ; exit 1' ERR SIGINT | ||
|
||
# start the network | ||
networkUp | ||
|
||
waitForContainer "orderer0.group1.orderer.example.com" "Starting raft node as part of a new channel channel=my-channel1" | ||
waitForContainer "ca.org1.example.com" "Listening on https://0.0.0.0:7054" | ||
waitForContainer "peer0.org1.example.com" "Joining gossip network of channel my-channel1 with 1 organizations" | ||
waitForContainer "peer1.org1.example.com" "Joining gossip network of channel my-channel1 with 1 organizations" | ||
waitForContainer "peer0.org1.example.com" "Learning about the configured anchor peers of Org1MSP for channel my-channel1" | ||
waitForContainer "peer0.org1.example.com" "Anchor peer.*with same endpoint, skipping connecting to myself" | ||
waitForContainer "peer0.org1.example.com" "Membership view has changed. peers went online:.*peer1.org1.example.com:7042" | ||
waitForContainer "peer1.org1.example.com" "Learning about the configured anchor peers of Org1MSP for channel my-channel1" | ||
waitForContainer "peer1.org1.example.com" "Membership view has changed. peers went online:.*peer0.org1.example.com:7041" | ||
|
||
# Test simple chaincode | ||
expectInvoke "peer0.org1.example.com" "my-channel1" "chaincode1" \ | ||
'{"Args":["KVContract:put", "name", "Willy Wonka"]}' \ | ||
'{\"success\":\"OK\"}' | ||
expectInvoke "peer1.org1.example.com" "my-channel1" "chaincode1" \ | ||
'{"Args":["KVContract:get", "name"]}' \ | ||
'{\"success\":\"Willy Wonka\"}' | ||
|
||
# Verify channel query scripts | ||
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch newest my-channel1 org1 peer1) | ||
expectCommand "cat \"$TEST_TMP/newest.block\"" "KVContract:get" | ||
|
||
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch 3 my-channel1 org1 peer1 "another.block") | ||
expectCommand "cat \"$TEST_TMP/another.block\"" "KVContract:put" | ||
|
||
(cd "$TEST_TMP" && "$FABLO_HOME/fablo.sh" channel fetch config my-channel1 org1 peer1 "channel-config.json") | ||
expectCommand "cat \"$TEST_TMP/channel-config.json\"" "\"mod_policy\": \"Admins\"," | ||
|
||
expectCommand "(cd \"$TEST_TMP\" && \"$FABLO_HOME/fablo.sh\" channel getinfo my-channel1 org1 peer1)" "\"height\":5" | ||
|
||
echo "🎉 Test passed! 🎉" |
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,60 @@ | ||
{ | ||
"$schema": "https://github.com/hyperledger-labs/fablo/releases/download/2.0.0/schema.json", | ||
"global": { | ||
"fabricVersion": "3.0.0-beta", | ||
"tls": true, | ||
"monitoring": { | ||
"loglevel": "debug" | ||
} | ||
}, | ||
"orgs": [ | ||
{ | ||
"organization": { | ||
"name": "Orderer", | ||
"domain": "orderer.example.com" | ||
}, | ||
"orderers": [ | ||
{ | ||
"groupName": "group1", | ||
"type": "BFT", | ||
"instances": 4 | ||
} | ||
|
||
] | ||
}, | ||
{ | ||
"organization": { | ||
"name": "Org1", | ||
"domain": "org1.example.com" | ||
}, | ||
"peer": { | ||
"instances": 2, | ||
"db": "LevelDb" | ||
} | ||
} | ||
], | ||
"channels": [ | ||
{ | ||
"name": "my-channel1", | ||
"orgs": [ | ||
{ | ||
"name": "Org1", | ||
"peers": [ | ||
"peer0", | ||
"peer1" | ||
] | ||
} | ||
] | ||
} | ||
], | ||
"chaincodes": [ | ||
{ | ||
"name": "chaincode1", | ||
"version": "0.0.1", | ||
"lang": "node", | ||
"channel": "my-channel1", | ||
"directory": "./chaincodes/chaincode-kv-node" | ||
} | ||
] | ||
} | ||
|
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