Skip to content
Merged
Changes from all commits
Commits
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
49 changes: 49 additions & 0 deletions .github/workflows/integration_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,55 @@ jobs:

echo "Success! Chain produced at least 5 blocks."

- name: Test Transaction Submission and Query
run: |
cd gm

# get bob's address
BOB_ADDRESS=$(gmd keys show bob -a)
ALICE_ADDRESS=$(gmd keys show alice -a)
echo "Bob's address: $BOB_ADDRESS"
echo "Alice's address: $ALICE_ADDRESS"

# query bob's initial balance
echo "Querying Bob's initial balance..."
INITIAL_BALANCE=$(gmd query bank balances $BOB_ADDRESS --output json | jq '.balances[0].amount' -r)
echo "Bob's initial balance: $INITIAL_BALANCE stake"

# check that bob has funds
if [ "$INITIAL_BALANCE" == "" ] || [ "$INITIAL_BALANCE" == "null" ] || [ "$INITIAL_BALANCE" -lt 100 ]; then
echo "Error: Bob's account not properly funded"
exit 1
fi
Comment on lines +139 to +143
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve shell conditional for empty/null and numeric checks
Mixing == for string equality and -lt for numeric comparison can be error-prone. Use -z to test for emptiness and a single = for string equality, reserving -lt for numeric cases. For example:

- if [ "$INITIAL_BALANCE" == "" ] || [ "$INITIAL_BALANCE" == "null" ] || [ "$INITIAL_BALANCE" -lt 100 ]; then
+ if [ -z "$INITIAL_BALANCE" ] || [ "$INITIAL_BALANCE" = "null" ] || [ "$INITIAL_BALANCE" -lt 100 ]; then
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# check that bob has funds
if [ "$INITIAL_BALANCE" == "" ] || [ "$INITIAL_BALANCE" == "null" ] || [ "$INITIAL_BALANCE" -lt 100 ]; then
echo "Error: Bob's account not properly funded"
exit 1
fi
# check that bob has funds
if [ -z "$INITIAL_BALANCE" ] || [ "$INITIAL_BALANCE" = "null" ] || [ "$INITIAL_BALANCE" -lt 100 ]; then
echo "Error: Bob's account not properly funded"
exit 1
fi


# send transaction from bob to alice and get tx hash
echo "Sending 100stake from Bob to Alice..."
TX_HASH=$(gmd tx bank send $BOB_ADDRESS $ALICE_ADDRESS 100stake -y --output json | jq -r .txhash)

sleep 3

# query the transaction (TODO: uncomment after tx indexer is fixed)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be uncommented after #68

#TX_RESULT=$(gmd query tx $TX_HASH --output json)
#TX_CODE=$(echo $TX_RESULT | jq -r '.code')
#if [ "$TX_CODE" != "0" ]; then
# echo "Error: Transaction failed with code $TX_CODE"
# echo $TX_RESULT | jq
# exit 1
#fi

# query bob's balance after transaction
FINAL_BALANCE=$(gmd query bank balances $BOB_ADDRESS --output json | jq '.balances[0].amount' -r)
echo "Bob's final balance: $FINAL_BALANCE"

# calculate and verify the expected balance
EXPECTED_BALANCE=$((INITIAL_BALANCE - 100))
if [ "$FINAL_BALANCE" != "$EXPECTED_BALANCE" ]; then
echo "Error: Balance mismatch. Expected: $EXPECTED_BALANCE, Actual: $FINAL_BALANCE"
exit 1
fi

echo "✅ Transaction test successful! Balance correctly updated."

- name: Cleanup Processes
if: always()
run: |
Expand Down