Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
julienrbrt committed Jun 3, 2024
1 parent d91da61 commit 8c3f27e
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 1 deletion.
34 changes: 33 additions & 1 deletion x/authz/simulation/operations.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
package simulation

import (
"context"
"math/rand"
"time"

"cosmossdk.io/core/address"
"cosmossdk.io/core/appmodule"
corecontext "cosmossdk.io/core/context"
coregas "cosmossdk.io/core/gas"
coreheader "cosmossdk.io/core/header"
"cosmossdk.io/x/authz"
"cosmossdk.io/x/authz/keeper"
banktype "cosmossdk.io/x/bank/types"
Expand Down Expand Up @@ -315,7 +320,12 @@ func SimulateMsgExec(

msg := []sdk.Msg{banktype.NewMsgSend(graStr, greStr, coins)}

_, err = sendAuth.Accept(ctx, msg[0])
goCtx := context.WithValue(ctx.Context(), corecontext.EnvironmentContextKey, appmodule.Environment{
HeaderService: headerService{},
GasService: mockGasService{},
})

_, err = sendAuth.Accept(goCtx, msg[0])
if err != nil {
if sdkerrors.ErrInsufficientFunds.Is(err) {
return simtypes.NoOpMsg(authz.ModuleName, TypeMsgExec, err.Error()), nil, nil
Expand Down Expand Up @@ -359,3 +369,25 @@ func SimulateMsgExec(
return simtypes.NewOperationMsg(&msgExec, true, "success"), nil, nil
}
}

type headerService struct{}

func (h headerService) HeaderInfo(ctx context.Context) coreheader.Info {
return sdk.UnwrapSDKContext(ctx).HeaderInfo()
}

type mockGasService struct {
coregas.Service
}

func (m mockGasService) GasMeter(ctx context.Context) coregas.Meter {
return mockGasMeter{}
}

type mockGasMeter struct {
coregas.Meter
}

func (m mockGasMeter) Consume(amount coregas.Gas, descriptor string) error {
return nil
}
1 change: 1 addition & 0 deletions x/bank/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Ref: https://keepachangelog.com/en/1.0.0/

### API Breaking Changes

* [#20502](https://github.com/cosmos/cosmos-sdk/pull/20502) `Accept` on the `Authorization` interface now expects the authz environment in the `context.Context`. This is already done when `Accept` is called by `k.DispatchActions`, but should be done manually if `Accept` is called directly.
* [#19954](https://github.com/cosmos/cosmos-sdk/pull/19954) Removal of the Address.String() method and related changes:
* Changed `NewInput`, `NewOutput`, `NewQueryBalanceRequest`, `NewQueryAllBalancesRequest`, `NewQuerySpendableBalancesRequest` to accept a string instead of an `AccAddress`.
* Added an address codec as an argument to `NewSendAuthorization`.
Expand Down

0 comments on commit 8c3f27e

Please sign in to comment.