Skip to content

Commit 3f764d5

Browse files
committed
fix: handle tests broken by libwasmvm
1 parent f641257 commit 3f764d5

File tree

7 files changed

+39
-8
lines changed

7 files changed

+39
-8
lines changed

app/helpers/test_helpers.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package helpers
22

33
import (
44
"encoding/json"
5+
"os"
56
"testing"
67
"time"
78

@@ -125,6 +126,11 @@ func SetupWithGenesisValSet(t *testing.T, valSet *tmtypes.ValidatorSet, genAccs
125126

126127
func setup() (*gaiaapp.GaiaApp, gaiaapp.GenesisState) {
127128
db := dbm.NewMemDB()
129+
dir, err := os.MkdirTemp("", "gaia-test-app")
130+
if err != nil {
131+
panic(err)
132+
}
133+
128134
appOptions := make(simtestutil.AppOptionsMap, 0)
129135
emptyWasmOpts := []wasmkeeper.Option{}
130136
appOptions[server.FlagInvCheckPeriod] = 5
@@ -136,7 +142,7 @@ func setup() (*gaiaapp.GaiaApp, gaiaapp.GenesisState) {
136142
nil,
137143
true,
138144
map[int64]bool{},
139-
gaiaapp.DefaultNodeHome,
145+
dir,
140146
appOptions,
141147
emptyWasmOpts,
142148
)

app/keepers/keepers.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package keepers
33
import (
44
"fmt"
55
"os"
6+
"path/filepath"
67

78
feemarketkeeper "github.com/skip-mev/feemarket/x/feemarket/keeper"
89
feemarkettypes "github.com/skip-mev/feemarket/x/feemarket/types"
@@ -467,6 +468,7 @@ func NewAppKeeper(
467468
// Must be called on PFMRouter AFTER TransferKeeper initialized
468469
appKeepers.PFMRouterKeeper.SetTransferKeeper(appKeepers.TransferKeeper)
469470

471+
wasmDir := filepath.Join(homePath, "wasm")
470472
wasmConfig, err := wasm.ReadWasmConfig(appOpts)
471473
if err != nil {
472474
panic("error while reading wasm config: " + err.Error())
@@ -479,14 +481,14 @@ func NewAppKeeper(
479481
appKeepers.BankKeeper,
480482
appKeepers.StakingKeeper,
481483
distrkeeper.NewQuerier(appKeepers.DistrKeeper),
482-
appKeepers.IBCKeeper.ChannelKeeper,
484+
appKeepers.IBCFeeKeeper,
483485
appKeepers.IBCKeeper.ChannelKeeper,
484486
appKeepers.IBCKeeper.PortKeeper,
485487
appKeepers.scopedWasmKeeper,
486488
appKeepers.TransferKeeper,
487489
bApp.MsgServiceRouter(),
488490
bApp.GRPCQueryRouter(),
489-
homePath,
491+
wasmDir,
490492
wasmConfig,
491493
wasmkeeper.BuiltInCapabilities(),
492494
authtypes.NewModuleAddress(govtypes.ModuleName).String(),

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ require (
191191
github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect
192192
github.com/rogpeppe/go-internal v1.12.0 // indirect
193193
github.com/rs/cors v1.8.3 // indirect
194-
github.com/rs/zerolog v1.32.0 // indirect
194+
github.com/rs/zerolog v1.33.0 // indirect
195195
github.com/sagikazarmark/locafero v0.4.0 // indirect
196196
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
197197
github.com/sasha-s/go-deadlock v0.3.1 // indirect

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -1165,8 +1165,8 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
11651165
github.com/rs/cors v1.8.3 h1:O+qNyWn7Z+F9M0ILBHgMVPuB1xTOucVd5gtaYyXBpRo=
11661166
github.com/rs/cors v1.8.3/go.mod h1:XyqrcTp5zjWr1wsJ8PIRZssZ8b/WMcMf71DJnit4EMU=
11671167
github.com/rs/xid v1.5.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg=
1168-
github.com/rs/zerolog v1.32.0 h1:keLypqrlIjaFsbmJOBdB/qvyF8KEtCWHwobLp5l/mQ0=
1169-
github.com/rs/zerolog v1.32.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
1168+
github.com/rs/zerolog v1.33.0 h1:1cU2KZkvPxNyfgEmhHAz/1A9Bz+llsdYzklWFzgp0r8=
1169+
github.com/rs/zerolog v1.33.0/go.mod h1:/7mN4D5sKwJLZQ2b/znpjC3/GQWY/xaDXUM0kKWRHss=
11701170
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
11711171
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
11721172
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

tests/integration/ibcfee_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ func TestIBCFeeTestSuite(t *testing.T) {
4949

5050
func (suite *IBCFeeTestSuite) SetupTest() {
5151
ante.UseFeeMarketDecorator = false
52-
ibctesting.DefaultTestingAppInit = GaiaAppIniter
52+
ibctesting.DefaultTestingAppInit = GaiaAppIniterRandomDir
5353
suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3)
5454
suite.chainA = suite.coordinator.GetChain(ibctesting.GetChainID(1))
5555
suite.chainB = suite.coordinator.GetChain(ibctesting.GetChainID(2))

tests/integration/interchain_security_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func init() {
2828
// concrete app types returned by the relevant app initers.
2929
ccvSuite = integration.NewCCVTestSuite[*gaiaApp.GaiaApp, *appConsumer.App](
3030
// Pass in ibctesting.AppIniters for gaia (provider) and consumer.
31-
GaiaAppIniter, icstestingutils.ConsumerAppIniter, []string{})
31+
GaiaAppIniterRandomDir, icstestingutils.ConsumerAppIniter, []string{})
3232

3333
ante.UseFeeMarketDecorator = false
3434
}

tests/integration/test_utils.go

+23
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"fmt"
66
"math/rand"
7+
"os"
78
"testing"
89
"time"
910

@@ -27,6 +28,28 @@ import (
2728

2829
var app *gaiaApp.GaiaApp
2930

31+
// Some tests require a random directory to be created when runnin IBC testing suite with gaia.
32+
// This is due to how CosmWasmVM initializes the VM - all IBC testing apps must have different dirs so they don't conflict.
33+
func GaiaAppIniterRandomDir() (ibctesting.TestingApp, map[string]json.RawMessage) {
34+
tmpDir, err := os.MkdirTemp("", "")
35+
if err != nil {
36+
panic(err)
37+
}
38+
app = gaiaApp.NewGaiaApp(
39+
log.NewNopLogger(),
40+
dbm.NewMemDB(),
41+
nil,
42+
true,
43+
map[int64]bool{},
44+
tmpDir,
45+
gaiaApp.EmptyAppOptions{},
46+
gaiaApp.EmptyWasmOptions)
47+
48+
testApp := ibctesting.TestingApp(app)
49+
50+
return testApp, app.ModuleBasics.DefaultGenesis(app.AppCodec())
51+
}
52+
3053
// GaiaAppIniter implements ibctesting.AppIniter for the gaia app
3154
func GaiaAppIniter() (ibctesting.TestingApp, map[string]json.RawMessage) {
3255
app = gaiaApp.NewGaiaApp(

0 commit comments

Comments
 (0)