Skip to content

Commit

Permalink
test: Add resources to upgrade integration tests (#340)
Browse files Browse the repository at this point in the history
* Add `resource` module to upgrade integration tests
* Pin to v0.45.5 fork for Cosmos SDK
* Fix go.sum

Signed-off-by: Andrew Nikitin <[email protected]>

Co-authored-by: Andrew Nikitin <[email protected]>
Co-authored-by: Ankur Banerjee <[email protected]>
  • Loading branch information
3 people authored Jul 5, 2022
1 parent f5fae32 commit a725660
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
2 changes: 1 addition & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -1583,4 +1583,4 @@ rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0=
rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA=
sigs.k8s.io/yaml v1.1.0/go.mod h1:UJmg0vDUVViEyp3mgSv9WPwZCDxu4rQW1olrI1uml+o=
sigs.k8s.io/yaml v1.2.0/go.mod h1:yfXDCHCao9+ENCvLSE62v9VSji2MKu5jeNfTrofGhJc=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
sourcegraph.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0/go.mod h1:hI742Nqp5OhwiqlzhgfbWU4mW4yO10fP+LoT9WOswdU=
60 changes: 58 additions & 2 deletions tests/e2e-complex/upgrade/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,17 @@ FNAME_TXHASHES="txs.hashes"
AMOUNT_BEFORE="19000000000000000"
CHEQ_AMOUNT="1ncheq"
CHEQ_AMOUNT_NUMBER="1"
DID_METHOD="did:cheqd:testnet:"
# shellcheck disable=SC2034
DID_1="did:cheqd:testnet:1111111111111111"
# shellcheck disable=SC2034
DID_2="did:cheqd:testnet:2222222222222222"
DID_2_IDENTIFIER="2222222222222222"
# shellcheck disable=SC2034
DID_2="${DID_METHOD}${DID_2_IDENTIFIER}"
# shellcheck disable=SC2034
RESOURCE_1="82aadc50-58e4-4e00-bf35-36062c2784be"
CHEQD_HOME="/home/cheqd"


GAS="auto"
GAS_ADJUSTMENT="1.3"
GAS_PRICES="25ncheq"
Expand Down Expand Up @@ -138,6 +142,7 @@ function send_did_new () {
ALICE_VER_KEY="$(cheqd_noded_docker debug ed25519 random)"
ALICE_VER_PUB_BASE_64=$(echo "${ALICE_VER_KEY}" | jq -r ".pub_key_base_64")
ALICE_VER_PRIV_BASE_64=$(echo "${ALICE_VER_KEY}" | jq -r ".priv_key_base_64")
export -n ALICE_VER_PRIV_BASE_64=$ALICE_VER_PRIV_BASE_64
ALICE_VER_PUB_MULTIBASE_58=$(cheqd_noded_docker debug encoding base64-multibase58 "${ALICE_VER_PUB_BASE_64}")

# Build CreateDid message
Expand All @@ -159,6 +164,39 @@ function send_did_new () {
echo "$txhash" >> $FNAME_TXHASHES
}

# Send resource
# input: resource to write
function send_resource_new () {
collection_id_to_write=$1
resource_to_write=$2

# Build CreateDid message
KEY_ID="${DID_METHOD}${collection_id_to_write}#key1"

RESOURCE_NAME="Resource 1"
RESOURCE_RESOURCE_TYPE="CL-Schema"
RESOURCE_DATA='{ "content": "test data" }';
echo "${RESOURCE_DATA}" > resource_data.json

# Post the message
# shellcheck disable=SC2086
resource=$(local_client_tx tx resource create-resource \
--collection-id ${collection_id_to_write} \
--resource-id ${resource_to_write} \
--resource-name "${RESOURCE_NAME}" \
--resource-type "${RESOURCE_RESOURCE_TYPE}" \
--resource-file ./resource_data.json \
"${KEY_ID}" "${ALICE_VER_PRIV_BASE_64}" \
--from operator0 \
--gas-prices "25ncheq" \
--chain-id $CHAIN_ID \
--output json \
-y)

txhash=$(echo "$resource" | jq ".txhash" | tr -d '"')
echo "$txhash" >> $FNAME_TXHASHES
}

# Send DID
# input: DID to write
function send_did () {
Expand Down Expand Up @@ -214,6 +252,12 @@ function get_did () {
cheqd_noded_docker query cheqd did "$requested_did" --output json
}

function get_resource () {
collection_id=$1
resource_id=$2
cheqd_noded_docker query resource resource "$collection_id" "$resource_id" --output json
}

# Check that balance of operator3 increased to CHEQ_AMOUNT
# Input: Address to check
function check_balance () {
Expand All @@ -236,3 +280,15 @@ function check_did () {
exit 1
fi
}

# Check that $DID exists
function check_resource () {
collection_id_to_check=$1
resource_to_check=$2
resource_from=$(get_resource "$collection_id_to_check" "$resource_to_check" | jq ".resource.header.id" | tr -d '"')
if [ "$resource_from" != "$resource_to_check" ];
then
echo "There is no any $resource_to_check on server"
exit 1
fi
}
6 changes: 6 additions & 0 deletions tests/e2e-complex/upgrade/upgrade_and_check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ check_did "$DID_2"
# Check that token transaction exists after upgrade too
check_tx_hashes

# Send new resource
send_resource_new "$DID_2_IDENTIFIER" "$RESOURCE_1"

# Check new resource
check_resource "$DID_2_IDENTIFIER" "$RESOURCE_1"

# Stop docker compose
docker_compose_down

Expand Down

0 comments on commit a725660

Please sign in to comment.