Skip to content

Commit

Permalink
test: add make test-nightly command (PundiAI#272)
Browse files Browse the repository at this point in the history
  • Loading branch information
zakir-code authored Mar 26, 2024
1 parent 99d3125 commit 7a1796d
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 29 deletions.
16 changes: 2 additions & 14 deletions .github/workflows/nightly-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,11 @@ concurrency:
cancel-in-progress: true

jobs:
integration:
main:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: 1.21

- name: Run go mod
run: make go.sum

- name: Run TestIntegrationTest
run: go test -mod=readonly -v -run TestIntegrationTest ./tests
env:
TEST_INTEGRATION: true

- name: Run TestCrosschainKeeperTestSuite
run: go test -mod=readonly -v -run TestCrosschainKeeperTestSuite ./x/crosschain/...
env:
TEST_INTEGRATION: true
- run: make test-nightly
4 changes: 4 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,10 @@ test:
test-count:
go test -mod=readonly -cpu 1 -count 1 -cover ./... | grep -v 'types\|cli\|no test files'

test-nightly:
@TEST_INTEGRATION=true go test -mod=readonly -v -run TestIntegrationTest ./tests
@TEST_CROSSCHAIN=true go test -mod=readonly -v -run TestCrosschainKeeperTestSuite ./x/crosschain/...

.PHONY: test

###############################################################################
Expand Down
29 changes: 25 additions & 4 deletions tests/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,18 @@ package tests

import (
"os"
"runtime"
"testing"

"github.com/stretchr/testify/suite"

arbitrumtypes "github.com/functionx/fx-core/v7/x/arbitrum/types"
avalanchetypes "github.com/functionx/fx-core/v7/x/avalanche/types"
bsctypes "github.com/functionx/fx-core/v7/x/bsc/types"
ethtypes "github.com/functionx/fx-core/v7/x/eth/types"
layer2types "github.com/functionx/fx-core/v7/x/layer2/types"
optimismtypes "github.com/functionx/fx-core/v7/x/optimism/types"
polygontypes "github.com/functionx/fx-core/v7/x/polygon/types"
trontypes "github.com/functionx/fx-core/v7/x/tron/types"
)

Expand All @@ -26,20 +32,35 @@ func TestIntegrationTest(t *testing.T) {
}

testSuite := NewTestSuite()
suite.Run(t, &IntegrationTest{
testingSuite := &IntegrationTest{
TestSuite: testSuite,
crosschain: []CrosschainTestSuite{
NewCrosschainWithTestSuite(ethtypes.ModuleName, testSuite),
NewCrosschainWithTestSuite(bsctypes.ModuleName, testSuite),
NewCrosschainWithTestSuite(trontypes.ModuleName, testSuite),
// NewCrosschainWithTestSuite(polygontypes.ModuleName, testSuite),
// NewCrosschainWithTestSuite(avalanchetypes.ModuleName, testSuite),
},
erc20: NewErc20TestSuite(testSuite),
evm: NewEvmTestSuite(testSuite),
staking: NewStakingSuite(testSuite),
precompile: NewPrecompileTestSuite(testSuite),
})
}
if runtime.GOOS == "linux" {
evmChainModules := []string{
polygontypes.ModuleName,
avalanchetypes.ModuleName,
arbitrumtypes.ModuleName,
optimismtypes.ModuleName,
layer2types.ModuleName,
}
for _, module := range evmChainModules {
testingSuite.crosschain = append(
testingSuite.crosschain,
NewCrosschainWithTestSuite(module, testSuite),
)
}
}

suite.Run(t, testingSuite)
}

func (suite *IntegrationTest) TestRun() {
Expand Down
21 changes: 10 additions & 11 deletions x/crosschain/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import (
"github.com/functionx/fx-core/v7/x/crosschain/keeper"
"github.com/functionx/fx-core/v7/x/crosschain/types"
ethtypes "github.com/functionx/fx-core/v7/x/eth/types"
layer2types "github.com/functionx/fx-core/v7/x/layer2/types"
optimismtypes "github.com/functionx/fx-core/v7/x/optimism/types"
polygontypes "github.com/functionx/fx-core/v7/x/polygon/types"
tronkeeper "github.com/functionx/fx-core/v7/x/tron/keeper"
Expand All @@ -49,21 +50,19 @@ func TestCrosschainKeeperTestSuite(t *testing.T) {
compile := regexp.MustCompile("^Test")
mustTestModule := []string{
trontypes.ModuleName,
}
otherModules := []string{
ethtypes.ModuleName,
bsctypes.ModuleName,
polygontypes.ModuleName,
avalanchetypes.ModuleName,
arbitrumtypes.ModuleName,
optimismtypes.ModuleName,
}

subModules := mustTestModule
if os.Getenv("TEST_INTEGRATION") != "true" {
subModules = append(subModules, otherModules[tmrand.Int63n(int64(len(otherModules)))])
} else {
subModules = append(subModules, otherModules...)
if os.Getenv("TEST_CROSSCHAIN") == "true" {
subModules = append(subModules, []string{
bsctypes.ModuleName,
polygontypes.ModuleName,
avalanchetypes.ModuleName,
arbitrumtypes.ModuleName,
optimismtypes.ModuleName,
layer2types.ModuleName,
}...)
}

for _, moduleName := range subModules {
Expand Down

0 comments on commit 7a1796d

Please sign in to comment.