2020-05-29 15:50:22 +00:00
|
|
|
package evm_test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"encoding/json"
|
|
|
|
|
|
|
|
"github.com/cosmos/ethermint/x/evm"
|
|
|
|
|
|
|
|
"github.com/ethereum/go-ethereum/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
var testJSON = `{
|
|
|
|
"accounts": [
|
|
|
|
{
|
|
|
|
"address": "0x00cabdd44664b73cfc3194b9d32eb6c351ef7652",
|
|
|
|
"balance": 34
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"address": "0x2cc7fdf9fde6746731d7f11979609d455c2c197a",
|
|
|
|
"balance": 0,
|
|
|
|
"code": "0x60806040"
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}`
|
|
|
|
|
|
|
|
func (suite *EvmTestSuite) TestInitGenesis() {
|
|
|
|
am := evm.NewAppModule(suite.app.EvmKeeper, suite.app.AccountKeeper)
|
|
|
|
in := json.RawMessage([]byte(testJSON))
|
2020-08-23 21:41:54 +00:00
|
|
|
_ = am.InitGenesis(suite.ctx, in)
|
2020-05-29 15:50:22 +00:00
|
|
|
|
|
|
|
testAddr := common.HexToAddress("0x2cc7fdf9fde6746731d7f11979609d455c2c197a")
|
|
|
|
|
|
|
|
res := suite.app.EvmKeeper.CommitStateDB.WithContext(suite.ctx).GetCode(testAddr)
|
|
|
|
expectedCode := common.FromHex("0x60806040")
|
|
|
|
suite.Require().Equal(expectedCode, res)
|
|
|
|
}
|