Skip to content

Commit

Permalink
Remove ToWithdrawalTx helper (#218)
Browse files Browse the repository at this point in the history
  • Loading branch information
AnkushinDaniil authored Sep 18, 2024
1 parent 70a93e2 commit c998a26
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 29 deletions.
14 changes: 7 additions & 7 deletions builder/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,13 @@ func TestBuildRollupTxs(t *testing.T) {
require.NotNil(t, depositTxETH.To(), "Deposit transaction must have a 'to' address")

cosmAddr := utils.EvmToCosmosAddress(*depositTxETH.To())
withdrawalTx := testapp.ToWithdrawalTx(
t,
cosmAddr.String(),
common.HexToAddress("0x12345abcde").String(),
math.NewIntFromBigInt(depositTxETH.Value()),
big.NewInt(100_000),
)
withdrawalTx := testapp.ToTx(t, &types.MsgInitiateWithdrawal{
Sender: cosmAddr.String(),
Target: common.HexToAddress("0x12345abcde").String(),
Value: math.NewIntFromBigInt(depositTxETH.Value()),
GasLimit: big.NewInt(100_000).Bytes(),
Data: []byte{},
})

b := builder.New(
env.pool,
Expand Down
14 changes: 7 additions & 7 deletions e2e/stack_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -327,13 +327,13 @@ func rollupFlow(t *testing.T, stack *e2e.StackConfig) {
// initiate the withdrawal of the deposited amount on L2
withdrawalTxResult, err := stack.L2Client.BroadcastTxAsync(
stack.Ctx,
testapp.ToWithdrawalTx(
t,
utils.EvmToCosmosAddress(*withdrawalTx.Sender).String(),
withdrawalTx.Target.String(),
math.NewIntFromBigInt(withdrawalTx.Value),
withdrawalTx.GasLimit,
),
testapp.ToTx(t, &rolluptypes.MsgInitiateWithdrawal{
Sender: utils.EvmToCosmosAddress(*withdrawalTx.Sender).String(),
Target: withdrawalTx.Target.String(),
Value: math.NewIntFromBigInt(withdrawalTx.Value),
GasLimit: withdrawalTx.GasLimit.Bytes(),
Data: []byte{},
}),
)
require.NoError(t, err)
require.Equal(t, abcitypes.CodeTypeOK, withdrawalTxResult.Code)
Expand Down
17 changes: 2 additions & 15 deletions testapp/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,16 @@ package testapp
import (
"context"
"encoding/json"
"math/big"
"slices"
"testing"

"cosmossdk.io/math"
abcitypes "github.com/cometbft/cometbft/abci/types"
dbm "github.com/cosmos/cosmos-db"
codectypes "github.com/cosmos/cosmos-sdk/codec/types"
sdktx "github.com/cosmos/cosmos-sdk/types/tx"
"github.com/cosmos/gogoproto/proto"
"github.com/polymerdao/monomer/testapp/x/testmodule"
"github.com/polymerdao/monomer/testapp/x/testmodule/types"
rolluptypes "github.com/polymerdao/monomer/x/rollup/types"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -53,7 +50,7 @@ func MakeGenesisAppState(t *testing.T, app *App, kvs ...string) map[string]json.
}

func ToTestTx(t *testing.T, k, v string) []byte {
return toTx(t, &types.MsgSetValue{
return ToTx(t, &types.MsgSetValue{
// TODO use real addresses and enable the signature and gas checks.
// This is just a dummy address. The signature and gas checks are disabled in testapp.go,
// so this works for now.
Expand All @@ -63,17 +60,7 @@ func ToTestTx(t *testing.T, k, v string) []byte {
})
}

func ToWithdrawalTx(t *testing.T, cosmosAddr string, ethAddr string, amount math.Int, gasLimit *big.Int) []byte {
return toTx(t, &rolluptypes.MsgInitiateWithdrawal{
Sender: cosmosAddr,
Target: ethAddr,
Value: amount,
GasLimit: gasLimit.Bytes(),
Data: []byte{},
})
}

func toTx(t *testing.T, msg proto.Message) []byte {
func ToTx(t *testing.T, msg proto.Message) []byte {
msgAny, err := codectypes.NewAnyWithValue(msg)
require.NoError(t, err)

Expand Down

0 comments on commit c998a26

Please sign in to comment.