tests: test that erigon can be used as a library (#8494)

This commit is contained in:
battlmonstr 2023-11-01 11:44:01 +01:00 committed by GitHub
parent 3698e7f476
commit 35696afca1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 55 additions and 8 deletions

View File

@ -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

View File

@ -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

1
tests/erigon-ext-test/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
go.sum

View File

@ -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

View File

@ -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

View File

@ -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
tests/erigon-ext-test/test.sh Executable file
View File

@ -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