Skip to content

Commit

Permalink
rebase
Browse files Browse the repository at this point in the history
  • Loading branch information
codchen committed Feb 13, 2024
1 parent 9fb6432 commit 1953b9f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion x/evm/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,11 @@ func (k *Keeper) GetHashFn(ctx sdk.Context) vm.GetHashFunc {
func (k *Keeper) GetEVMTxDeferredInfo(ctx sdk.Context) (res []EvmTxDeferredInfo) {
k.deferredInfo.Range(func(key, value any) bool {
txIdx := key.(int)
if txIdx >= 0 && txIdx < len(k.txResults) && k.txResults[txIdx].Code == 0 {
if txIdx < 0 || txIdx >= len(k.txResults) {
ctx.Logger().Error(fmt.Sprintf("getting invalid tx index in EVM deferred info: %d, num of txs: %d", txIdx, len(k.txResults)))
return true
}

Check warning on line 154 in x/evm/keeper/keeper.go

View check run for this annotation

Codecov / codecov/patch

x/evm/keeper/keeper.go#L152-L154

Added lines #L152 - L154 were not covered by tests
if k.txResults[txIdx].Code == 0 {
res = append(res, *(value.(*EvmTxDeferredInfo)))
}
return true
Expand Down
3 changes: 3 additions & 0 deletions x/evm/keeper/wei_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/sei-protocol/sei-chain/x/evm/state"
"github.com/sei-protocol/sei-chain/x/evm/types"
"github.com/stretchr/testify/require"
abci "github.com/tendermint/tendermint/abci/types"
)

func TestSettleCommon(t *testing.T) {
Expand Down Expand Up @@ -51,6 +52,7 @@ func TestSettleCommon(t *testing.T) {
globalEscrowBalance := k.BankKeeper().GetBalance(ctx, k.AccountKeeper().GetModuleAddress(banktypes.WeiEscrowName), "usei")
require.True(t, globalEscrowBalance.Amount.IsZero())

k.SetTxResults([]*abci.ExecTxResult{{Code: 0}, {Code: 0}, {Code: 0}, {Code: 0}})
deferredInfo := k.GetEVMTxDeferredInfo(ctx)
k.SettleWeiEscrowAccounts(ctx, deferredInfo)
globalEscrowBalance = k.BankKeeper().GetBalance(ctx, k.AccountKeeper().GetModuleAddress(banktypes.WeiEscrowName), "usei")
Expand Down Expand Up @@ -99,6 +101,7 @@ func TestSettleMultiRedeem(t *testing.T) {
globalEscrowBalance := k.BankKeeper().GetBalance(ctx, k.AccountKeeper().GetModuleAddress(banktypes.WeiEscrowName), "usei")
require.True(t, globalEscrowBalance.Amount.IsZero())

k.SetTxResults([]*abci.ExecTxResult{{Code: 0}, {Code: 0}, {Code: 0}})
deferredInfo := k.GetEVMTxDeferredInfo(ctx)
k.SettleWeiEscrowAccounts(ctx, deferredInfo)
globalEscrowBalance = k.BankKeeper().GetBalance(ctx, k.AccountKeeper().GetModuleAddress(banktypes.WeiEscrowName), "usei")
Expand Down

0 comments on commit 1953b9f

Please sign in to comment.