Skip to content

Commit

Permalink
fuzz tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Wojtek committed Apr 5, 2024
1 parent 60d1fa2 commit eda35c2
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/relayer-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ jobs:
ci_step: [
"lint",
"test",
"fuzz-test",
"integration tests contract",
"integration tests processes",
"integration tests xrpl",
Expand All @@ -26,13 +25,7 @@ jobs:
linter-cache: true
docker-cache: false
- ci_step: "test"
command: "coreumbridge-xrpl-builder test"
wasm-cache: false
linter-cache: false
docker-cache: false
# FIXME (wojciech): fuzz tests still use `make` because we need to support them in crust first
- ci_step: "fuzz-test"
command: "make test-fuzz"
command: "coreumbridge-xrpl-builder test fuzz-test"
wasm-cache: false
linter-cache: false
docker-cache: false
Expand Down
21 changes: 21 additions & 0 deletions build/bridge/tests.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package bridge

import (
"context"
"fmt"
"os"
"path/filepath"

Expand Down Expand Up @@ -46,8 +47,28 @@ func RunIntegrationTests(name string) build.CommandFunc {
return golang.RunTests(ctx, deps, golang.TestConfig{
PackagePath: filepath.Join(testsDir, name),
Flags: []string{
"-timeout=20m",
"-tags=integrationtests",
},
})
}
}

// RunFuzzTests runs fuzz tests.
func RunFuzzTests(ctx context.Context, deps build.DepsFunc) error {
if err := runFuzzTest(ctx, deps, "FuzzAmountConversionCoreumToXRPLAndBack"); err != nil {
return err
}
return runFuzzTest(ctx, deps, "FuzzAmountConversionCoreumToXRPLAndBack_ExceedingSignificantNumber")
}

func runFuzzTest(ctx context.Context, deps build.DepsFunc, name string) error {
return golang.RunTests(ctx, deps, golang.TestConfig{
PackagePath: "relayer/processes",
Flags: []string{
"-run", "^$",
"-fuzz", fmt.Sprintf("^%s$", name),
"-fuzztime", "20s",
},
})
}
1 change: 1 addition & 0 deletions build/index.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var Commands = map[string]build.Command{
"build/relayer": {Fn: bridge.BuildRelayer, Description: "Builds relayer"},
"build/contract": {Fn: bridge.BuildSmartContract, Description: "Builds smart contract"},
"download": {Fn: bridge.DownloadDependencies, Description: "Downloads go dependencies"},
"fuzz-test": {Fn: bridge.RunFuzzTests, Description: "Runs fuzz tests"},
"generate": {Fn: bridge.Generate, Description: "Generates artifacts"},
"images": {Fn: bridge.BuildRelayerDockerImage, Description: "Builds relayer docker image"},
"integration-tests": {Fn: bridge.RunAllIntegrationTests, Description: "Runs integration tests"},
Expand Down

0 comments on commit eda35c2

Please sign in to comment.