-
Notifications
You must be signed in to change notification settings - Fork 4
ci: add tx test in integration test #87
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
|
||
| # 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) | ||
|
Member
Author
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. 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: | | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
🛠️ Refactor suggestion
Improve shell conditional for empty/null and numeric checks
Mixing
==for string equality and-ltfor numeric comparison can be error-prone. Use-zto test for emptiness and a single=for string equality, reserving-ltfor numeric cases. For example:📝 Committable suggestion