Skip to content

Commit

Permalink
move tests to integration folder
Browse files Browse the repository at this point in the history
  • Loading branch information
tac0turtle committed Aug 29, 2024
1 parent 1d0c66c commit 4f425ed
Show file tree
Hide file tree
Showing 13 changed files with 507 additions and 277 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasm
package integration

import (
"encoding/json"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasm_test
package integration

import (
"encoding/base64"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package keeper_test
package integration

import (
"testing"
Expand Down
9 changes: 5 additions & 4 deletions x/wasm/module_test.go → tests/integration/module_test.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package wasm
package integration

import (
"bytes"
Expand All @@ -24,6 +24,7 @@ import (
stakingkeeper "github.com/cosmos/cosmos-sdk/x/staking/keeper"

"github.com/CosmWasm/wasmd/app/params"
"github.com/CosmWasm/wasmd/x/wasm"
"github.com/CosmWasm/wasmd/x/wasm/exported"
"github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/CosmWasm/wasmd/x/wasm/keeper/testdata"
Expand All @@ -44,7 +45,7 @@ func (ms mockSubspace) GetParamSet(ctx sdk.Context, ps exported.ParamSet) {
}

type testData struct {
module AppModule
module wasm.AppModule
ctx sdk.Context
acctKeeper authkeeper.AccountKeeper
keeper keeper.Keeper
Expand Down Expand Up @@ -73,7 +74,7 @@ func setupTest(t *testing.T) testData {
queryRouter.SetInterfaceRegistry(encConf.InterfaceRegistry)
serviceRouter.SetInterfaceRegistry(encConf.InterfaceRegistry)
data := testData{
module: NewAppModule(encConf.Codec, keepers.WasmKeeper, keepers.StakingKeeper, keepers.AccountKeeper, keepers.BankKeeper, nil, newMockSubspace(DefaultParams)),
module: wasm.NewAppModule(encConf.Codec, keepers.WasmKeeper, keepers.StakingKeeper, keepers.AccountKeeper, keepers.BankKeeper, nil, newMockSubspace(DefaultParams)),
ctx: ctx,
acctKeeper: keepers.AccountKeeper,
keeper: *keepers.WasmKeeper,
Expand Down Expand Up @@ -511,7 +512,7 @@ func TestReadWasmConfig(t *testing.T) {
}
for msg, spec := range specs {
t.Run(msg, func(t *testing.T) {
got, err := ReadWasmConfig(spec.src)
got, err := wasm.ReadWasmConfig(spec.src)
require.NoError(t, err)
assert.Equal(t, spec.exp, got)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package keeper_test
package integration

import (
_ "embed"
Expand All @@ -20,10 +20,10 @@ import (
"github.com/CosmWasm/wasmd/x/wasm/types"
)

//go:embed testdata/reflect_1_5.wasm
//go:embed ../../../x/wasm/keeper/testdata/reflect_1_5.wasm
var wasmContract []byte

//go:embed testdata/hackatom.wasm
//go:embed ../../../x/wasm/keeper/testdata/hackatom.wasm
var hackatomContract []byte

func TestStoreCode(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package keeper
package integration

import (
"encoding/hex"
Expand All @@ -18,27 +18,33 @@ import (
v1 "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
"github.com/cosmos/cosmos-sdk/x/gov/types/v1beta1"

"github.com/CosmWasm/wasmd/x/wasm/keeper"
"github.com/CosmWasm/wasmd/x/wasm/keeper/testdata"
"github.com/CosmWasm/wasmd/x/wasm/types"
)

var (
CyberpunkCapabilities = []string{"staking", "mask", "stargate", "cosmwasm_1_1", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4"}
ReflectCapabilities = []string{"staking", "mask", "stargate", "cosmwasm_1_1", "cosmwasm_1_2", "cosmwasm_1_3", "cosmwasm_1_4", "cosmwasm_2_0"}
)

func TestLoadStoredGovV1Beta1LegacyTypes(t *testing.T) {
capabilities := make([]string, len(ReflectCapabilities)+1)
copy(capabilities, ReflectCapabilities)
capabilities = append(capabilities, "iterator")
pCtx, keepers := CreateTestInput(t, false, capabilities)
pCtx, keepers := keeper.CreateTestInput(t, false, capabilities)
k := keepers.WasmKeeper
keepers.GovKeeper.SetLegacyRouter(v1beta1.NewRouter().
AddRoute(types.ModuleName, NewLegacyWasmProposalHandler(k, types.EnableAllProposals)),
AddRoute(types.ModuleName, keeper.NewLegacyWasmProposalHandler(k, types.EnableAllProposals)),
)
myAddress := RandomAccountAddress(t)
myAddress := keeper.RandomAccountAddress(t)
keepers.Faucet.Fund(pCtx, myAddress, sdk.NewCoin(sdk.DefaultBondDenom, sdkmath.NewIntFromUint64(100_000_000)))
keepers.Faucet.Fund(pCtx, myAddress, sdk.NewCoin("denom", sdkmath.NewIntFromUint64(100_000_000)))

reflectExample := InstantiateReflectExampleContract(t, pCtx, keepers)
burnerCodeID, _, err := k.create(pCtx, myAddress, testdata.BurnerContractWasm(), nil, DefaultAuthorizationPolicy{})
reflectExample := keeper.InstantiateReflectExampleContract(t, pCtx, keepers)
burnerCodeID, _, err := k.create(pCtx, myAddress, testdata.BurnerContractWasm(), nil, keeper.DefaultAuthorizationPolicy{}) //TODO: what to do here
require.NoError(t, err)
hackatomExample := InstantiateHackatomExampleContract(t, pCtx, keepers)
hackatomExample := keeper.InstantiateHackatomExampleContract(t, pCtx, keepers)

type StealMsg struct {
Recipient string `json:"recipient"`
Expand Down Expand Up @@ -193,7 +199,7 @@ func TestLoadStoredGovV1Beta1LegacyTypes(t *testing.T) {
}
}

func mustSubmitAndExecuteLegacyProposal(t *testing.T, ctx sdk.Context, content v1beta1.Content, myActorAddress string, keepers TestKeepers) uint64 {
func mustSubmitAndExecuteLegacyProposal(t *testing.T, ctx sdk.Context, content v1beta1.Content, myActorAddress string, keepers keeper.TestKeepers) uint64 {
t.Helper()
govAuthority := keepers.AccountKeeper.GetModuleAddress(govtypes.ModuleName).String()
msgServer := govkeeper.NewMsgServerImpl(keepers.GovKeeper)
Expand Down
Loading

0 comments on commit 4f425ed

Please sign in to comment.