2023-09-29 18:43:26 +00:00
|
|
|
name: Test
|
|
|
|
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
branches: '*'
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- main
|
|
|
|
|
|
|
|
env:
|
|
|
|
CANONICAL_VERSION: v5.0.4-alpha
|
2024-08-05 13:17:00 +00:00
|
|
|
ETH_TESTING_REF: v0.5.1
|
2023-09-29 18:43:26 +00:00
|
|
|
|
|
|
|
jobs:
|
2024-08-05 13:17:00 +00:00
|
|
|
build:
|
|
|
|
name: Build Docker image
|
2023-09-29 18:43:26 +00:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2024-08-05 13:17:00 +00:00
|
|
|
- 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
|
2023-09-29 18:43:26 +00:00
|
|
|
- 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
|
2024-08-05 13:17:00 +00:00
|
|
|
ref: ${{ env.ETH_TESTING_REF }}
|
2023-09-29 18:43:26 +00:00
|
|
|
- name: Run unit tests
|
|
|
|
run: make test
|
|
|
|
|
2024-08-05 13:17:00 +00:00
|
|
|
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 .
|
2023-09-29 18:43:26 +00:00
|
|
|
- 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
|
2024-08-05 13:17:00 +00:00
|
|
|
ETHDB_PATH: ./fixtures/chains/data/postmerge1/geth/chaindata
|
|
|
|
ETH_GENESIS_BLOCK: 0x66ef6002e201cfdb23bd3f615fcf41e59d8382055e5a836f8d4c2af0d484647c
|
|
|
|
SNAPSHOT_BLOCK_HEIGHT: 170
|
2023-09-29 18:43:26 +00:00
|
|
|
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")
|
2024-08-05 13:17:00 +00:00
|
|
|
[[ "$version" -ge 21 ]]
|
|
|
|
do
|
|
|
|
echo "Waiting for ipld-eth-db..."
|
|
|
|
sleep 3
|
|
|
|
done
|
2023-09-29 18:43:26 +00:00
|
|
|
|
|
|
|
./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 ]]
|
2024-08-05 13:17:00 +00:00
|
|
|
[[ "$(count_results eth.state_cids)" = 264 ]]
|
|
|
|
[[ "$(count_results eth.storage_cids)" = 371 ]]
|
2023-09-29 18:43:26 +00:00
|
|
|
|
|
|
|
compliance-test:
|
2024-08-05 13:17:00 +00:00
|
|
|
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
|
2023-09-29 18:43:26 +00:00
|
|
|
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
|
2024-08-05 13:17:00 +00:00
|
|
|
ref: ${{ env.ETH_TESTING_REF }}
|
2023-09-29 18:43:26 +00:00
|
|
|
- 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
|
2024-08-05 13:17:00 +00:00
|
|
|
ETHDB_PATH: ./fixtures/chains/data/premerge2/geth/chaindata
|
|
|
|
ETHDB_ANCIENT: ./fixtures/chains/data/premerge2/geth/chaindata/ancient
|
2023-09-29 18:43:26 +00:00
|
|
|
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")
|
2024-08-05 13:17:00 +00:00
|
|
|
[[ "$version" -ge 21 ]]
|
2023-09-29 18:43:26 +00:00
|
|
|
do sleep 1; done
|
|
|
|
|
|
|
|
./ipld-eth-state-snapshot/scripts/compare-snapshots.sh \
|
|
|
|
./snapshot-canonical ./snapshot-current
|