diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index d354b2a0..2cbb0f3e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -22,6 +22,9 @@ jobs: - name: Run unit tests run: ./stack unit-tests + - name: Run hardhat unit tests + run: ./stack unit-tests-hardhat + run-integration-tests: runs-on: ubuntu-latest steps: diff --git a/LOCAL_DEVELOPMENT.md b/LOCAL_DEVELOPMENT.md index fb3c76a0..de61b9d4 100644 --- a/LOCAL_DEVELOPMENT.md +++ b/LOCAL_DEVELOPMENT.md @@ -80,7 +80,9 @@ Once all the services are up and running this command can be used to trigger an ### Tests -There are two commands that can be used to run existing tests: `./stack unit-tests` and `./stack integration-tests` (bear in mind the latter expects a blockchain node to be running locally). +Run the Go unit tests with `./stack unit-tests` and the Hardhat unit tests with `./stack unit-tests-hardhat`. + +Run the integration tests with `./stack integration-tests`. The integration tests expect all parts of the stack are running, except the request to run a job. See [Using Docker Compose](./LOCAL_DEVELOPMENT.md#using-docker-compose) to run the stack. ## Notes on tooling diff --git a/pkg/module/utils_test.go b/pkg/module/utils_test.go index 1a69eff5..81e6e747 100644 --- a/pkg/module/utils_test.go +++ b/pkg/module/utils_test.go @@ -1,3 +1,5 @@ +//go:build unit + package module import ( diff --git a/pkg/resourceprovider/cpuworker_test.go b/pkg/resourceprovider/cpuworker_test.go index 5589fb3f..de621244 100644 --- a/pkg/resourceprovider/cpuworker_test.go +++ b/pkg/resourceprovider/cpuworker_test.go @@ -1,3 +1,5 @@ +//go:build unit + package resourceprovider import ( diff --git a/pkg/solver/matcher/matcher_test.go b/pkg/solver/matcher/matcher_test.go index 15b2e00b..5d5924e8 100644 --- a/pkg/solver/matcher/matcher_test.go +++ b/pkg/solver/matcher/matcher_test.go @@ -1,3 +1,5 @@ +//go:build unit + package matcher import ( diff --git a/test/ratelimit_test.go b/pkg/solver/ratelimit_test.go similarity index 97% rename from test/ratelimit_test.go rename to pkg/solver/ratelimit_test.go index f32df4b3..3b240d93 100644 --- a/test/ratelimit_test.go +++ b/pkg/solver/ratelimit_test.go @@ -1,4 +1,6 @@ -package main +//go:build integration + +package solver_test import ( "fmt" diff --git a/pkg/system/otel_test.go b/pkg/system/otel_test.go index 3b26adbf..658d72e5 100644 --- a/pkg/system/otel_test.go +++ b/pkg/system/otel_test.go @@ -1,3 +1,5 @@ +//go:build unit + package system import "testing" diff --git a/pkg/web3/sdk_test.go b/pkg/web3/sdk_test.go index 6ac848a1..ee493cff 100644 --- a/pkg/web3/sdk_test.go +++ b/pkg/web3/sdk_test.go @@ -1,3 +1,5 @@ +//go:build unit + package web3_test import ( @@ -5,13 +7,14 @@ import ( "crypto/ecdsa" "errors" "fmt" - "github.com/ethereum/go-ethereum/crypto" - "golang.org/x/crypto/sha3" "log" "math/big" "os" "testing" + "github.com/ethereum/go-ethereum/crypto" + "golang.org/x/crypto/sha3" + "github.com/BurntSushi/toml" "github.com/lilypad-tech/lilypad/pkg/options" "github.com/lilypad-tech/lilypad/pkg/system" @@ -65,6 +68,8 @@ func CreateTestWeb3SDK() (*web3.Web3SDK, error) { } func TestGetBalance(t *testing.T) { + t.Skip("Issue: https://github.com/Lilypad-Tech/lilypad/issues/385") + sdk, err := CreateTestWeb3SDK() if err != nil { t.Fatalf("Failed to create Web3SDK: %v", err) @@ -78,6 +83,8 @@ func TestGetBalance(t *testing.T) { } func TestGetLPBalance(t *testing.T) { + t.Skip("Issue: https://github.com/Lilypad-Tech/lilypad/issues/385") + sdk, err := CreateTestWeb3SDK() if err != nil { t.Fatalf("Failed to create Web3SDK: %v", err) @@ -90,6 +97,8 @@ func TestGetLPBalance(t *testing.T) { } func TestGetLPBalanceNoBalance(t *testing.T) { + t.Skip("Issue: https://github.com/Lilypad-Tech/lilypad/issues/385") + sdk, err := CreateTestWeb3SDK() noBalanceInt := big.NewInt(0) if err != nil { @@ -114,6 +123,8 @@ func TestGetLPBalanceNoBalance(t *testing.T) { } func TestGetBlockNumber(t *testing.T) { + t.Skip("Issue: https://github.com/Lilypad-Tech/lilypad/issues/385") + sdk, err := CreateTestWeb3SDK() if err != nil { t.Fatalf("Failed to create Web3SDK: %v", err) diff --git a/pkg/web3/utils_test.go b/pkg/web3/utils_test.go index 4b666d90..1e8a56b5 100644 --- a/pkg/web3/utils_test.go +++ b/pkg/web3/utils_test.go @@ -1,3 +1,5 @@ +//go:build unit + package web3 import ( diff --git a/stack b/stack index 9dc7974d..3521d307 100755 --- a/stack +++ b/stack @@ -237,6 +237,10 @@ function mediator() { ############################################################################ function unit-tests() { + go test -v -tags="unit" -count 1 ./... +} + +function unit-tests-hardhat() { cd hardhat npx hardhat test --network hardhat } @@ -245,8 +249,7 @@ function unit-tests() { # see LOCAL_DEVELOPMENT.md function integration-tests() { load-local-env - cd test - go test -v -count 1 . + go test -v -tags="integration" -count 1 ./... } ############################################################################ diff --git a/test/integration_test.go b/test/integration_test.go index 881ae9ca..38ecd6d9 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -1,4 +1,6 @@ -package main +//go:build integration + +package main_test import ( "fmt"