-
Notifications
You must be signed in to change notification settings - Fork 75
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
Feature(cli): Add smoke tests for cli commands #1617
Open
sambukowski
wants to merge
8
commits into
main
Choose a base branch
from
ENG-868
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
ef9db9a
test(cli): add smoke test for cli commands
joroshiba a4ab6d7
cli smoke tests
sambukowski 92f0857
fix validator update
sambukowski 184be70
refactor tests to individual just functions, update single sequencer …
sambukowski ed17817
remove old just command
sambukowski d0505ae
remove test prefix
sambukowski 5e3f0f2
rename funded account to sudo account
sambukowski 5c450e7
simplify bech32m test
sambukowski 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 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 |
---|---|---|
@@ -0,0 +1,193 @@ | ||
_default: | ||
@just --list | ||
|
||
cli-test *ARGS: | ||
@just {{ARGS}} | ||
|
||
deploy: | ||
@just deploy cluster | ||
@just deploy ingress-controller | ||
@just wait-for-ingress-controller | ||
@just deploy astria-local | ||
|
||
command tag *ARGS: | ||
docker run --rm --network host "ghcr.io/astriaorg/astria-cli{{ if tag != '' { replace(':#', '#', tag) } else { '' } }}" {{ ARGS }} | ||
|
||
fundedAccount := "astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm" | ||
privKey1 := "2bd806c97f0e00af1a1fc3328fa763a9269723c8db8fac4f93af71db186d6e90" | ||
privKey2 := "dfa7108e38ab71f89f356c72afc38600d5758f11a8c337164713e4471411d2e0" | ||
ibcAddAddress := "astria13ahqz4pjqfmynk9ylrqv4fwe4957x2p0h5782u" | ||
pubKey := "88787e29db8d5247c6adfac9909b56e6b2705c3120b2e3885e8ec8aa416a10f1" | ||
newPower := "100" | ||
originalPower := "10" | ||
sequencerRpc := "http://rpc.sequencer.localdev.me" | ||
sequencerChainId := "sequencer-test-chain-0" | ||
asset := "test" | ||
defaultTag := "latest" | ||
|
||
validate-output output expected_format: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
if echo "$output" | perl -0777 -ne 'exit 0 if /'"$expected_format"'/; exit 1'; then | ||
printf "\e[32m✔\e[0m Output matches the expected format.\n" | ||
else | ||
printf "❌ Output does not match the expected format.\n" | ||
exit 1 | ||
fi | ||
|
||
# Test the `create-account` command | ||
create-account tag=defaultTag: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
printf "\nRunning the 'sequencer account create' command...\n" | ||
output=$(just cli-test command {{ tag }} sequencer account create) | ||
expected_format="^Create Sequencer Account\n\nPrivate Key:\s+\"[0-9a-f]{64}\"\nPublic Key:\s+\"[0-9a-f]{64}\"\nAddress:\s+\"[0-9a-f]{40}\"$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
# Test the `bech32m` command | ||
bech32m tag=defaultTag: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
# make a new account to get the address bytes | ||
output=$(just cli-test command {{ tag }} sequencer account create) | ||
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. Maybe should be a default address in bytes configured instead of creating an account? create account might change to print a bech32m prefixed address instead of bytes |
||
expected_format="^Create Sequencer Account\n\nPrivate Key:\s+\"[0-9a-f]{64}\"\nPublic Key:\s+\"[0-9a-f]{64}\"\nAddress:\s+\"[0-9a-f]{40}\"$" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
printf "\nRunning the 'sequencer address bech32' command...\n" | ||
address=$(echo "$output" | perl -ne 'print $1 if /Address:\s+"([0-9a-f]{40})"/') | ||
# Run the second command with the extracted address | ||
output=$(just cli-test command {{ tag }} sequencer address bech32m --bytes "$address") | ||
expected_format="^astria[0-9a-z]{39}$" | ||
astria_address=$(echo "$output") | ||
just cli-test validate-output "$astria_address" "$expected_format" | ||
|
||
get-balance tag=defaultTag: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
printf "\nRunning the 'sequencer account balance' command...\n" | ||
output=$(just cli-test command {{ tag }} sequencer account balance {{fundedAccount}} --sequencer-url {{sequencerRpc}}) | ||
expected_format="^Balances for address: astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm\n\s+[0-9]{18} nria$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
printf "\nRunning the 'sequencer balance get' command...\n" | ||
output=$(just cli-test command {{ tag }} sequencer balance get {{fundedAccount}} --sequencer-url {{sequencerRpc}}) | ||
expected_format="^Balances for address: astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm\n\s+[0-9]{18} nria$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
get-nonce tag=defaultTag: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
printf "\nRunning the 'sequencer account nonce' command...\n" | ||
output=$(just cli-test command {{ tag }} sequencer account nonce {{fundedAccount}} --sequencer-url {{sequencerRpc}}) | ||
expected_format="^Nonce for address astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm\n\s+[0-9]+ at height [0-9]*$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
get-blockheight tag=defaultTag: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
printf "\nRunning the 'sequencer blockheight get' command...\n" | ||
output=$(just cli-test command {{ tag }} sequencer blockheight get --sequencer-url {{sequencerRpc}}) | ||
expected_format="^Block Height:\n\s+[0-9]*$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
ibc-relayer tag=defaultTag: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
printf "\nRunning the 'sequencer sudo ibc-relayer add' command...\n" | ||
output=$(just cli-test command {{ tag }} sequencer sudo ibc-relayer add --address {{ibcAddAddress}} --private-key {{privKey1}} --sequencer-url {{sequencerRpc}} --sequencer.chain-id {{sequencerChainId}}) | ||
expected_format="^sending tx from address: astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm\nIbcRelayerChangeAction::Addition completed!\nIncluded in block: [0-9]+$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
printf "\nRunning the 'sequencer sudo ibc-relayer remove' command...\n" | ||
output=$(just cli-test command {{ tag }} sequencer sudo ibc-relayer remove --address {{ibcAddAddress}} --private-key {{privKey1}} --sequencer-url {{sequencerRpc}} --sequencer.chain-id {{sequencerChainId}}) | ||
expected_format="^sending tx from address: astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm\nIbcRelayerChangeAction::Removal completed!\nIncluded in block: [0-9]+$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
fee-asset tag=defaultTag: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
printf "\nRunning the 'sequencer sudo fee-asset add' command...\n" | ||
output=$(just cli-test command {{ tag }} sequencer sudo fee-asset add --asset {{asset}} --private-key {{privKey1}} --sequencer-url {{sequencerRpc}} --sequencer.chain-id {{sequencerChainId}}) | ||
expected_format="^sending tx from address: astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm\nFeeAssetChangeAction::Addition completed!\nIncluded in block: [0-9]+$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
printf "\nRunning the 'sequencer sudo fee-asset remove' command...\n" | ||
output=$(just cli-test command {{ tag }} sequencer sudo fee-asset remove --asset {{asset}} --private-key {{privKey1}} --sequencer-url {{sequencerRpc}} --sequencer.chain-id {{sequencerChainId}}) | ||
expected_format="^sending tx from address: astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm\nFeeAssetChangeAction::Removal completed!\nIncluded in block: [0-9]+$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
sudo-address-change tag=defaultTag: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
printf "\nRunning the 'sequencer sudo sudo-address-change' command...\n" | ||
output=$(just cli-test command {{ tag }} sequencer sudo sudo-address-change --address {{ibcAddAddress}} --private-key {{privKey1}} --sequencer-url {{sequencerRpc}} --sequencer.chain-id {{sequencerChainId}}) | ||
expected_format="^sending tx from address: astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm\nSudoAddressChange completed!\nIncluded in block: [0-9]+$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
printf "\nRunning the 'sequencer sudo sudo-address-change' command to revert the sudo address to the original one...\n" | ||
output=$(just cli-test command {{ tag }} sequencer sudo sudo-address-change --address {{fundedAccount}} --private-key {{privKey2}} --sequencer-url {{sequencerRpc}} --sequencer.chain-id {{sequencerChainId}}) | ||
expected_format="^sending tx from address: astria13ahqz4pjqfmynk9ylrqv4fwe4957x2p0h5782u\nSudoAddressChange completed!\nIncluded in block: [0-9]+$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
validator-update tag=defaultTag: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
printf "\nRunning the 'sequencer sudo validator-update' command to update power...\n" | ||
output=$(just cli-test command {{ tag }} sequencer sudo validator-update --power 10 --validator-public-key {{pubKey}} --private-key {{privKey1}} --sequencer-url {{sequencerRpc}} --sequencer.chain-id {{sequencerChainId}}) | ||
expected_format="^sending tx from address: astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm\nValidatorUpdate completed!\nIncluded in block: [0-9]+$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
printf "\nRunning the 'sequencer sudo validator-update' command to revert power...\n" | ||
output=$(just cli-test command {{ tag }} sequencer sudo validator-update --power 1 --validator-public-key {{pubKey}} --private-key {{privKey1}} --sequencer-url {{sequencerRpc}} --sequencer.chain-id {{sequencerChainId}}) | ||
expected_format="^sending tx from address: astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm\nValidatorUpdate completed!\nIncluded in block: [0-9]+$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
transfer tag=defaultTag: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
printf "\nRunning the 'sequencer transfer' command...\n" | ||
output=$(just cli-test command {{ tag }} sequencer transfer {{ibcAddAddress}} --amount 100 --private-key {{privKey1}} --sequencer-url {{sequencerRpc}} --sequencer.chain-id {{sequencerChainId}}) | ||
expected_format="^sending tx from address: astria1rsxyjrcm255ds9euthjx6yc3vrjt9sxrm9cfgm\nTransfer completed!\nIncluded in block: [0-9]+$" | ||
echo "Output:\n$output" | ||
just cli-test validate-output "$output" "$expected_format" | ||
|
||
run tag=defaultTag: | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
printf "Testing the CLI with the tag: {{ tag }}\n" | ||
|
||
just cli-test create-account | ||
just cli-test bech32m | ||
just cli-test get-balance | ||
just cli-test get-nonce | ||
just cli-test get-blockheight | ||
just cli-test ibc-relayer | ||
just cli-test fee-asset | ||
just cli-test sudo-address-change | ||
just cli-test validator-update | ||
just cli-test transfer |
This file contains 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
This file contains 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
Oops, something went wrong.
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.
nit:
sudoAccount
, but can be treated as afundedAccount