diff --git a/.vscode/tasks.json b/.vscode/tasks.json index ab56522001c..2bae461cc39 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -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 + } } ] } \ No newline at end of file diff --git a/Makefile b/Makefile index efc9b0de000..ec10c98994a 100644 --- a/Makefile +++ b/Makefile @@ -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 ### ############################################################################### @@ -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) diff --git a/app/apptesting/test_suite.go b/app/apptesting/test_suite.go index e84228585db..12e971a4452 100644 --- a/app/apptesting/test_suite.go +++ b/app/apptesting/test_suite.go @@ -3,6 +3,7 @@ package apptesting import ( "encoding/json" "fmt" + "os" "testing" "time" @@ -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) diff --git a/app/upgrades/v13/upgrade_test.go b/app/upgrades/v13/upgrade_test.go index 96c49800f25..77aeb9f02e5 100644 --- a/app/upgrades/v13/upgrade_test.go +++ b/app/upgrades/v13/upgrade_test.go @@ -46,6 +46,7 @@ func dummyUpgrade(suite *UpgradeTestSuite) { } func (suite *UpgradeTestSuite) TestUpgrade() { + suite.SkipIfWSL() testCases := []struct { name string pre_upgrade func() diff --git a/app/upgrades/v15/upgrade_test.go b/app/upgrades/v15/upgrade_test.go index 00ac4265ecc..080a3a9400a 100644 --- a/app/upgrades/v15/upgrade_test.go +++ b/app/upgrades/v15/upgrade_test.go @@ -37,6 +37,7 @@ var DefaultAcctFunds sdk.Coins = sdk.NewCoins( func (suite *UpgradeTestSuite) SetupTest() { suite.Setup() + suite.SkipIfWSL() } func TestUpgradeTestSuite(t *testing.T) { diff --git a/tests/ibc-hooks/ibc_middleware_test.go b/tests/ibc-hooks/ibc_middleware_test.go index 9ff7dd0f019..e2653295374 100644 --- a/tests/ibc-hooks/ibc_middleware_test.go +++ b/tests/ibc-hooks/ibc_middleware_test.go @@ -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() diff --git a/wasmbinding/test/custom_msg_test.go b/wasmbinding/test/custom_msg_test.go index 0ee914b02b0..268060c726d 100644 --- a/wasmbinding/test/custom_msg_test.go +++ b/wasmbinding/test/custom_msg_test.go @@ -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" @@ -18,6 +19,7 @@ import ( ) func TestCreateDenomMsg(t *testing.T) { + apptesting.SkipIfWSL(t) creator := RandomAccountAddress() osmosis, ctx := SetupCustomApp(t, creator) @@ -49,6 +51,7 @@ func TestCreateDenomMsg(t *testing.T) { } func TestMintMsg(t *testing.T) { + apptesting.SkipIfWSL(t) creator := RandomAccountAddress() osmosis, ctx := SetupCustomApp(t, creator) @@ -177,6 +180,7 @@ func TestMintMsg(t *testing.T) { } func TestBurnMsg(t *testing.T) { + apptesting.SkipIfWSL(t) creator := RandomAccountAddress() osmosis, ctx := SetupCustomApp(t, creator) diff --git a/wasmbinding/test/custom_query_test.go b/wasmbinding/test/custom_query_test.go index c3c92d0b5c3..999661539ba 100644 --- a/wasmbinding/test/custom_query_test.go +++ b/wasmbinding/test/custom_query_test.go @@ -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" ) @@ -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) diff --git a/wasmbinding/test/messages_test.go b/wasmbinding/test/messages_test.go index 39dec5a8216..28d8b25dfa9 100644 --- a/wasmbinding/test/messages_test.go +++ b/wasmbinding/test/messages_test.go @@ -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" @@ -14,6 +15,7 @@ import ( ) func TestCreateDenom(t *testing.T) { + apptesting.SkipIfWSL(t) actor := RandomAccountAddress() osmosis, ctx := SetupCustomApp(t, actor) @@ -62,6 +64,7 @@ func TestCreateDenom(t *testing.T) { } func TestChangeAdmin(t *testing.T) { + apptesting.SkipIfWSL(t) const validDenom = "validdenom" tokenCreator := RandomAccountAddress() @@ -166,6 +169,7 @@ func TestChangeAdmin(t *testing.T) { } func TestMint(t *testing.T) { + apptesting.SkipIfWSL(t) creator := RandomAccountAddress() osmosis, ctx := SetupCustomApp(t, creator) @@ -285,6 +289,7 @@ func TestMint(t *testing.T) { } func TestBurn(t *testing.T) { + apptesting.SkipIfWSL(t) creator := RandomAccountAddress() osmosis, ctx := SetupCustomApp(t, creator) diff --git a/wasmbinding/test/queries_test.go b/wasmbinding/test/queries_test.go index 10a64764abc..0167ecc1315 100644 --- a/wasmbinding/test/queries_test.go +++ b/wasmbinding/test/queries_test.go @@ -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" ) @@ -63,6 +64,7 @@ func TestFullDenom(t *testing.T) { } func TestDenomAdmin(t *testing.T) { + apptesting.SkipIfWSL(t) addr := RandomAccountAddress() app, ctx := SetupCustomApp(t, addr) diff --git a/wasmbinding/test/store_run_test.go b/wasmbinding/test/store_run_test.go index 64f7f70b160..191154e3d9d 100644 --- a/wasmbinding/test/store_run_test.go +++ b/wasmbinding/test/store_run_test.go @@ -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) { @@ -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 @@ -83,6 +85,7 @@ type HackatomExampleInitMsg struct { } func TestInstantiateContract(t *testing.T) { + apptesting.SkipIfWSL(t) osmosis, ctx := CreateTestInput() funder := RandomAccountAddress() benefit, arb := RandomAccountAddress(), RandomAccountAddress() diff --git a/x/ibc-rate-limit/ibc_middleware_test.go b/x/ibc-rate-limit/ibc_middleware_test.go index fbdfb014a6e..4b5b55e01fb 100644 --- a/x/ibc-rate-limit/ibc_middleware_test.go +++ b/x/ibc-rate-limit/ibc_middleware_test.go @@ -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() diff --git a/x/tokenfactory/keeper/before_send_test.go b/x/tokenfactory/keeper/before_send_test.go index ca018cba2f3..2acca3886b1 100644 --- a/x/tokenfactory/keeper/before_send_test.go +++ b/x/tokenfactory/keeper/before_send_test.go @@ -18,6 +18,7 @@ type SendMsgTestCase struct { } func (suite *KeeperTestSuite) TestBeforeSendHook() { + suite.SkipIfWSL() for _, tc := range []struct { desc string wasmFile string