Skip to content

Commit

Permalink
Merge pull request #300 from cheqd/DEV-705-did-validation
Browse files Browse the repository at this point in the history
[DEV-705] e2e test fixes
  • Loading branch information
askolesov authored Mar 18, 2022
2 parents 194b6d7 + e41afb1 commit b094a0b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 22 deletions.
40 changes: 20 additions & 20 deletions tests/e2e-complex/upgrade/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ CHEQD_IMAGE_TO="cheqd-cli"
# shellcheck disable=SC2034
CHEQD_VERSION_TO=$(git describe --always --tag --match "v*" | sed 's/^v//')
# shellcheck disable=SC2034
UPGRADE_NAME="v0.4"
UPGRADE_NAME="v0.5"
VOTING_PERIOD=30
EXPECTED_BLOCK_SECOND=5
EXTRA_BLOCKS=5
Expand All @@ -23,20 +23,19 @@ AMOUNT_BEFORE="19000000000000000"
CHEQ_AMOUNT="1ncheq"
CHEQ_AMOUNT_NUMBER="1"
# shellcheck disable=SC2034
DID_1="did:cheqd:testnet:abcdef"
DID_1="did:cheqd:testnet:1111111111111111"
# shellcheck disable=SC2034
DID_2="did:cheqd:testnet:higklm"
DID_2="did:cheqd:testnet:2222222222222222"

# cheqd_noded docker wrapper

cheqd_noded_docker() {
docker run --rm \
-v "$(pwd):/cheqd" \
--network host \
-u root \
-e HOME=/cheqd \
--entrypoint "cheqd-noded" \
${CHEQD_IMAGE_FROM} "$@"
docker run --rm \
-v "$(pwd):/cheqd" \
--network host \
-u root \
-e HOME=/cheqd \
--entrypoint "cheqd-noded" \
${CHEQD_IMAGE_FROM} "$@"
}

# Parameters
Expand All @@ -54,18 +53,18 @@ function docker_exec () {
function docker_compose_up () {
pushd "node_configs/node0"
NODE_0_ID=$(cheqd_noded_docker tendermint show-node-id | sed 's/\r//g')
export NODE_0_ID
export NODE_0_ID="$NODE_0_ID"
popd

export CHEQD_IMAGE_NAME="$1"
export MOUNT_POINT="$2"

docker-compose --env-file .env up -d
docker compose --env-file .env up -d
}

# Stop docker-compose
function docker_compose_down () {
docker-compose --env-file .env down
docker compose --env-file .env down
}

# Clean environment
Expand All @@ -84,7 +83,6 @@ function make_777 () {
}



# Transaction related funcs

function random_string() {
Expand All @@ -94,7 +92,8 @@ function random_string() {

function get_addresses () {
all_keys=$(local_client_tx keys list)
mapfile -t addresses < <(echo "$all_keys" | grep -o 'cheqd1.*')
# mapfile -t addresses < <(echo "$all_keys" | grep -o 'cheqd1.*')
addresses=( $(echo "$all_keys" | grep -o 'cheqd1.*') )
echo "${addresses[@]}"
}

Expand All @@ -120,7 +119,7 @@ function send_tokens() {

# Send DID
# input: DID to write
function send_did_old() {
function send_did_new () {
did_to_write=$1

# Generate Alice identity key
Expand All @@ -136,7 +135,7 @@ function send_did_old() {
MSG_CREATE_DID='{"id":"'${did_to_write}'","verification_method":[{"id":"'"${KEY_ID}"'","type":"Ed25519VerificationKey2020","controller":"'${did_to_write}'","public_key_multibase":"'${ALICE_VER_PUB_MULTIBASE_58}'"}],"authentication":["'${KEY_ID}'"]}'

# Post the message
did=$(local_client_tx tx cheqd create-did "${MSG_CREATE_DID}" "${KEY_ID}" --ver-key "${ALICE_VER_PRIV_BASE_64}" \
did=$(local_client_tx tx cheqd create-did "${MSG_CREATE_DID}" "${KEY_ID}" "${ALICE_VER_PRIV_BASE_64}" \
--from operator0 \
--gas-prices "25ncheq" \
--chain-id $CHAIN_ID \
Expand All @@ -150,7 +149,7 @@ function send_did_old() {

# Send DID
# input: DID to write
function send_did() {
function send_did () {
did_to_write=$1

# Generate Alice identity key
Expand All @@ -166,7 +165,8 @@ function send_did() {
MSG_CREATE_DID='{"id":"'${did_to_write}'","verification_method":[{"id":"'"${KEY_ID}"'","type":"Ed25519VerificationKey2020","controller":"'${did_to_write}'","public_key_multibase":"'${ALICE_VER_PUB_MULTIBASE_58}'"}],"authentication":["'${KEY_ID}'"]}'

# Post the message
did=$(local_client_tx tx cheqd create-did "${MSG_CREATE_DID}" "${KEY_ID}" "${ALICE_VER_PRIV_BASE_64}" \
did=$(local_client_tx tx cheqd create-did "${MSG_CREATE_DID}" "${KEY_ID}" \
--ver-key "${ALICE_VER_PRIV_BASE_64}" \
--from operator0 \
--gas-prices "25ncheq" \
--chain-id $CHAIN_ID \
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e-complex/upgrade/prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ OP2_ADDRESS=${addresses[2]}
send_tokens "$OP2_ADDRESS"

# Send DID transaction
send_did_old "$DID_1"
send_did "$DID_1"

# Check that token transaction exists
check_tx_hashes
Expand Down
12 changes: 11 additions & 1 deletion tests/e2e-complex/upgrade/upgrade_and_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,16 @@ set -euox pipefail
# shellcheck disable=SC1091
. common.sh

cheqd_noded_docker() {
docker run --rm \
-v "$(pwd):/home/cheqd" \
--network host \
-u root \
-e HOME=/home/cheqd \
--entrypoint "cheqd-noded" \
${CHEQD_IMAGE_TO} "$@"
}

# Wait for upgrade height
bash ../../tools/wait-for-chain.sh "$UPGRADE_HEIGHT" $((2 * VOTING_PERIOD))

Expand Down Expand Up @@ -46,7 +56,7 @@ check_did "$DID_1"
send_tokens "$OP_ADDRESS_AFTER"

# Send DID after upgrade
send_did "$DID_2"
send_did_new "$DID_2"

# Check balance after token sending
check_balance "$OP_ADDRESS_AFTER"
Expand Down

0 comments on commit b094a0b

Please sign in to comment.