From 0e5e0b913f89b2cc16caf559cbaa85716b8ba0d3 Mon Sep 17 00:00:00 2001 From: quasisamurai Date: Wed, 4 Sep 2024 11:55:01 -0300 Subject: [PATCH] archeologic works on unit tests --- testutil/test_helpers.go | 19 +- x/ibc-rate-limit/ibc_middleware_test.go | 329 +++++++++++------------- 2 files changed, 154 insertions(+), 194 deletions(-) diff --git a/testutil/test_helpers.go b/testutil/test_helpers.go index cc369431a..906839be3 100644 --- a/testutil/test_helpers.go +++ b/testutil/test_helpers.go @@ -10,11 +10,13 @@ import ( "testing" "time" + wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" abcit "github.com/cometbft/cometbft/abci/types" tmrand "github.com/cometbft/cometbft/libs/rand" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" + simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" icacontrollerkeeper "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/keeper" icacontrollertypes "github.com/cosmos/ibc-go/v8/modules/apps/27-interchain-accounts/controller/types" "github.com/stretchr/testify/require" @@ -31,7 +33,6 @@ import ( consumertypes "github.com/cosmos/interchain-security/v5/x/ccv/consumer/types" "github.com/CosmWasm/wasmd/x/wasm/keeper" - wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" wasmtypes "github.com/CosmWasm/wasmd/x/wasm/types" "github.com/cosmos/cosmos-sdk/testutil/sims" sdk "github.com/cosmos/cosmos-sdk/types" @@ -55,7 +56,6 @@ import ( ccv "github.com/cosmos/interchain-security/v5/x/ccv/types" cmttypes "github.com/cometbft/cometbft/types" - simtestutil "github.com/cosmos/cosmos-sdk/testutil/sims" ) var ( @@ -93,17 +93,14 @@ type IBCConnectionTestSuite struct { ChainProvider *ibctesting.TestChain ChainA *ibctesting.TestChain ChainB *ibctesting.TestChain - ChainC *ibctesting.TestChain ProviderApp e2e.ProviderApp ChainAApp e2e.ConsumerApp ChainBApp e2e.ConsumerApp - //ChainCApp e2e.ConsumerApp CCVPathA *ibctesting.Path CCVPathB *ibctesting.Path Path *ibctesting.Path - PathAC *ibctesting.Path TransferPath *ibctesting.Path } @@ -141,11 +138,9 @@ func (suite *IBCConnectionTestSuite) SetupTest() { suite.ChainProvider = suite.Coordinator.GetChain(ibctesting.GetChainID(1)) suite.ChainA = suite.Coordinator.GetChain(ibctesting.GetChainID(2)) suite.ChainB = suite.Coordinator.GetChain(ibctesting.GetChainID(3)) - //suite.ChainC = suite.Coordinator.GetChain(ibctesting.GetChainID(4)) suite.ProviderApp = suite.ChainProvider.App.(*appProvider.App) suite.ChainAApp = suite.ChainA.App.(*app.App) suite.ChainBApp = suite.ChainB.App.(*app.App) - //suite.ChainCApp = suite.ChainB.App.(*app.App) providerKeeper := suite.ProviderApp.GetProviderKeeper() consumerKeeperA := suite.ChainAApp.GetConsumerKeeper() @@ -229,11 +224,6 @@ func (suite *IBCConnectionTestSuite) SetupTest() { suite.Path = NewICAPath(suite.ChainA, suite.ChainB, suite.ChainProvider) suite.Coordinator.SetupConnections(suite.Path) - - //suite.PathAC = NewICAPath(suite.ChainA, suite.ChainC, suite.ChainProvider) - - suite.Coordinator.SetupConnections(suite.Path) - } func (suite *IBCConnectionTestSuite) ConfigureTransferChannel() { @@ -546,13 +536,13 @@ func (suite *IBCConnectionTestSuite) SendMsgsNoCheck(chain *ibctesting.TestChain // increment acc sequence regardless of success or failure tx execution defer func() { - err := suite.ChainA.SenderAccount.SetSequence(chain.SenderAccount.GetSequence() + 1) + err := chain.SenderAccount.SetSequence(chain.SenderAccount.GetSequence() + 1) if err != nil { panic(err) } }() - resp, err := SignAndDeliver(chain.TB, chain.TxConfig, chain.App.GetBaseApp(), msgs, chain.ChainID, []uint64{chain.SenderAccount.GetAccountNumber()}, []uint64{suite.ChainA.SenderAccount.GetSequence()}, suite.ChainA.CurrentHeader.GetTime(), suite.ChainA.NextVals.Hash(), suite.ChainA.SenderPrivKey) + resp, err := SignAndDeliver(chain.TB, chain.TxConfig, chain.App.GetBaseApp(), msgs, chain.ChainID, []uint64{chain.SenderAccount.GetAccountNumber()}, []uint64{chain.SenderAccount.GetSequence()}, chain.CurrentHeader.GetTime(), chain.NextVals.Hash(), chain.SenderPrivKey) if err != nil { return nil, err } @@ -621,4 +611,5 @@ func (suite *IBCConnectionTestSuite) ExecuteContract(contract, sender sdk.AccAdd app := suite.GetNeutronZoneApp(suite.ChainA) contractKeeper := wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper) return contractKeeper.Execute(suite.ChainA.GetContext(), contract, sender, msg, funds) + } diff --git a/x/ibc-rate-limit/ibc_middleware_test.go b/x/ibc-rate-limit/ibc_middleware_test.go index 341abc190..d862c9ee6 100644 --- a/x/ibc-rate-limit/ibc_middleware_test.go +++ b/x/ibc-rate-limit/ibc_middleware_test.go @@ -9,7 +9,6 @@ import ( sdkmath "cosmossdk.io/math" wasmkeeper "github.com/CosmWasm/wasmd/x/wasm/keeper" - capabilitytypes "github.com/cosmos/ibc-go/modules/capability/types" "github.com/neutron-org/neutron/v4/testutil" "github.com/stretchr/testify/require" "golang.org/x/exp/slices" @@ -24,6 +23,7 @@ import ( ibctesting "github.com/cosmos/ibc-go/v8/testing" "github.com/stretchr/testify/suite" + sdktypes "github.com/cosmos/cosmos-sdk/types" "github.com/neutron-org/neutron/v4/x/ibc-rate-limit/types" ) @@ -47,52 +47,12 @@ func NewTransferPath(chainA, chainB *ibctesting.TestChain) *ibctesting.Path { return path } -// -//func (suite *MiddlewareTestSuite) SetupTest() { -// suite.SkipIfWSL() -// // TODO: This needs to get removed. Waiting on https://github.com/cosmos/ibc-go/issues/3123 -// txfeetypes.ConsensusMinFee = osmomath.ZeroDec() -// suite.Setup() -// ibctesting.DefaultTestingAppInit = osmosisibctesting.SetupTestingApp -// suite.coordinator = ibctesting.NewCoordinator(suite.T(), 3) -// suite.chainA = &osmosisibctesting.TestChain{ -// TestChain: suite.coordinator.GetChain(ibctesting.GetChainID(1)), -// } -// // Remove epochs to prevent minting -// err := suite.chainA.MoveEpochsToTheFuture() -// suite.Require().NoError(err) -// // Create second chain -// suite.chainB = &osmosisibctesting.TestChain{ -// TestChain: suite.coordinator.GetChain(ibctesting.GetChainID(2)), -// } -// suite.path = NewTransferPath(suite.chainA, suite.chainB) -// err = suite.chainB.MoveEpochsToTheFuture() -// suite.Require().NoError(err) -// suite.coordinator.Setup(suite.path) -// // setup a third chain -// suite.chainC = &osmosisibctesting.TestChain{ -// TestChain: suite.coordinator.GetChain(ibctesting.GetChainID(3)), -// } -// suite.pathAC = NewTransferPath(suite.chainA, suite.chainC) -// err = suite.chainC.MoveEpochsToTheFuture() -// suite.Require().NoError(err) -// suite.coordinator.Setup(suite.pathAC) -//} - -// TODO: This needs to get removed. Waiting on https://github.com/cosmos/ibc-go/issues/3123 -//func (suite *MiddlewareTestSuite) TearDownSuite() { -// txfeetypes.ConsensusMinFee = oldConsensusMinFee -// -// for _, dir := range osmosisibctesting.TestingDirectories { -// os.RemoveAll(dir) -// } -//} - // Helpers func (suite *MiddlewareTestSuite) MessageFromAToB(denom string, amount sdkmath.Int) sdk.Msg { coin := sdk.NewCoin(denom, amount) - port := suite.Path.EndpointA.ChannelConfig.PortID - channel := suite.Path.EndpointA.ChannelID + port := suite.TransferPath.EndpointA.ChannelConfig.PortID + channel := suite.TransferPath.EndpointA.ChannelID + fmt.Println(channel) accountFrom := suite.ChainA.SenderAccount.GetAddress().String() accountTo := suite.ChainB.SenderAccount.GetAddress().String() timeoutHeight := clienttypes.NewHeight(10, 100) @@ -127,24 +87,24 @@ func (suite *MiddlewareTestSuite) MessageFromBToA(denom string, amount sdkmath.I ) } -func (suite *MiddlewareTestSuite) MessageFromAToC(denom string, amount sdkmath.Int) sdk.Msg { - coin := sdk.NewCoin(denom, amount) - port := suite.PathAC.EndpointA.ChannelConfig.PortID - channel := suite.PathAC.EndpointA.ChannelID - accountFrom := suite.ChainA.SenderAccount.GetAddress().String() - accountTo := suite.ChainC.SenderAccount.GetAddress().String() - timeoutHeight := clienttypes.NewHeight(10, 100) - return transfertypes.NewMsgTransfer( - port, - channel, - coin, - accountFrom, - accountTo, - timeoutHeight, - uint64(time.Now().UnixNano()), - "", - ) -} +//func (suite *MiddlewareTestSuite) MessageFromAToC(denom string, amount sdkmath.Int) sdk.Msg { +// coin := sdk.NewCoin(denom, amount) +// port := suite.PathAC.EndpointA.ChannelConfig.PortID +// channel := suite.PathAC.EndpointA.ChannelID +// accountFrom := suite.ChainA.SenderAccount.GetAddress().String() +// accountTo := suite.ChainC.SenderAccount.GetAddress().String() +// timeoutHeight := clienttypes.NewHeight(10, 100) +// return transfertypes.NewMsgTransfer( +// port, +// channel, +// coin, +// accountFrom, +// accountTo, +// timeoutHeight, +// uint64(time.Now().UnixNano()), +// "", +// ) +//} func CalculateChannelValue(ctx sdk.Context, denom string, bankKeeper bankkeeper.Keeper) sdkmath.Int { return bankKeeper.GetSupply(ctx, denom).Amount @@ -170,24 +130,24 @@ func CalculateChannelValue(ctx sdk.Context, denom string, bankKeeper bankkeeper. } func (suite *MiddlewareTestSuite) FullSendBToA(msg sdk.Msg) (*abci.ExecTxResult, string, error) { - sendResult, err := suite.SendMsgsNoCheck(suite.ChainA, msg) + sendResult, err := suite.SendMsgsNoCheck(suite.ChainB, msg) suite.Require().NoError(err) packet, err := ibctesting.ParsePacketFromEvents(sendResult.GetEvents()) suite.Require().NoError(err) - err = suite.Path.EndpointA.UpdateClient() + err = suite.TransferPath.EndpointA.UpdateClient() suite.Require().NoError(err) - res, err := suite.Path.EndpointA.RecvPacketWithResult(packet) + res, err := suite.TransferPath.EndpointA.RecvPacketWithResult(packet) suite.Require().NoError(err) ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) suite.Require().NoError(err) - err = suite.Path.EndpointA.UpdateClient() + err = suite.TransferPath.EndpointA.UpdateClient() suite.Require().NoError(err) - err = suite.Path.EndpointB.UpdateClient() + err = suite.TransferPath.EndpointB.UpdateClient() suite.Require().NoError(err) return sendResult, string(ack), err @@ -198,32 +158,40 @@ func (suite *MiddlewareTestSuite) FullSendAToB(msg sdk.Msg) (*abci.ExecTxResult, if err != nil { return nil, "", err } + fmt.Println(sendResult.Log) + fmt.Println(sendResult.Info) + fmt.Println(sendResult.Code) + fmt.Println(sendResult.Events) + fmt.Println(sendResult.GasUsed) packet, err := ibctesting.ParsePacketFromEvents(sendResult.GetEvents()) if err != nil { return nil, "", err } + fmt.Println(2) - err = suite.Path.EndpointB.UpdateClient() + err = suite.TransferPath.EndpointB.UpdateClient() if err != nil { return nil, "", err } + fmt.Println(3) - res, err := suite.Path.EndpointB.RecvPacketWithResult(packet) + res, err := suite.TransferPath.EndpointB.RecvPacketWithResult(packet) if err != nil { return nil, "", err } - + fmt.Println(4) ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) if err != nil { return nil, "", err } - - err = suite.Path.EndpointA.UpdateClient() + fmt.Println(5) + err = suite.TransferPath.EndpointA.UpdateClient() + fmt.Println(6) if err != nil { return nil, "", err } - err = suite.Path.EndpointB.UpdateClient() + err = suite.TransferPath.EndpointB.UpdateClient() if err != nil { return nil, "", err } @@ -231,43 +199,43 @@ func (suite *MiddlewareTestSuite) FullSendAToB(msg sdk.Msg) (*abci.ExecTxResult, return sendResult, string(ack), nil } -func (suite *MiddlewareTestSuite) FullSendAToC(msg sdk.Msg) (*abci.ExecTxResult, string, error) { - sendResult, err := suite.SendMsgsNoCheck(suite.ChainA, msg) - if err != nil { - return nil, "", err - } - - packet, err := ibctesting.ParsePacketFromEvents(sendResult.GetEvents()) - if err != nil { - return nil, "", err - } - - err = suite.PathAC.EndpointB.UpdateClient() - if err != nil { - return nil, "", err - } - - res, err := suite.PathAC.EndpointB.RecvPacketWithResult(packet) - if err != nil { - return nil, "", err - } - - ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) - if err != nil { - return nil, "", err - } - - err = suite.PathAC.EndpointA.UpdateClient() - if err != nil { - return nil, "", err - } - err = suite.PathAC.EndpointB.UpdateClient() - if err != nil { - return nil, "", err - } - - return sendResult, string(ack), nil -} +//func (suite *MiddlewareTestSuite) FullSendAToC(msg sdk.Msg) (*abci.ExecTxResult, string, error) { +// sendResult, err := suite.SendMsgsNoCheck(suite.ChainA, msg) +// if err != nil { +// return nil, "", err +// } +// +// packet, err := ibctesting.ParsePacketFromEvents(sendResult.GetEvents()) +// if err != nil { +// return nil, "", err +// } +// +// err = suite.PathAC.EndpointB.UpdateClient() +// if err != nil { +// return nil, "", err +// } +// +// res, err := suite.PathAC.EndpointB.RecvPacketWithResult(packet) +// if err != nil { +// return nil, "", err +// } +// +// ack, err := ibctesting.ParseAckFromEvents(res.GetEvents()) +// if err != nil { +// return nil, "", err +// } +// +// err = suite.PathAC.EndpointA.UpdateClient() +// if err != nil { +// return nil, "", err +// } +// err = suite.PathAC.EndpointB.UpdateClient() +// if err != nil { +// return nil, "", err +// } +// +// return sendResult, string(ack), nil +//} func (suite *MiddlewareTestSuite) AssertReceive(success bool, msg sdk.Msg) (string, error) { _, ack, err := suite.FullSendBToA(msg) @@ -496,9 +464,9 @@ func (suite *MiddlewareTestSuite) TestRecvTransferWithRateLimitingNonNative() { // Test no rate limiting occurs when the contract is set, but no quotas are configured for the path func (suite *MiddlewareTestSuite) TestSendTransferNoQuota() { // Setup contract - app := suite.GetNeutronZoneApp(suite.ChainA) - creator := app.AccountKeeper.GetModuleAddress(govtypes.ModuleName) - suite.StoreTestCode(suite.ChainA.GetContext(), creator, "./bytecode/rate_limiter.wasm") + //app := suite.GetNeutronZoneApp(suite.ChainA) + testOwner := sdktypes.MustAccAddressFromBech32(testutil.TestOwnerAddress) + suite.StoreTestCode(suite.ChainA.GetContext(), testOwner, "./bytecode/rate_limiter.wasm") addr := suite.InstantiateRLContract(``) suite.RegisterRateLimitingContract(addr) @@ -510,6 +478,7 @@ func (suite *MiddlewareTestSuite) TestSendTransferNoQuota() { // Test rate limits are reverted if a "send" fails func (suite *MiddlewareTestSuite) TestFailedSendTransfer() { + suite.ConfigureTransferChannel() suite.initializeEscrow() // Setup contract app := suite.GetNeutronZoneApp(suite.ChainA) @@ -597,87 +566,87 @@ func (suite *MiddlewareTestSuite) TestUnsetRateLimitingContract() { } // Test rate limits are reverted if a "send" fails -func (suite *MiddlewareTestSuite) TestNonICS20() { - suite.initializeEscrow() - // Setup contract - app := suite.GetNeutronZoneApp(suite.ChainA) - creator := app.AccountKeeper.GetModuleAddress(govtypes.ModuleName) - suite.StoreTestCode(suite.ChainA.GetContext(), creator, "./bytecode/rate_limiter.wasm") - quotas := suite.BuildChannelQuota("weekly", "channel-0", sdk.DefaultBondDenom, 604800, 1, 1) - addr := suite.InstantiateRLContract(quotas) - suite.RegisterRateLimitingContract(addr) - - data := []byte("{}") - _, err := app.RateLimitingICS4Wrapper.SendPacket(suite.ChainA.GetContext(), capabilitytypes.NewCapability(1), "wasm.osmo1873ls0d60tg7hk00976teq9ywhzv45u3hk2urw8t3eau9eusa4eqtun9xn", "channel-0", clienttypes.NewHeight(0, 0), 1, data) - - suite.Require().Error(err) - // This will error out, but not because of rate limiting - suite.Require().NotContains(err.Error(), "rate limit") - suite.Require().Contains(err.Error(), "channel not found") -} - -func (suite *MiddlewareTestSuite) TestDenomRestrictionFlow() { - // Setup contract - app := suite.GetNeutronZoneApp(suite.ChainA) - creator := app.AccountKeeper.GetModuleAddress(govtypes.ModuleName) - suite.StoreTestCode(suite.ChainA.GetContext(), creator, "./bytecode/rate_limiter.wasm") - quotas := suite.BuildChannelQuota("weekly", "channel-0", sdk.DefaultBondDenom, 604800, 1, 1) - contractAddr := suite.InstantiateRLContract(quotas) - suite.RegisterRateLimitingContract(contractAddr) - osmosisApp := suite.GetNeutronZoneApp(suite.ChainA) - govModule := osmosisApp.AccountKeeper.GetModuleAddress(govtypes.ModuleName) - - denom := sdk.DefaultBondDenom - sendAmount := sdkmath.NewInt(1000) - acceptedChannel := suite.Path.EndpointA.ChannelID - - // Successfully send a denom before any restrictions are added. - _, err := suite.AssertSend(true, suite.MessageFromAToB(denom, sendAmount)) - suite.Require().NoError(err, "Send should succeed without restrictions") - - // Sending on a diff channel should work - _, _, err = suite.FullSendAToC(suite.MessageFromAToC(denom, sendAmount)) - suite.Require().NoError(err, "Send on alternative channel should work") - - // Add a restriction that only allows sending on the accepted channel - restrictionMsg := fmt.Sprintf(`{"set_denom_restrictions": {"denom":"%s","allowed_channels":["%s"]}}`, denom, acceptedChannel) - _, err = suite.ExecuteContract(contractAddr, govModule, []byte(restrictionMsg), sdk.Coins{}) - suite.Require().NoError(err) - - // Sending on the accepted channel should succeed - _, err = suite.AssertSend(true, suite.MessageFromAToB(denom, sendAmount)) - suite.Require().NoError(err, "Send on accepted channel should succeed") - - // Sending on any other channel should fail - _, err = suite.AssertSend(false, suite.MessageFromAToC(denom, sendAmount)) - suite.Require().Error(err, "Send on blocked channel should fail") - - // Unset the restriction and verify that sending on other channels works again - unsetMsg := fmt.Sprintf(`{"unset_denom_restrictions": {"denom":"%s"}}`, denom) - _, err = suite.ExecuteContract(contractAddr, govModule, []byte(unsetMsg), sdk.Coins{}) - suite.Require().NoError(err, "Unsetting denom restriction should succeed") - - // Sending again on the previously blocked channel should now succeed - _, _, err = suite.FullSendAToC(suite.MessageFromAToC(denom, sendAmount)) - suite.Require().NoError(err, "Send on previously blocked channel should succeed after unsetting restriction") +//func (suite *MiddlewareTestSuite) TestNonICS20() { +// suite.initializeEscrow() +// // Setup contract +// app := suite.GetNeutronZoneApp(suite.ChainA) +// testOwner := sdktypes.MustAccAddressFromBech32(testutil.TestOwnerAddress) +// suite.StoreTestCode(suite.ChainA.GetContext(), testOwner, "./bytecode/rate_limiter.wasm") +// quotas := suite.BuildChannelQuota("weekly", "channel-0", sdk.DefaultBondDenom, 604800, 1, 1) +// addr := suite.InstantiateRLContract(quotas) +// suite.RegisterRateLimitingContract(addr) +// +// data := []byte("{}") +// _, err := app.RateLimitingICS4Wrapper.SendPacket(suite.ChainA.GetContext(), capabilitytypes.NewCapability(1), "wasm.neutron1873ls0d60tg7hk00976teq9ywhzv45u3hk2urw8t3eau9eusa4eqtun9xn", "channel-0", clienttypes.NewHeight(0, 0), 1, data) +// +// suite.Require().Error(err) +// // This will error out, but not because of rate limiting +// suite.Require().NotContains(err.Error(), "rate limit") +// suite.Require().Contains(err.Error(), "channel not found") +//} -} +//func (suite *MiddlewareTestSuite) TestDenomRestrictionFlow() { +// // Setup contract +// app := suite.GetNeutronZoneApp(suite.ChainA) +// creator := app.AccountKeeper.GetModuleAddress(govtypes.ModuleName) +// suite.StoreTestCode(suite.ChainA.GetContext(), creator, "./bytecode/rate_limiter.wasm") +// quotas := suite.BuildChannelQuota("weekly", "channel-0", sdk.DefaultBondDenom, 604800, 1, 1) +// contractAddr := suite.InstantiateRLContract(quotas) +// suite.RegisterRateLimitingContract(contractAddr) +// osmosisApp := suite.GetNeutronZoneApp(suite.ChainA) +// govModule := osmosisApp.AccountKeeper.GetModuleAddress(govtypes.ModuleName) +// +// denom := sdk.DefaultBondDenom +// sendAmount := sdkmath.NewInt(1000) +// acceptedChannel := suite.Path.EndpointA.ChannelID +// +// // Successfully send a denom before any restrictions are added. +// _, err := suite.AssertSend(true, suite.MessageFromAToB(denom, sendAmount)) +// suite.Require().NoError(err, "Send should succeed without restrictions") +// +// // Sending on a diff channel should work +// _, _, err = suite.FullSendAToC(suite.MessageFromAToC(denom, sendAmount)) +// suite.Require().NoError(err, "Send on alternative channel should work") +// +// // Add a restriction that only allows sending on the accepted channel +// restrictionMsg := fmt.Sprintf(`{"set_denom_restrictions": {"denom":"%s","allowed_channels":["%s"]}}`, denom, acceptedChannel) +// _, err = suite.ExecuteContract(contractAddr, govModule, []byte(restrictionMsg), sdk.Coins{}) +// suite.Require().NoError(err) +// +// // Sending on the accepted channel should succeed +// _, err = suite.AssertSend(true, suite.MessageFromAToB(denom, sendAmount)) +// suite.Require().NoError(err, "Send on accepted channel should succeed") +// +// // Sending on any other channel should fail +// _, err = suite.AssertSend(false, suite.MessageFromAToC(denom, sendAmount)) +// suite.Require().Error(err, "Send on blocked channel should fail") +// +// // Unset the restriction and verify that sending on other channels works again +// unsetMsg := fmt.Sprintf(`{"unset_denom_restrictions": {"denom":"%s"}}`, denom) +// _, err = suite.ExecuteContract(contractAddr, govModule, []byte(unsetMsg), sdk.Coins{}) +// suite.Require().NoError(err, "Unsetting denom restriction should succeed") +// +// // Sending again on the previously blocked channel should now succeed +// _, _, err = suite.FullSendAToC(suite.MessageFromAToC(denom, sendAmount)) +// suite.Require().NoError(err, "Send on previously blocked channel should succeed after unsetting restriction") +// +//} func (suite *MiddlewareTestSuite) InstantiateRLContract(quotas string) sdk.AccAddress { app := suite.GetNeutronZoneApp(suite.ChainA) transferModule := app.AccountKeeper.GetModuleAddress(transfertypes.ModuleName) - govModule := app.AccountKeeper.GetModuleAddress(govtypes.ModuleName) + //govModule := app.AccountKeeper.GetModuleAddress(govtypes.ModuleName) initMsgBz := []byte(fmt.Sprintf(`{ "gov_module": "%s", "ibc_module":"%s", "paths": [%s] }`, - govModule, transferModule, quotas)) + suite.ChainA.SenderAccount.GetAddress(), transferModule, quotas)) contractKeeper := wasmkeeper.NewDefaultPermissionKeeper(app.WasmKeeper) codeID := uint64(1) - creator := app.AccountKeeper.GetModuleAddress(govtypes.ModuleName) + creator := suite.ChainA.SenderAccount.GetAddress() addr, _, err := contractKeeper.Instantiate(suite.ChainA.GetContext(), codeID, creator, creator, initMsgBz, "rate limiting contract", nil) suite.Require().NoError(err) return addr