Skip to content

Commit

Permalink
tests: test that erigon can be used as a library (#8494)
Browse files Browse the repository at this point in the history
  • Loading branch information
battlmonstr authored Nov 1, 2023
1 parent 3698e7f commit 35696af
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 8 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ jobs:
- name: test-integration
run: make test-integration

- name: Test erigon as a library
env:
GIT_COMMIT: ${{ github.event.pull_request.head.sha || github.sha }}
run: make test-erigon-ext GIT_COMMIT=$GIT_COMMIT

# name: history-v3-test-integration
# run: make test3-integration

Expand Down
18 changes: 10 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -140,22 +140,24 @@ db-tools:
rm -rf vendor
@echo "Run \"$(GOBIN)/mdbx_stat -h\" to get info about mdbx db file."

## test: run unit tests with a 100s timeout
test:
test-erigon-lib:
@cd erigon-lib && $(MAKE) test

test-erigon-ext:
@cd tests/erigon-ext-test && ./test.sh $(GIT_COMMIT)

## test: run unit tests with a 100s timeout
test: test-erigon-lib
$(GOTEST) --timeout 10m

test3:
@cd erigon-lib && $(MAKE) test
test3: test-erigon-lib
$(GOTEST) --timeout 10m -tags $(BUILD_TAGS),e3

## test-integration: run integration tests with a 30m timeout
test-integration:
@cd erigon-lib && $(MAKE) test
test-integration: test-erigon-lib
$(GOTEST) --timeout 240m -tags $(BUILD_TAGS),integration

test3-integration:
@cd erigon-lib && $(MAKE) test
test3-integration: test-erigon-lib
$(GOTEST) --timeout 240m -tags $(BUILD_TAGS),integration,e3

## lint-deps: install lint dependencies
Expand Down
1 change: 1 addition & 0 deletions tests/erigon-ext-test/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
go.sum
2 changes: 2 additions & 0 deletions tests/erigon-ext-test/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// this is a dummy file needed to exclude this folder from the root folder unit tests suite
// the actual go.mod for the test is generated by test.sh from go.mod.template
9 changes: 9 additions & 0 deletions tests/erigon-ext-test/go.mod.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module example.com/erigon-ext-test

go 1.20

require github.com/ledgerwatch/erigon $COMMIT_SHA

replace github.com/ledgerwatch/erigon-lib => github.com/ledgerwatch/erigon/erigon-lib $COMMIT_SHA

require github.com/ethereum/go-ethereum v1.13.3
18 changes: 18 additions & 0 deletions tests/erigon-ext-test/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package main

import (
geth_params "github.com/ethereum/go-ethereum/params"
// geth_crypto "github.com/ethereum/go-ethereum/crypto"
erigon_lib_common "github.com/ledgerwatch/erigon-lib/common"
erigon_crypto "github.com/ledgerwatch/erigon/crypto"
erigon_params "github.com/ledgerwatch/erigon/params"
)

func main() {
println("Erigon version: ", erigon_params.Version)
println("geth version: ", geth_params.Version)
println("Erigon lib common eth Wei: ", erigon_lib_common.Wei)
println("Erigon crypto secp256k1 S256 BitSize: ", erigon_crypto.S256().Params().BitSize)
// not working due to duplicate symbols errors
// println("geth crypto secp256k1 S256 BitSize: ", geth_crypto.S256().Params().BitSize)
}
10 changes: 10 additions & 0 deletions tests/erigon-ext-test/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash

COMMIT_SHA="$1"

sed "s/\$COMMIT_SHA/$COMMIT_SHA/" go.mod.template > go.mod

rm -f go.sum
go mod tidy

go run main.go

0 comments on commit 35696af

Please sign in to comment.