This repository has been archived by the owner on Jun 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #167 from thanethomson/issues/154
Add Tendermint test harness to KMS integration test
- Loading branch information
Showing
4 changed files
with
123 additions
and
11 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
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,35 @@ | ||
#!/bin/bash | ||
|
||
PWD=`pwd` | ||
TMHOME=${TMHOME:-${PWD}} | ||
OUTPUT_PATH=${OUTPUT_PATH:-${PWD}} | ||
GENESIS_FILE=${GENESIS_FILE:-${TMHOME}/config/genesis.json} | ||
SIGNING_KEY=${SIGNING_KEY:-${OUTPUT_PATH}/signing.key} | ||
SECRET_KEY=${SECRET_KEY:-${OUTPUT_PATH}/secret_connection.key} | ||
OUTPUT_FILE=${OUTPUT_FILE:-${OUTPUT_PATH}/tmkms.toml} | ||
VALIDATOR_ADDR=${VALIDATOR_ADDR:-"tcp://127.0.0.1:61278"} | ||
CFG_TEMPLATE=$(cat <<-EOF | ||
[[validator]] | ||
addr = "VALIDATOR_ADDR" | ||
chain_id = "CHAIN_ID" | ||
reconnect = true # true is the default | ||
secret_key = "SECRET_KEY" | ||
[[providers.softsign]] | ||
id = "CHAIN_ID" | ||
path = "SIGNING_KEY" | ||
EOF | ||
) | ||
|
||
# First extract the chain ID from the genesis file | ||
CHAIN_ID_SED_EXPR='s/[ ]*"chain_id":[ ]*"\([^"]*\)".*/\1/' | ||
CHAIN_ID=`grep '"chain_id"' ${GENESIS_FILE} | sed "${CHAIN_ID_SED_EXPR}"` | ||
|
||
# Now generate the tmkms.toml file | ||
echo "${CFG_TEMPLATE}" | \ | ||
sed "s|CHAIN_ID|${CHAIN_ID}|g" | \ | ||
sed "s|VALIDATOR_ADDR|${VALIDATOR_ADDR}|g" | \ | ||
sed "s|SECRET_KEY|${SECRET_KEY}|g" | \ | ||
sed "s|SIGNING_KEY|${SIGNING_KEY}|g" > ${OUTPUT_FILE} | ||
|
||
echo "Wrote ${OUTPUT_FILE}" |
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,30 @@ | ||
#!/bin/bash | ||
TMKMS_BIN=${TMKMS_BIN:-"./target/debug/tmkms"} | ||
TMKMS_CONFIG=${TMKMS_CONFIG:-"/remote_val_harness/tmkms.toml"} | ||
REMOTE_VAL_HARNESS_BIN=${REMOTE_VAL_HARNESS_BIN:-"remote_val_harness"} | ||
TMHOME=${TMHOME:-"/remote_val_harness"} | ||
|
||
# Run KMS in the background | ||
${TMKMS_BIN} start -c ${TMKMS_CONFIG} & | ||
TMKMS_PID=$! | ||
|
||
# Run the test harness in the foreground | ||
${REMOTE_VAL_HARNESS_BIN} run \ | ||
--addr tcp://127.0.0.1:61278 \ | ||
--genesis-file ${TMHOME}/config/genesis.json \ | ||
--key-file ${TMHOME}/config/priv_validator_key.json \ | ||
--state-file ${TMHOME}/data/priv_validator_state.json | ||
HARNESS_EXIT_CODE=$? | ||
|
||
# Kill the KMS, if it's still running | ||
if ps -p ${TMKMS_PID} > /dev/null | ||
then | ||
echo "Killing KMS (pid ${TMKMS_PID})" | ||
kill ${TMKMS_PID} | ||
else | ||
echo "KMS (pid ${TMKMS_PID}) already stopped, not killing" | ||
fi | ||
|
||
# Bubble the exit code up out of the script | ||
echo "Harness tests exiting with code ${HARNESS_EXIT_CODE}" | ||
exit ${HARNESS_EXIT_CODE} |