Refactor to use statediff plugin #1
67
.gitea/workflows/test.yml
Normal file
67
.gitea/workflows/test.yml
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
name: Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches: '*'
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
# Needed until we can incorporate docker startup into the executor container
|
||||||
|
env:
|
||||||
|
DOCKER_HOST: unix:///var/run/dind.sock
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
tests:
|
||||||
|
name: Run unit and integration tests
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version-file: go.mod
|
||||||
|
check-latest: true
|
||||||
|
- name: Configure Gitea access
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ secrets.CICD_REPO_TOKEN }}
|
||||||
|
run: |
|
||||||
|
git config --global url."https://$TOKEN:@git.vdb.to/".insteadOf "https://git.vdb.to/"
|
||||||
|
- name: Build package
|
||||||
|
run: go build .
|
||||||
|
- name: Run unit tests
|
||||||
|
run: make test
|
||||||
|
|
||||||
|
- name: Run dockerd
|
||||||
|
run: |
|
||||||
|
dockerd -H $DOCKER_HOST --userland-proxy=false &
|
||||||
|
sleep 5
|
||||||
|
- 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 integration tests
|
||||||
|
env:
|
||||||
|
SNAPSHOT_MODE: postgres
|
||||||
|
SNAPSHOT_BLOCK_HEIGHT: 32
|
||||||
|
LEVELDB_PATH: ./fixture/chain2data
|
||||||
|
LEVELDB_ANCIENT: ./fixture/chain2data/ancient
|
||||||
|
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 18 ]]
|
||||||
|
do sleep 1; 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)" = 5 ]]
|
||||||
|
[[ "$(count_results eth.storage_cids)" = 13 ]]
|
30
.github/workflows/on-pr.yaml
vendored
30
.github/workflows/on-pr.yaml
vendored
@ -1,30 +0,0 @@
|
|||||||
name: Docker Build
|
|
||||||
|
|
||||||
on: [pull_request]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test:
|
|
||||||
name: Run unit tests
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
env:
|
|
||||||
GOPATH: /tmp/go
|
|
||||||
GO111MODULE: on
|
|
||||||
steps:
|
|
||||||
- name: Create GOPATH
|
|
||||||
run: mkdir -p /tmp/go
|
|
||||||
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: ">=1.19.0"
|
|
||||||
check-latest: true
|
|
||||||
|
|
||||||
- name: Checkout code
|
|
||||||
uses: actions/checkout@v2
|
|
||||||
|
|
||||||
- name: Run database
|
|
||||||
run: docker-compose up -d
|
|
||||||
|
|
||||||
- name: Run unit tests
|
|
||||||
run: |
|
|
||||||
sleep 45
|
|
||||||
make dbtest
|
|
10
Makefile
10
Makefile
@ -9,15 +9,5 @@ $(MOCKS_DIR)/gen_indexer.go:
|
|||||||
--mock_names Indexer=MockgenIndexer \
|
--mock_names Indexer=MockgenIndexer \
|
||||||
github.com/cerc-io/plugeth-statediff/indexer Indexer
|
github.com/cerc-io/plugeth-statediff/indexer Indexer
|
||||||
|
|
||||||
clean:
|
|
||||||
rm -f mocks/snapshot/publisher.go
|
|
||||||
|
|
||||||
build:
|
|
||||||
go fmt ./...
|
|
||||||
go build
|
|
||||||
|
|
||||||
test: mocks
|
test: mocks
|
||||||
go clean -testcache && go test -p 1 -v ./...
|
go clean -testcache && go test -p 1 -v ./...
|
||||||
|
|
||||||
dbtest: mocks
|
|
||||||
go clean -testcache && TEST_WITH_DB=true go test -p 1 -v ./...
|
|
||||||
|
1
fixture/.gitignore
vendored
1
fixture/.gitignore
vendored
@ -4,4 +4,3 @@
|
|||||||
*/LOG
|
*/LOG
|
||||||
*/MANIFEST-*
|
*/MANIFEST-*
|
||||||
*/ancient/FLOCK
|
*/ancient/FLOCK
|
||||||
*/ancient/*.meta
|
|
||||||
|
@ -142,7 +142,7 @@ func InitDB(c *DBConfig) {
|
|||||||
c.MaxConns = viper.GetInt(DATABASE_MAX_OPEN_CONNECTIONS_TOML)
|
c.MaxConns = viper.GetInt(DATABASE_MAX_OPEN_CONNECTIONS_TOML)
|
||||||
c.MaxConnLifetime = time.Duration(viper.GetInt(DATABASE_MAX_CONN_LIFETIME_TOML)) * time.Second
|
c.MaxConnLifetime = time.Duration(viper.GetInt(DATABASE_MAX_CONN_LIFETIME_TOML)) * time.Second
|
||||||
|
|
||||||
c.Driver = postgres.PGX
|
c.Driver = postgres.SQLX
|
||||||
}
|
}
|
||||||
|
|
||||||
func InitFile(c *FileConfig) error {
|
func InitFile(c *FileConfig) error {
|
||||||
|
25
test/ci-config.toml
Normal file
25
test/ci-config.toml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
[database]
|
||||||
|
name = "cerc_testing"
|
||||||
|
hostname = "127.0.0.1"
|
||||||
|
port = 8077
|
||||||
|
user = "vdbm"
|
||||||
|
password = "password"
|
||||||
|
|
||||||
|
[log]
|
||||||
|
level = "debug"
|
||||||
|
|
||||||
|
[snapshot]
|
||||||
|
mode = "postgres"
|
||||||
|
workers = 4
|
||||||
|
blockHeight = 0
|
||||||
|
recoveryFile = "snapshot_recovery_file"
|
||||||
|
|
||||||
|
[file]
|
||||||
|
outputDir = "test-output"
|
||||||
|
|
||||||
|
[ethereum]
|
||||||
|
clientName = "test-client"
|
||||||
|
nodeID = "test-node"
|
||||||
|
networkID = "test-network"
|
||||||
|
chainID = 1
|
||||||
|
genesisBlock = "0x37cbb63c7150a7b60f2878433963ed8ba7e5f82fb2683ec7a945c974e1cf4e05"
|
@ -1,5 +1,3 @@
|
|||||||
version: '3.2'
|
|
||||||
|
|
||||||
services:
|
services:
|
||||||
migrations:
|
migrations:
|
||||||
restart: on-failure
|
restart: on-failure
|
||||||
@ -22,6 +20,6 @@ services:
|
|||||||
POSTGRES_DB: "cerc_testing"
|
POSTGRES_DB: "cerc_testing"
|
||||||
POSTGRES_PASSWORD: "password"
|
POSTGRES_PASSWORD: "password"
|
||||||
ports:
|
ports:
|
||||||
- "127.0.0.1:8077:5432"
|
- 0.0.0.0:8077:5432
|
||||||
volumes:
|
volumes:
|
||||||
- /tmp:/tmp
|
- /tmp:/tmp
|
Loading…
Reference in New Issue
Block a user