Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: skip wasm tests in wsl and add a vs code task #5214

Merged
merged 2 commits into from
May 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,16 @@
"label": "e2e-setup",
"type": "shell",
"command": "make e2e-setup"
},
{
"label": "test-unit",
"type": "shell",
"command": "make test-unit",
"problemMatcher": [],
"group": {
"kind": "test",
"isDefault": true
}
}
]
}
15 changes: 14 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,19 @@ ifeq (,$(findstring nostrip,$(OSMOSIS_BUILD_OPTIONS)))
BUILD_FLAGS += -trimpath
endif

# Note that this skips certain tests that are not supported on WSL
# This is a workaround to enable quickly running full unit test suite locally
# on WSL without failures. The failures are stemming from trying to upload
# wasm code. An OS permissioning issue.
is_wsl := $(shell uname -a | grep -i Microsoft)
ifeq ($(is_wsl),)
# Not in WSL
SKIP_WASM_WSL_TESTS := "false"
else
# In WSL
SKIP_WASM_WSL_TESTS := "true"
endif

###############################################################################
### Build ###
###############################################################################
Expand Down Expand Up @@ -252,7 +265,7 @@ test: test-unit test-build
test-all: test-race test-cover

test-unit:
@VERSION=$(VERSION) go test -mod=readonly -tags='ledger test_ledger_mock norace' $(PACKAGES_UNIT)
@VERSION=$(VERSION) SKIP_WASM_WSL_TESTS=$(SKIP_WASM_WSL_TESTS) go test -mod=readonly -tags='ledger test_ledger_mock norace' $(PACKAGES_UNIT)

test-race:
@VERSION=$(VERSION) go test -mod=readonly -race -tags='ledger test_ledger_mock' $(PACKAGES_UNIT)
Expand Down
18 changes: 18 additions & 0 deletions app/apptesting/test_suite.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package apptesting
import (
"encoding/json"
"fmt"
"os"
"testing"
"time"

Expand Down Expand Up @@ -388,6 +389,23 @@ func (s *KeeperTestHelper) StateNotAltered() {
s.Require().Equal(oldState, newState)
}

func (s *KeeperTestHelper) SkipIfWSL() {
SkipIfWSL(s.T())
}

// SkipIfWSL skips tests if running on WSL
// This is a workaround to enable quickly running full unit test suite locally
// on WSL without failures. The failures are stemming from trying to upload
// wasm code. An OS permissioning issue.
func SkipIfWSL(t *testing.T) {
t.Helper()
skip := os.Getenv("SKIP_WASM_WSL_TESTS")
fmt.Println("SKIP_WASM_WSL_TESTS", skip)
if skip == "true" {
t.Skip("Skipping Wasm tests")
}
}

// CreateRandomAccounts is a function return a list of randomly generated AccAddresses
func CreateRandomAccounts(numAccts int) []sdk.AccAddress {
testAddrs := make([]sdk.AccAddress, numAccts)
Expand Down
1 change: 1 addition & 0 deletions app/upgrades/v13/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ func dummyUpgrade(suite *UpgradeTestSuite) {
}

func (suite *UpgradeTestSuite) TestUpgrade() {
suite.SkipIfWSL()
testCases := []struct {
name string
pre_upgrade func()
Expand Down
1 change: 1 addition & 0 deletions app/upgrades/v15/upgrade_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var DefaultAcctFunds sdk.Coins = sdk.NewCoins(

func (suite *UpgradeTestSuite) SetupTest() {
suite.Setup()
suite.SkipIfWSL()
}

func TestUpgradeTestSuite(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions tests/ibc-hooks/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ func TestIBCHooksTestSuite(t *testing.T) {
}

func (suite *HooksTestSuite) SetupTest() {
suite.SkipIfWSL()
// TODO: This needs to get removed. Waiting on https://github.com/cosmos/ibc-go/issues/3123
txfeetypes.ConsensusMinFee = sdk.ZeroDec()
suite.Setup()
Expand Down
4 changes: 4 additions & 0 deletions wasmbinding/test/custom_msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"fmt"
"testing"

"github.com/osmosis-labs/osmosis/v15/app/apptesting"
"github.com/osmosis-labs/osmosis/v15/x/tokenfactory/types"

"github.com/stretchr/testify/require"
Expand All @@ -18,6 +19,7 @@ import (
)

func TestCreateDenomMsg(t *testing.T) {
apptesting.SkipIfWSL(t)
creator := RandomAccountAddress()
osmosis, ctx := SetupCustomApp(t, creator)

Expand Down Expand Up @@ -49,6 +51,7 @@ func TestCreateDenomMsg(t *testing.T) {
}

func TestMintMsg(t *testing.T) {
apptesting.SkipIfWSL(t)
creator := RandomAccountAddress()
osmosis, ctx := SetupCustomApp(t, creator)

Expand Down Expand Up @@ -177,6 +180,7 @@ func TestMintMsg(t *testing.T) {
}

func TestBurnMsg(t *testing.T) {
apptesting.SkipIfWSL(t)
creator := RandomAccountAddress()
osmosis, ctx := SetupCustomApp(t, creator)

Expand Down
2 changes: 2 additions & 0 deletions wasmbinding/test/custom_query_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v15/app"
"github.com/osmosis-labs/osmosis/v15/app/apptesting"
"github.com/osmosis-labs/osmosis/v15/wasmbinding/bindings"
)

Expand All @@ -34,6 +35,7 @@ func SetupCustomApp(t *testing.T, addr sdk.AccAddress) (*app.OsmosisApp, sdk.Con
}

func TestQueryFullDenom(t *testing.T) {
apptesting.SkipIfWSL(t)
actor := RandomAccountAddress()
osmosis, ctx := SetupCustomApp(t, actor)

Expand Down
5 changes: 5 additions & 0 deletions wasmbinding/test/messages_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v15/app/apptesting"
"github.com/osmosis-labs/osmosis/v15/wasmbinding"
"github.com/osmosis-labs/osmosis/v15/wasmbinding/bindings"
"github.com/osmosis-labs/osmosis/v15/x/tokenfactory/types"
Expand All @@ -14,6 +15,7 @@ import (
)

func TestCreateDenom(t *testing.T) {
apptesting.SkipIfWSL(t)
actor := RandomAccountAddress()
osmosis, ctx := SetupCustomApp(t, actor)

Expand Down Expand Up @@ -62,6 +64,7 @@ func TestCreateDenom(t *testing.T) {
}

func TestChangeAdmin(t *testing.T) {
apptesting.SkipIfWSL(t)
const validDenom = "validdenom"

tokenCreator := RandomAccountAddress()
Expand Down Expand Up @@ -166,6 +169,7 @@ func TestChangeAdmin(t *testing.T) {
}

func TestMint(t *testing.T) {
apptesting.SkipIfWSL(t)
creator := RandomAccountAddress()
osmosis, ctx := SetupCustomApp(t, creator)

Expand Down Expand Up @@ -285,6 +289,7 @@ func TestMint(t *testing.T) {
}

func TestBurn(t *testing.T) {
apptesting.SkipIfWSL(t)
creator := RandomAccountAddress()
osmosis, ctx := SetupCustomApp(t, creator)

Expand Down
2 changes: 2 additions & 0 deletions wasmbinding/test/queries_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v15/app/apptesting"
"github.com/osmosis-labs/osmosis/v15/wasmbinding"
)

Expand Down Expand Up @@ -63,6 +64,7 @@ func TestFullDenom(t *testing.T) {
}

func TestDenomAdmin(t *testing.T) {
apptesting.SkipIfWSL(t)
addr := RandomAccountAddress()
app, ctx := SetupCustomApp(t, addr)

Expand Down
3 changes: 3 additions & 0 deletions wasmbinding/test/store_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
sdk "github.com/cosmos/cosmos-sdk/types"

"github.com/osmosis-labs/osmosis/v15/app"
"github.com/osmosis-labs/osmosis/v15/app/apptesting"
)

func TestNoStorageWithoutProposal(t *testing.T) {
Expand Down Expand Up @@ -58,6 +59,7 @@ func storeCodeViaProposal(t *testing.T, ctx sdk.Context, osmosis *app.OsmosisApp
}

func TestStoreCodeProposal(t *testing.T) {
apptesting.SkipIfWSL(t)
osmosis, ctx := CreateTestInput()
myActorAddress := RandomAccountAddress()
wasmKeeper := osmosis.WasmKeeper
Expand All @@ -83,6 +85,7 @@ type HackatomExampleInitMsg struct {
}

func TestInstantiateContract(t *testing.T) {
apptesting.SkipIfWSL(t)
osmosis, ctx := CreateTestInput()
funder := RandomAccountAddress()
benefit, arb := RandomAccountAddress(), RandomAccountAddress()
Expand Down
1 change: 1 addition & 0 deletions x/ibc-rate-limit/ibc_middleware_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func NewTransferPath(chainA, chainB *osmosisibctesting.TestChain) *ibctesting.Pa
}

func (suite *MiddlewareTestSuite) SetupTest() {
suite.SkipIfWSL()
// TODO: This needs to get removed. Waiting on https://github.com/cosmos/ibc-go/issues/3123
txfeetypes.ConsensusMinFee = sdk.ZeroDec()
suite.Setup()
Expand Down
1 change: 1 addition & 0 deletions x/tokenfactory/keeper/before_send_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type SendMsgTestCase struct {
}

func (suite *KeeperTestSuite) TestBeforeSendHook() {
suite.SkipIfWSL()
for _, tc := range []struct {
desc string
wasmFile string
Expand Down