|
| 1 | +name: Liveness Tests |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: ["main"] |
| 6 | + pull_request: |
| 7 | + branches: ["main"] |
| 8 | + workflow_dispatch: |
| 9 | + |
| 10 | +jobs: |
| 11 | + rollkit-liveness: |
| 12 | + name: Ignite Rollkit App Liveness Test |
| 13 | + runs-on: ubuntu-latest |
| 14 | + timeout-minutes: 30 |
| 15 | + env: |
| 16 | + DO_NOT_TRACK: true |
| 17 | + |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@v4 |
| 20 | + with: |
| 21 | + fetch-depth: 0 |
| 22 | + |
| 23 | + - name: Set up Go |
| 24 | + uses: actions/setup-go@v5 |
| 25 | + with: |
| 26 | + go-version: "stable" |
| 27 | + cache: true |
| 28 | + |
| 29 | + - name: Install Ignite CLI |
| 30 | + run: | |
| 31 | + curl -sSL https://get.ignite.com/cli@v28.10.0! | bash |
| 32 | +
|
| 33 | + - name: Start Local DA |
| 34 | + run: | |
| 35 | + # clone rollkit repository (#TODO install via go install when possible) |
| 36 | + git clone https://github.com/rollkit/rollkit --depth 1 rollkit-repo |
| 37 | + cd rollkit-repo/da/cmd/local-da |
| 38 | + # start the local da in the background |
| 39 | + go run . & |
| 40 | + # capture the background process PID |
| 41 | + echo "DA_PID=$!" >> $GITHUB_ENV |
| 42 | + # give it a moment to start |
| 43 | + sleep 3 |
| 44 | +
|
| 45 | + - name: Scaffold & Init Rollkit Chain |
| 46 | + run: | |
| 47 | + # get the path to the current checkout of ignite apps |
| 48 | + ROLLKIT_APP_DIR=$(pwd)/rollkit |
| 49 | +
|
| 50 | + # scaffold a new chain |
| 51 | + ignite scaffold chain gm --no-module --skip-git |
| 52 | + cd gm |
| 53 | +
|
| 54 | + # install rollkit app |
| 55 | + ignite app install $ROLLKIT_APP_DIR |
| 56 | +
|
| 57 | + # add rollkit to the chain |
| 58 | + ignite rollkit add |
| 59 | + go mod tidy |
| 60 | +
|
| 61 | + # build the chain |
| 62 | + ignite chain build --skip-proto |
| 63 | +
|
| 64 | + # initialize rollkit |
| 65 | + ignite rollkit init |
| 66 | +
|
| 67 | + - name: Start Chain and Wait for Blocks |
| 68 | + run: | |
| 69 | + cd gm |
| 70 | +
|
| 71 | + # start the chain and send output to a log file |
| 72 | + gmd start --rollkit.node.aggregator --log_format=json > chain.log 2>&1 & |
| 73 | + CHAIN_PID=$! |
| 74 | + echo "CHAIN_PID=$CHAIN_PID" >> $GITHUB_ENV |
| 75 | +
|
| 76 | + echo "Waiting for chain to produce blocks..." |
| 77 | +
|
| 78 | + # wait for chain to start and check for 5 blocks |
| 79 | + BLOCKS_FOUND=0 |
| 80 | + MAX_ATTEMPTS=60 |
| 81 | + ATTEMPT=0 |
| 82 | +
|
| 83 | + while [ $BLOCKS_FOUND -lt 5 ] && [ $ATTEMPT -lt $MAX_ATTEMPTS ]; do |
| 84 | + sleep 2 |
| 85 | + ATTEMPT=$((ATTEMPT+1)) |
| 86 | + |
| 87 | + # check if the chain is still running |
| 88 | + if ! ps -p $CHAIN_PID > /dev/null; then |
| 89 | + echo "Chain process died unexpectedly" |
| 90 | + cat chain.log |
| 91 | + exit 1 |
| 92 | + fi |
| 93 | + |
| 94 | + # count blocks in log |
| 95 | + BLOCKS_FOUND=$(grep -c "block executed successfully" chain.log || true) |
| 96 | + echo "Found $BLOCKS_FOUND blocks so far (attempt $ATTEMPT/$MAX_ATTEMPTS)" |
| 97 | + done |
| 98 | +
|
| 99 | + if [ $BLOCKS_FOUND -lt 5 ]; then |
| 100 | + echo "Failed to find 5 blocks within time limit" |
| 101 | + cat chain.log |
| 102 | + exit 1 |
| 103 | + fi |
| 104 | +
|
| 105 | + echo "Success! Chain produced at least 5 blocks." |
| 106 | +
|
| 107 | + - name: Test Transaction Submission and Query |
| 108 | + run: | |
| 109 | + cd gm |
| 110 | +
|
| 111 | + # get bob's address |
| 112 | + BOB_ADDRESS=$(gmd keys show bob -a) |
| 113 | + ALICE_ADDRESS=$(gmd keys show alice -a) |
| 114 | + echo "Bob's address: $BOB_ADDRESS" |
| 115 | + echo "Alice's address: $ALICE_ADDRESS" |
| 116 | +
|
| 117 | + # query bob's initial balance |
| 118 | + echo "Querying Bob's initial balance..." |
| 119 | + INITIAL_BALANCE=$(gmd query bank balances $BOB_ADDRESS --output json | jq '.balances[0].amount' -r) |
| 120 | + echo "Bob's initial balance: $INITIAL_BALANCE stake" |
| 121 | +
|
| 122 | + # check that bob has funds |
| 123 | + if [ "$INITIAL_BALANCE" == "" ] || [ "$INITIAL_BALANCE" == "null" ] || [ "$INITIAL_BALANCE" -lt 100 ]; then |
| 124 | + echo "Error: Bob's account not properly funded" |
| 125 | + exit 1 |
| 126 | + fi |
| 127 | +
|
| 128 | + # send transaction from bob to alice and get tx hash |
| 129 | + echo "Sending 100stake from Bob to Alice..." |
| 130 | + TX_HASH=$(gmd tx bank send $BOB_ADDRESS $ALICE_ADDRESS 100stake -y --output json | jq -r .txhash) |
| 131 | +
|
| 132 | + sleep 3 |
| 133 | +
|
| 134 | + # query the transaction |
| 135 | + TX_RESULT=$(gmd query tx $TX_HASH --output json) |
| 136 | + TX_CODE=$(echo $TX_RESULT | jq -r '.code') |
| 137 | + if [ "$TX_CODE" != "0" ]; then |
| 138 | + echo "Error: Transaction failed with code $TX_CODE" |
| 139 | + echo $TX_RESULT | jq |
| 140 | + exit 1 |
| 141 | + fi |
| 142 | +
|
| 143 | + # query bob's balance after transaction |
| 144 | + FINAL_BALANCE=$(gmd query bank balances $BOB_ADDRESS --output json | jq '.balances[0].amount' -r) |
| 145 | + echo "Bob's final balance: $FINAL_BALANCE" |
| 146 | +
|
| 147 | + # calculate and verify the expected balance |
| 148 | + EXPECTED_BALANCE=$((INITIAL_BALANCE - 100)) |
| 149 | + if [ "$FINAL_BALANCE" != "$EXPECTED_BALANCE" ]; then |
| 150 | + echo "Error: Balance mismatch. Expected: $EXPECTED_BALANCE, Actual: $FINAL_BALANCE" |
| 151 | + exit 1 |
| 152 | + fi |
| 153 | +
|
| 154 | + echo "✅ Transaction test successful! Balance correctly updated." |
| 155 | +
|
| 156 | + - name: Cleanup Processes |
| 157 | + if: always() |
| 158 | + run: | |
| 159 | + # kill chain process if it exists |
| 160 | + if [[ -n "${CHAIN_PID}" ]]; then |
| 161 | + kill -9 $CHAIN_PID || true |
| 162 | + fi |
| 163 | +
|
| 164 | + # kill DA process if it exists |
| 165 | + if [[ -n "${DA_PID}" ]]; then |
| 166 | + kill -9 $DA_PID || true |
| 167 | + fi |
0 commit comments