-
Notifications
You must be signed in to change notification settings - Fork 881
feat: add autobahn integration tests - batch 1 (CON-249) #3234
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
Open
wen-coding
wants to merge
1
commit into
main
Choose a base branch
from
wen/add_autobahn_integration_tests
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.
+163
−1
Open
Changes from all commits
Commits
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
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 |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| #!/bin/bash | ||
| set -e | ||
|
|
||
| LOG_DIR="build/generated/logs" | ||
|
|
||
| echo "============================================" | ||
| echo " Autobahn Integration Tests" | ||
| echo "============================================" | ||
|
|
||
| get_height() { | ||
| # Use abci_info instead of /status because autobahn updates the app state | ||
| # but not the CometBFT block store, so /status shows height 0. | ||
| # TODO: switch back to /status once autobahn syncs the CometBFT state store. | ||
| local retries=10 | ||
| for i in $(seq 1 $retries); do | ||
| HEIGHT=$(curl -s http://localhost:26657/abci_info 2>/dev/null | python3 -c "import sys,json; print(json.load(sys.stdin)['response']['last_block_height'])" 2>/dev/null) | ||
| if [ -n "$HEIGHT" ] && [ "$HEIGHT" != "0" ]; then | ||
| echo "$HEIGHT" | ||
| return 0 | ||
| fi | ||
| sleep 3 | ||
| done | ||
| echo "FAIL: Could not get block height after $retries retries" >&2 | ||
| return 1 | ||
| } | ||
|
|
||
| # Assert autobahn is enabled on all running nodes. | ||
| # Called before each test to guard against accidental disablement. | ||
| assert_autobahn_enabled() { | ||
| for i in 0 1 2 3; do | ||
| LOG="$LOG_DIR/seid-$i.log" | ||
| if [ ! -f "$LOG" ]; then continue; fi | ||
| if ! grep -q "GigaRouter initialized" "$LOG"; then | ||
| echo "FAIL: Autobahn not enabled on node $i (missing 'GigaRouter initialized' in $LOG)" | ||
| exit 1 | ||
| fi | ||
| done | ||
| } | ||
|
|
||
| # ---- Test 1: Blocks are being produced ---- | ||
| echo "" | ||
| echo "=== Test 1: Block production ===" | ||
| assert_autobahn_enabled | ||
| HEIGHT1=$(get_height) | ||
| echo " Height: $HEIGHT1" | ||
| sleep 5 | ||
| HEIGHT2=$(get_height) | ||
| echo " Height: $HEIGHT2 (after 5s)" | ||
| if [ "$HEIGHT2" -le "$HEIGHT1" ]; then | ||
| echo "FAIL: Block height not advancing ($HEIGHT1 -> $HEIGHT2)" | ||
| exit 1 | ||
| fi | ||
| echo "PASS: Blocks advancing ($HEIGHT1 -> $HEIGHT2)" | ||
|
|
||
| # ---- Test 2: Bank transfer ---- | ||
| echo "" | ||
| echo "=== Test 2: Bank transfer ===" | ||
| assert_autobahn_enabled | ||
| # Create a test recipient address | ||
| RECIPIENT=$(docker exec sei-node-0 sh -c "printf '12345678\n12345678\n' | seid keys add test_recipient --output json 2>/dev/null" | python3 -c "import sys,json; print(json.load(sys.stdin)['address'])") | ||
| echo " Recipient: $RECIPIENT" | ||
|
|
||
| # Send from node_admin (genesis account) to recipient. | ||
| # Use -b sync (not -b block) because CometBFT consensus is disabled in autobahn mode. | ||
| # TODO: support -b block once autobahn updates the CometBFT block store so the broadcast | ||
| # endpoint can track tx inclusion. | ||
| docker exec sei-node-0 sh -c "printf '12345678\n' | seid tx bank send node_admin $RECIPIENT 1000000usei --chain-id sei --fees 2000usei -b sync -y --output json" > /dev/null 2>&1 | ||
|
|
||
| # Wait for the tx to be finalized through autobahn consensus. | ||
| echo " Waiting for tx to finalize..." | ||
| BALANCE="0" | ||
| for attempt in $(seq 1 15); do | ||
| BALANCE=$(docker exec sei-node-0 seid q bank balances "$RECIPIENT" --denom usei --output json 2>/dev/null | python3 -c "import sys,json; print(json.load(sys.stdin)['amount'])" 2>/dev/null) | ||
| if [ "$BALANCE" = "1000000" ]; then | ||
| break | ||
| fi | ||
| sleep 2 | ||
| done | ||
| echo " Balance: $BALANCE usei" | ||
| if [ "$BALANCE" != "1000000" ]; then | ||
| echo "FAIL: Expected balance 1000000, got $BALANCE" | ||
| exit 1 | ||
| fi | ||
| echo "PASS: Bank transfer successful" | ||
|
|
||
| # ---- Test 3: Fault tolerance - one node down ---- | ||
| echo "" | ||
| echo "=== Test 3: One node down (3/4 quorum) ===" | ||
| assert_autobahn_enabled | ||
| HEIGHT_BEFORE=$(get_height) | ||
| echo " Height before: $HEIGHT_BEFORE" | ||
| echo " Killing seid on node 3..." | ||
| docker exec sei-node-3 pkill seid || true | ||
| sleep 10 | ||
| HEIGHT_AFTER=$(get_height) | ||
| echo " Height after: $HEIGHT_AFTER" | ||
| if [ "$HEIGHT_AFTER" -le "$HEIGHT_BEFORE" ]; then | ||
| echo "FAIL: Chain should continue with 3/4 validators" | ||
| exit 1 | ||
| fi | ||
| echo "PASS: Chain continues with one node down ($HEIGHT_BEFORE -> $HEIGHT_AFTER)" | ||
|
|
||
| # ---- Test 4: Two nodes down (no quorum) ---- | ||
| echo "" | ||
| echo "=== Test 4: Two nodes down (no quorum) ===" | ||
| assert_autobahn_enabled | ||
| echo " Killing seid on node 2..." | ||
| docker exec sei-node-2 pkill seid || true | ||
| sleep 5 | ||
| HEIGHT_BEFORE=$(get_height) | ||
| echo " Height: $HEIGHT_BEFORE" | ||
| sleep 15 | ||
| HEIGHT_AFTER=$(get_height) | ||
| echo " Height after 15s: $HEIGHT_AFTER" | ||
| if [ "$HEIGHT_AFTER" -ne "$HEIGHT_BEFORE" ]; then | ||
| echo "FAIL: Chain should halt with 2/4 validators (height changed: $HEIGHT_BEFORE -> $HEIGHT_AFTER)" | ||
| exit 1 | ||
| fi | ||
| echo "PASS: Chain halted with two nodes down" | ||
|
|
||
| # ---- Test 5: Recovery ---- | ||
| # TODO: Re-enable once autobahn supports node restart. Currently, a restarted seid fails | ||
| # because autobahn writes to the app state but not to the CometBFT block/state store. | ||
| # On restart, the CometBFT handshaker sees appHeight >> storeHeight and cannot reconcile. | ||
| echo "" | ||
| echo "=== Test 5: Recovery (SKIPPED — autobahn node restart not yet supported) ===" | ||
|
|
||
| echo "" | ||
| echo "============================================" | ||
| echo " All Autobahn Integration Tests PASSED" | ||
| echo "============================================" | ||
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
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.
Any chance we can write these in go?