Skip to content

Commit

Permalink
fix test error
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer-zq committed Apr 22, 2024
1 parent 8fb2026 commit 2dfd446
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 1 addition & 1 deletion modules/token/keeper/erc20.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (k Keeper) DeployERC20(

contractArgs, err := contracts.TokenProxyContract.ABI.Pack(
"",
params.Beacon,
common.HexToAddress(params.Beacon),
initArgs,
)
if err != nil {
Expand Down
6 changes: 5 additions & 1 deletion modules/token/keeper/keeper_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package keeper_test
import (
"testing"

"github.com/ethereum/go-ethereum/common"
"github.com/stretchr/testify/suite"

"github.com/cometbft/cometbft/crypto/tmhash"
Expand All @@ -29,6 +30,7 @@ var (
add2 = sdk.AccAddress(tmhash.SumTruncated([]byte("tokenTest1")))
initAmt = sdkmath.NewIntWithDecimal(100000000, int(6))
initCoin = sdk.Coins{sdk.NewCoin(denom, initAmt)}
beacon = common.BytesToAddress(owner.Bytes())
)

type KeeperTestSuite struct {
Expand All @@ -51,7 +53,9 @@ func (suite *KeeperTestSuite) SetupTest() {
suite.app = app

// set params
suite.keeper.SetParams(suite.ctx, v1.DefaultParams())
params := v1.DefaultParams()
params.Beacon = beacon.String()
suite.keeper.SetParams(suite.ctx, params)

// init tokens to addr
err := suite.bk.MintCoins(suite.ctx, types.ModuleName, initCoin)
Expand Down
18 changes: 13 additions & 5 deletions simapp/mocks/evm.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,22 @@ func (e *evm) ApplyMessage(ctx sdk.Context, msg core.Message, tracer vm.EVMLogge
if isCreate {
contractAddr := crypto.CreateAddress(msg.From(), msg.Nonce())

data := msg.Data()[len(contracts.ERC20TokenContract.Bin):]
argss, err := contracts.ERC20TokenContract.ABI.Constructor.Inputs.Unpack(data)
data := msg.Data()[len(contracts.TokenProxyContract.Bin):]
args, err := contracts.TokenProxyContract.ABI.Constructor.Inputs.Unpack(data)
if err != nil {
return nil, err
}
name, _ := argss[0].(string)
symbol, _ := argss[1].(string)
scale, _ := argss[2].(uint8)

data = args[1].([]byte)
data = data[4:]
args, err = contracts.ERC20TokenContract.ABI.Methods[contracts.MethodInitialize].Inputs.Unpack(data)
if err != nil {
return nil, err
}

name, _ := args[0].(string)
symbol, _ := args[1].(string)
scale, _ := args[2].(uint8)
e.erc20s[contractAddr] = &erc20{
address: contractAddr,
scale: scale,
Expand Down

0 comments on commit 2dfd446

Please sign in to comment.