Skip to content

Commit 564fe64

Browse files
authored
test: Add test build tags (#460)
* test: Tag integration tests * test: Tag unit tests * test: Move rate limit test alongside solver * test: Move integration test to main_test package * docs: Update testing instructions * test: Update stack test commands Adds a command for Go unit tests. * test: Skip broken tests We have an issue for them at #385. * test: Update tests with separate Go and Hardhat unit tests
1 parent d679ea3 commit 564fe64

File tree

11 files changed

+40
-7
lines changed

11 files changed

+40
-7
lines changed

.github/workflows/test.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ jobs:
2222
- name: Run unit tests
2323
run: ./stack unit-tests
2424

25+
- name: Run hardhat unit tests
26+
run: ./stack unit-tests-hardhat
27+
2528
run-integration-tests:
2629
runs-on: ubuntu-latest
2730
steps:

LOCAL_DEVELOPMENT.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,9 @@ Once all the services are up and running this command can be used to trigger an
8080

8181
### Tests
8282

83-
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).
83+
Run the Go unit tests with `./stack unit-tests` and the Hardhat unit tests with `./stack unit-tests-hardhat`.
84+
85+
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.
8486

8587
## Notes on tooling
8688

pkg/module/utils_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build unit
2+
13
package module
24

35
import (

pkg/resourceprovider/cpuworker_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build unit
2+
13
package resourceprovider
24

35
import (

pkg/solver/matcher/matcher_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build unit
2+
13
package matcher
24

35
import (

test/ratelimit_test.go renamed to pkg/solver/ratelimit_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
package main
1+
//go:build integration
2+
3+
package solver_test
24

35
import (
46
"fmt"

pkg/system/otel_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build unit
2+
13
package system
24

35
import "testing"

pkg/web3/sdk_test.go

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
1+
//go:build unit
2+
13
package web3_test
24

35
import (
46
"context"
57
"crypto/ecdsa"
68
"errors"
79
"fmt"
8-
"github.com/ethereum/go-ethereum/crypto"
9-
"golang.org/x/crypto/sha3"
1010
"log"
1111
"math/big"
1212
"os"
1313
"testing"
1414

15+
"github.com/ethereum/go-ethereum/crypto"
16+
"golang.org/x/crypto/sha3"
17+
1518
"github.com/BurntSushi/toml"
1619
"github.com/lilypad-tech/lilypad/pkg/options"
1720
"github.com/lilypad-tech/lilypad/pkg/system"
@@ -65,6 +68,8 @@ func CreateTestWeb3SDK() (*web3.Web3SDK, error) {
6568
}
6669

6770
func TestGetBalance(t *testing.T) {
71+
t.Skip("Issue: https://github.com/Lilypad-Tech/lilypad/issues/385")
72+
6873
sdk, err := CreateTestWeb3SDK()
6974
if err != nil {
7075
t.Fatalf("Failed to create Web3SDK: %v", err)
@@ -78,6 +83,8 @@ func TestGetBalance(t *testing.T) {
7883
}
7984

8085
func TestGetLPBalance(t *testing.T) {
86+
t.Skip("Issue: https://github.com/Lilypad-Tech/lilypad/issues/385")
87+
8188
sdk, err := CreateTestWeb3SDK()
8289
if err != nil {
8390
t.Fatalf("Failed to create Web3SDK: %v", err)
@@ -90,6 +97,8 @@ func TestGetLPBalance(t *testing.T) {
9097
}
9198

9299
func TestGetLPBalanceNoBalance(t *testing.T) {
100+
t.Skip("Issue: https://github.com/Lilypad-Tech/lilypad/issues/385")
101+
93102
sdk, err := CreateTestWeb3SDK()
94103
noBalanceInt := big.NewInt(0)
95104
if err != nil {
@@ -114,6 +123,8 @@ func TestGetLPBalanceNoBalance(t *testing.T) {
114123
}
115124

116125
func TestGetBlockNumber(t *testing.T) {
126+
t.Skip("Issue: https://github.com/Lilypad-Tech/lilypad/issues/385")
127+
117128
sdk, err := CreateTestWeb3SDK()
118129
if err != nil {
119130
t.Fatalf("Failed to create Web3SDK: %v", err)

pkg/web3/utils_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
//go:build unit
2+
13
package web3
24

35
import (

stack

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,10 @@ function mediator() {
237237
############################################################################
238238

239239
function unit-tests() {
240+
go test -v -tags="unit" -count 1 ./...
241+
}
242+
243+
function unit-tests-hardhat() {
240244
cd hardhat
241245
npx hardhat test --network hardhat
242246
}
@@ -245,8 +249,7 @@ function unit-tests() {
245249
# see LOCAL_DEVELOPMENT.md
246250
function integration-tests() {
247251
load-local-env
248-
cd test
249-
go test -v -count 1 .
252+
go test -v -tags="integration" -count 1 ./...
250253
}
251254

252255
############################################################################

test/integration_test.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
package main
1+
//go:build integration
2+
3+
package main_test
24

35
import (
46
"fmt"

0 commit comments

Comments
 (0)