144 lines
4.6 KiB
YAML
144 lines
4.6 KiB
YAML
name: Test
|
|
|
|
on:
|
|
pull_request:
|
|
branches: '*'
|
|
push:
|
|
branches:
|
|
- main
|
|
|
|
env:
|
|
CANONICAL_VERSION: v5.0.4-alpha
|
|
ETH_TESTING_REF: v0.5.1
|
|
|
|
jobs:
|
|
build:
|
|
name: Build Docker image
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Build docker image
|
|
run: docker build .
|
|
|
|
unit-test:
|
|
name: Run unit tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v3
|
|
with:
|
|
go-version-file: go.mod
|
|
check-latest: true
|
|
- name: Install test fixtures
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: cerc-io/eth-testing
|
|
path: ./fixtures
|
|
ref: ${{ env.ETH_TESTING_REF }}
|
|
- name: Run unit tests
|
|
run: make test
|
|
|
|
integration-test:
|
|
name: Run integration tests
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: actions/setup-go@v3
|
|
with:
|
|
go-version-file: go.mod
|
|
check-latest: true
|
|
- name: Install test fixtures
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: cerc-io/eth-testing
|
|
path: ./fixtures
|
|
ref: ${{ env.ETH_TESTING_REF }}
|
|
- name: Build package
|
|
run: go build .
|
|
- name: Run DB container
|
|
run: docker compose -f test/compose.yml up --wait
|
|
|
|
# Run a sanity test against the fixture data
|
|
# Complete integration tests are TODO
|
|
- name: Run basic integration test
|
|
env:
|
|
SNAPSHOT_MODE: postgres
|
|
ETHDB_PATH: ./fixtures/chains/data/postmerge1/geth/chaindata
|
|
ETH_GENESIS_BLOCK: 0x66ef6002e201cfdb23bd3f615fcf41e59d8382055e5a836f8d4c2af0d484647c
|
|
SNAPSHOT_BLOCK_HEIGHT: 170
|
|
run: |
|
|
until
|
|
ready_query='select max(version_id) from goose_db_version;'
|
|
version=$(docker exec -e PGPASSWORD=password test-ipld-eth-db-1 \
|
|
psql -tA cerc_testing -U vdbm -c "$ready_query")
|
|
[[ "$version" -ge 21 ]]
|
|
do
|
|
echo "Waiting for ipld-eth-db..."
|
|
sleep 3
|
|
done
|
|
|
|
./ipld-eth-state-snapshot --config test/ci-config.toml stateSnapshot
|
|
|
|
count_results() {
|
|
query="select count(*) from $1;"
|
|
docker exec -e PGPASSWORD=password test-ipld-eth-db-1 \
|
|
psql -tA cerc_testing -U vdbm -c "$query"
|
|
}
|
|
set -x
|
|
[[ "$(count_results eth.header_cids)" = 1 ]]
|
|
[[ "$(count_results eth.state_cids)" = 264 ]]
|
|
[[ "$(count_results eth.storage_cids)" = 371 ]]
|
|
|
|
compliance-test:
|
|
name: Run compliance tests (disabled)
|
|
# Schema has been updated, so compliance tests are disabled until we have a meaningful way to
|
|
# compare to previous results.
|
|
if: false
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v3
|
|
with:
|
|
path: ./ipld-eth-state-snapshot
|
|
- uses: actions/setup-go@v3
|
|
with:
|
|
go-version-file: ./ipld-eth-state-snapshot/go.mod
|
|
check-latest: true
|
|
- name: Install test fixtures
|
|
uses: actions/checkout@v3
|
|
with:
|
|
repository: cerc-io/eth-testing
|
|
path: ./fixtures
|
|
ref: ${{ env.ETH_TESTING_REF }}
|
|
- name: Build current version
|
|
working-directory: ./ipld-eth-state-snapshot
|
|
run: go build -o ../snapshot-current .
|
|
|
|
- name: Checkout canonical version
|
|
uses: actions/checkout@v3
|
|
with:
|
|
path: ./ipld-eth-state-snapshot-canonical
|
|
ref: ${{ env.CANONICAL_VERSION }}
|
|
- name: Build canonical version
|
|
working-directory: ./ipld-eth-state-snapshot-canonical
|
|
run: go build -o ../snapshot-canonical .
|
|
|
|
- name: Run DB container
|
|
working-directory: ./ipld-eth-state-snapshot
|
|
run: docker compose -f test/compose.yml up --wait
|
|
- name: Compare snapshot output
|
|
env:
|
|
SNAPSHOT_BLOCK_HEIGHT: 200
|
|
ETHDB_PATH: ./fixtures/chains/data/premerge2/geth/chaindata
|
|
ETHDB_ANCIENT: ./fixtures/chains/data/premerge2/geth/chaindata/ancient
|
|
ETH_GENESIS_BLOCK: "0x8a3c7cddacbd1ab4ec1b03805fa2a287f3a75e43d87f4f987fcc399f5c042614"
|
|
run: |
|
|
until
|
|
ready_query='select max(version_id) from goose_db_version;'
|
|
version=$(docker exec -e PGPASSWORD=password test-ipld-eth-db-1 \
|
|
psql -tA cerc_testing -U vdbm -c "$ready_query")
|
|
[[ "$version" -ge 21 ]]
|
|
do sleep 1; done
|
|
|
|
./ipld-eth-state-snapshot/scripts/compare-snapshots.sh \
|
|
./snapshot-canonical ./snapshot-current
|