Skip to content
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

chain sync test #1257

Merged
merged 4 commits into from
Jun 11, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
42 changes: 42 additions & 0 deletions .github/workflows/chain-sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Chain Sync

on:
push:
tags:
- v[0-9]+.[0-9]+.[0-9]+*
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

jobs:
chain-sync:
continue-on-error: true
timeout-minutes: 60
runs-on: ubuntu-latest

steps:
- name: Checkout sources
uses: actions/checkout@v4

- name: Install deps
run: sudo apt -y install protobuf-compiler

- name: Install & display rust toolchain
run: rustup show

- name: Check targets are installed correctly
run: rustup target list --installed

- name: Build
run: cargo build --release --locked
ermalkaleci marked this conversation as resolved.
Show resolved Hide resolved

- name: Test astar sync
run: ./scripts/sync.sh astar

- name: Test shiden sync
run: ./scripts/sync.sh shiden

- name: Test shibuya sync
run: ./scripts/sync.sh shibuya
39 changes: 39 additions & 0 deletions scripts/sync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

set -e

# first argument is chain
chain="$@"

# run node
./target/release/astar-collator --chain $chain --no-telemetry --no-prometheus --tmp & CHAIN_PID=$!

printf "Waiting for RPC to be ready"
attempts=12 # 1 minutes
until nc -z localhost 9944; do
attempts=$((attempts - 1))
if [ $attempts -eq 0 ]; then
echo "Chain RPC failed to start"
exit 1
fi
sleep 5
done

printf "Waiting for 30 seconds to sync at least 1000 blocks"
sleep 30

number=$(curl --location http://localhost:9944 \
--header 'Content-Type: application/json' \
--data '{
"jsonrpc": "2.0",
"method": "chain_getHeader",
"params": [],
"id": 1
}' | jq '.result.number' | xargs | { read hex_number; printf "%d\n" $hex_number; })
ermalkaleci marked this conversation as resolved.
Show resolved Hide resolved

if [ "$number" -lt 1000 ]; then
echo "Chain failed to sync 1000 blocks in 30 seconds"
exit 1
fi

kill $CHAIN_PID
Loading