Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: Add resources to upgrade integration tests #340

Merged
merged 24 commits into from
Jul 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
a2b2080
Add resources to upgrade integration tests
Toktar Jul 1, 2022
35c9c8c
Makes linter happy
Jul 1, 2022
d82bae1
Pin to v0.45.5 fork for Cosmos SDK
ankurdotb Jul 1, 2022
f61ea65
Bugfix for resource upgrade test
Toktar Jul 4, 2022
ddd3e4b
Update common.sh
ankurdotb Jul 4, 2022
484deff
Merge branch 'upgrade_tests' of https://github.com/cheqd/cheqd-node i…
ankurdotb Jul 4, 2022
691bedf
Bugfix for resource upgrade test
Toktar Jul 4, 2022
ce0f2e4
Bugfix for resource upgrade test
Toktar Jul 4, 2022
3ffc352
Bugfix for resource upgrade test
Toktar Jul 4, 2022
437020f
Bugfix for resource upgrade test
Toktar Jul 4, 2022
0d4bda1
Bugfix for resource upgrade test
Toktar Jul 4, 2022
e43e5e5
Bugfix for resource upgrade test
Toktar Jul 4, 2022
6c1b65c
Bugfix for resource upgrade test
Toktar Jul 4, 2022
d2c5470
Squashed commit of the following:
ankurdotb Jul 4, 2022
3a9dd47
Bugfix for resource upgrade test
Toktar Jul 4, 2022
08c02dc
Merge branch 'upgrade_tests' of github.com:cheqd/cheqd-node into upgr…
Toktar Jul 4, 2022
3be9f8e
Merge branch 'main' of github.com:cheqd/cheqd-node into upgrade_tests
Toktar Jul 4, 2022
5042807
Merge branch 'main' into upgrade_tests
Toktar Jul 4, 2022
557509c
Bugfix for resource upgrade test
Toktar Jul 4, 2022
00b2360
Merge branch 'upgrade_tests' of github.com:cheqd/cheqd-node into upgr…
Toktar Jul 4, 2022
cad7f29
Bugfix for resource upgrade test
Toktar Jul 4, 2022
63382dd
Revert "Pin to v0.45.5 fork for Cosmos SDK"
Jul 4, 2022
87a86f7
Bump cosmos
Toktar Jul 5, 2022
0edde73
Fix go.sum
Jul 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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