Skip to content

Commit

Permalink
Fix ibcratelimit tests. (#1977)
Browse files Browse the repository at this point in the history
* Update tests for ibc-rate-limit to pass.

* Add ICS20 check.

* Fix tests for ICS20. Temporarily add todo for ibchooks.

* Update changelog.

* Update correct line in CHANGELOG.
  • Loading branch information
Taztingo authored May 17, 2024
1 parent 93002e8 commit 2adf2c5
Show file tree
Hide file tree
Showing 20 changed files with 477 additions and 385 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,12 @@ jobs:
run: |
grep -vF \
-e 'github.com/provenance-io/provenance/x/ibchooks' \
-e 'github.com/provenance-io/provenance/x/ibcratelimit/module' \
-e 'github.com/provenance-io/provenance/x/ibcratelimit/simulation' \
-e 'github.com/provenance-io/provenance/x/oracle/simulation' \
pkgs.txt > pkgs.txt.tmp
split -d -n l/3 pkgs.txt.tmp pkgs.txt.part.
printf '%s\n' \
'github.com/provenance-io/provenance/x/ibchooks' \
'github.com/provenance-io/provenance/x/ibcratelimit/module' \
'github.com/provenance-io/provenance/x/ibcratelimit/simulation' \
'github.com/provenance-io/provenance/x/oracle/simulation' \
> pkgs.txt.part.03
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ Ref: https://keepachangelog.com/en/1.0.0/
* Switch to auto-generated `String` and `Equal` methods for most proto messages [#1957](https://github.com/provenance-io/provenance/pull/1957).
* Clean up the marker module's expected BankKeeper interface [#1954](https://github.com/provenance-io/provenance/pull/1954).
* Add the auto-cli commands and a few others newly added by the SDK [#1971](https://github.com/provenance-io/provenance/pull/1971).
* Fix unit tests for ibcratelimit [#1977](https://github.com/provenance-io/provenance/pull/1977).

### Client Breaking

Expand Down
18 changes: 11 additions & 7 deletions app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import (
porttypes "github.com/cosmos/ibc-go/v8/modules/core/05-port/types"
ibcexported "github.com/cosmos/ibc-go/v8/modules/core/exported"
ibckeeper "github.com/cosmos/ibc-go/v8/modules/core/keeper"
ibctm "github.com/cosmos/ibc-go/v8/modules/light-clients/07-tendermint"
ibctestingtypes "github.com/cosmos/ibc-go/v8/testing/types"

simappparams "github.com/provenance-io/provenance/app/params"
Expand Down Expand Up @@ -287,11 +288,12 @@ type App struct {
ScopedICQKeeper capabilitykeeper.ScopedKeeper
ScopedOracleKeeper capabilitykeeper.ScopedKeeper

TransferStack *ibchooks.IBCMiddleware
Ics20WasmHooks *ibchooks.WasmHooks
Ics20MarkerHooks *ibchooks.MarkerHooks
IbcHooks *ibchooks.IbcHooks
HooksICS4Wrapper ibchooks.ICS4Middleware
TransferStack *ibchooks.IBCMiddleware
Ics20WasmHooks *ibchooks.WasmHooks
Ics20MarkerHooks *ibchooks.MarkerHooks
IbcHooks *ibchooks.IbcHooks
HooksICS4Wrapper ibchooks.ICS4Middleware
RateLimitMiddleware porttypes.Middleware

// the module manager
mm *module.Manager
Expand Down Expand Up @@ -542,8 +544,8 @@ func New(
)
app.TransferKeeper = &transferKeeper
transferModule := ibctransfer.NewIBCModule(*app.TransferKeeper)
rateLimitingTransferModule = *rateLimitingTransferModule.WithIBCModule(transferModule)
hooksTransferModule := ibchooks.NewIBCMiddleware(&rateLimitingTransferModule, &app.HooksICS4Wrapper)
app.RateLimitMiddleware = rateLimitingTransferModule.WithIBCModule(transferModule)
hooksTransferModule := ibchooks.NewIBCMiddleware(app.RateLimitMiddleware, &app.HooksICS4Wrapper)
app.TransferStack = &hooksTransferModule

app.NameKeeper = namekeeper.NewKeeper(appCodec, keys[nametypes.StoreKey])
Expand Down Expand Up @@ -775,6 +777,7 @@ func New(
ibctransfer.NewAppModule(*app.TransferKeeper),
icqModule,
icaModule,
ibctm.AppModule{},
)

// BasicModuleManager defines the module BasicManager is in charge of setting up basic,
Expand Down Expand Up @@ -950,6 +953,7 @@ func New(
paramstypes.ModuleName,
slashingtypes.ModuleName,
stakingtypes.ModuleName,
ibctm.ModuleName,
ibctransfertypes.ModuleName,
upgradetypes.ModuleName,
vestingtypes.ModuleName,
Expand Down
6 changes: 4 additions & 2 deletions internal/antewrapper/msg_fees_decorator.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package antewrapper

import (
"strings"

sdkmath "cosmossdk.io/math"

sdk "github.com/cosmos/cosmos-sdk/types"
Expand Down Expand Up @@ -77,9 +79,9 @@ func (mfd MsgFeesDecorator) AnteHandle(ctx sdk.Context, tx sdk.Tx, simulate bool

// This check for chain-id is exclusively for not breaking all existing sim tests which freak out when denom is anything other than stake.
// and some network tests won't work without a chain id being set(but they also setup everything with stake denom) so `simapp-unit-testing` chain id is skipped also.
// This only needs to work to pio-testnet and pio-mainnet, so this is safe.
// This only needs to work to pio-testnet, pio-mainnet, and ibc tests, so this is safe.
func isTestContext(ctx sdk.Context) bool {
return len(ctx.ChainID()) == 0 || ctx.ChainID() == SimAppChainID || ctx.ChainID() == pioconfig.SimAppChainID
return len(ctx.ChainID()) == 0 || ctx.ChainID() == SimAppChainID || ctx.ChainID() == pioconfig.SimAppChainID || strings.HasPrefix(ctx.ChainID(), "testchain")
}

// EnsureSufficientFloorAndMsgFees verifies that the given transaction has supplied
Expand Down
Loading

0 comments on commit 2adf2c5

Please sign in to comment.