-
Notifications
You must be signed in to change notification settings - Fork 0
fix: use address resolution for wallet references in test script #4
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -83,7 +83,7 @@ for CONTRACT in "$CONTRACT_DIR"/*.wasm; do | |||||||
|
|
||||||||
| tx_hash=$($BINARY tx wasm store "$CONTRACT" \ | ||||||||
| --from "$WALLET" \ | ||||||||
| --instantiate-anyof-addresses "$WALLET" \ | ||||||||
| --instantiate-anyof-addresses "$($BINARY keys show $WALLET -a)" \ | ||||||||
| --chain-id "$CHAIN_ID" \ | ||||||||
| --node "$RPC" \ | ||||||||
| --gas-prices "0.5$DENOM" \ | ||||||||
|
|
@@ -125,23 +125,23 @@ fi | |||||||
| if [ ${#code_ids[@]} -eq 1 ]; then | ||||||||
| echo "Instantiating contract with code_id ${code_ids[0]}" | ||||||||
| for i in {1..2}; do | ||||||||
| res=$($BINARY tx wasm instantiate ${code_ids[0]} '{}' --label test --admin $WALLET $TXFLAG --from $WALLET | jq -r '.txhash') | ||||||||
| res=$($BINARY tx wasm instantiate ${code_ids[0]} '{}' --label test --admin "$($BINARY keys show $WALLET -a)" $TXFLAG --from $WALLET | jq -r '.txhash') | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Use cached address and quote Avoid repeated key lookups and ensure -res=$($BINARY tx wasm instantiate ${code_ids[0]} '{}' --label test --admin "$($BINARY keys show $WALLET -a)" $TXFLAG --from $WALLET | jq -r '.txhash')
+res=$($BINARY tx wasm instantiate ${code_ids[0]} '{}' --label test --admin "$WALLET_ADDR" $TXFLAG --from "$WALLET" | jq -r '.txhash')🤖 Prompt for AI Agents |
||||||||
| sleep 10 | ||||||||
| contract_address=$($BINARY q tx $res --node $RPC -o json | jq -r '.events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value') | ||||||||
| contract_addresses+=("$contract_address") | ||||||||
| done | ||||||||
| else | ||||||||
| echo "Instantiating contracts with code_ids ${code_ids[@]}" | ||||||||
| for code_id in "${code_ids[@]}"; do | ||||||||
| res=$($BINARY tx wasm instantiate $code_id '{}' --label test --admin $WALLET $TXFLAG --from $WALLET | jq -r '.txhash') | ||||||||
| res=$($BINARY tx wasm instantiate $code_id '{}' --label test --admin "$($BINARY keys show $WALLET -a)" $TXFLAG --from $WALLET | jq -r '.txhash') | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion DRY: reuse cached admin address and quote Same refactor as above to reduce command invocations and harden quoting. -res=$($BINARY tx wasm instantiate $code_id '{}' --label test --admin "$($BINARY keys show $WALLET -a)" $TXFLAG --from $WALLET | jq -r '.txhash')
+res=$($BINARY tx wasm instantiate $code_id '{}' --label test --admin "$WALLET_ADDR" $TXFLAG --from "$WALLET" | jq -r '.txhash')📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| sleep 10 | ||||||||
| contract_address=$($BINARY q tx $res --node $RPC -o json | jq -r '.events[] | select(.type == "instantiate").attributes[] | select(.key == "_contract_address").value') | ||||||||
| contract_addresses+=("$contract_address") | ||||||||
| done | ||||||||
| fi | ||||||||
|
|
||||||||
| echo -e "\nTrying to instantiate a contract with $WALLET2 should fail..." | ||||||||
| $BINARY tx wasm instantiate ${code_ids[0]} '{}' --label test_fail --admin $WALLET2 $TXFLAG --from $WALLET2 | ||||||||
| $BINARY tx wasm instantiate ${code_ids[0]} '{}' --label test_fail --admin "$($BINARY keys show $WALLET2 -a)" $TXFLAG --from $WALLET2 | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainUse cached address for negative test and optionally assert failure Reusing the cached address avoids extra lookups. Consider asserting that this instantiate indeed fails to make the test deterministic. Minimal change: -$BINARY tx wasm instantiate ${code_ids[0]} '{}' --label test_fail --admin "$($BINARY keys show $WALLET2 -a)" $TXFLAG --from $WALLET2
+$BINARY tx wasm instantiate ${code_ids[0]} '{}' --label test_fail --admin "$WALLET2_ADDR" $TXFLAG --from "$WALLET2"Optional stronger check: if $BINARY tx wasm instantiate "${code_ids[0]}" '{}' --label test_fail --admin "$WALLET2_ADDR" $TXFLAG --from "$WALLET2"; then
echo "Unexpected success: instantiate should have failed"; exit 1
else
echo "Expected failure confirmed"
fi🏁 Script executed: #!/bin/bash
# Check if WALLET2_ADDR is defined/cached in the test script
rg -n 'WALLET2_ADDR' -C3 scripts/test.shLength of output: 40 🏁 Script executed: #!/bin/bash
# Search for any assignment to WALLET2_ADDR or usage of keys show for WALLET2
rg -n 'WALLET2_ADDR' -C3 scripts/test.sh
rg -n 'keys show.*\$WALLET2' -C3 scripts/test.shLength of output: 777 🏁 Script executed: #!/bin/bash
# Search for where WALLET_ADDR is defined to locate address caching block
rg -n 'WALLET_ADDR=' -C5 scripts/test.shLength of output: 40 Define and cache WALLET2_ADDR before reuse, then assert instantiate failure The variable • Add a cache assignment before line 144 in scripts/test.sh: WALLET2_ADDR=$($BINARY keys show $WALLET2 -a)• Update the instantiate call to use the cached address: -$BINARY tx wasm instantiate ${code_ids[0]} '{}' --label test_fail \
- --admin "$($BINARY keys show $WALLET2 -a)" $TXFLAG --from $WALLET2
+$BINARY tx wasm instantiate ${code_ids[0]} '{}' --label test_fail \
+ --admin "$WALLET2_ADDR" $TXFLAG --from "$WALLET2"• (Optional) Wrap in an if $BINARY tx wasm instantiate "${code_ids[0]}" '{}' \
--label test_fail --admin "$WALLET2_ADDR" $TXFLAG --from "$WALLET2"; then
echo "Unexpected success: instantiate should have failed"
exit 1
else
echo "Expected failure confirmed"
fi🤖 Prompt for AI Agents |
||||||||
|
|
||||||||
| echo -e "\nInstantiated contracts at : ${contract_addresses[@]}" | ||||||||
|
|
||||||||
|
|
@@ -238,7 +238,7 @@ echo -e "\n--- All contract interactions complete ---" | |||||||
| echo -e "\n--- Interop with Native Cosmos Modules ---" | ||||||||
|
|
||||||||
| echo -e "\nSending native tokens..." | ||||||||
| $BINARY tx bank send $WALLET $WALLET2 100uom $TXFLAG --from $WALLET | ||||||||
| $BINARY tx bank send "$($BINARY keys show $WALLET -a)" "$($BINARY keys show $WALLET2 -a)" 100uom $TXFLAG --from $WALLET | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Reuse cached addresses, quote Keep denom configurable and avoid repeated key lookups. -$BINARY tx bank send "$($BINARY keys show $WALLET -a)" "$($BINARY keys show $WALLET2 -a)" 100uom $TXFLAG --from $WALLET
+$BINARY tx bank send "$WALLET_ADDR" "$WALLET2_ADDR" "100$DENOM" $TXFLAG --from "$WALLET"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| sleep 8 | ||||||||
| $BINARY tx bank send $WALLET2 $WALLET 80uom $TXFLAG --from $WALLET2 | ||||||||
| $BINARY tx bank send "$($BINARY keys show $WALLET2 -a)" "$($BINARY keys show $WALLET -a)" 80uom $TXFLAG --from $WALLET2 | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion Same as above: cached addresses, quoting, and configurable denom -$BINARY tx bank send "$($BINARY keys show $WALLET2 -a)" "$($BINARY keys show $WALLET -a)" 80uom $TXFLAG --from $WALLET2
+$BINARY tx bank send "$WALLET2_ADDR" "$WALLET_ADDR" "80$DENOM" $TXFLAG --from "$WALLET2"📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||
| sleep 8 | ||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
Consider including all intended admins and avoid repeated key lookups
If the intent was to allow both wallets to instantiate, pass both addresses as a comma-separated list. Also, avoid repeated
keys showcalls by caching resolved addresses.Apply within this line:
Define once after parsing flags (and validate):
If only one admin was intended, still prefer using
$WALLET_ADDRand quote the inner var in command substitution if you keep it:🏁 Script executed:
Length of output: 4370
scripts/test.sh: cache wallet addresses, include both admins, parameterize denom, and fix array echo
"$($BINARY keys show …)"invocations with$WALLET_ADDRor$WALLET2_ADDR, e.g. bank sends at lines 241–243:execute_tx(lines 162, 168, 171) to use$DENOM.🤖 Prompt for AI Agents