mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Add getCodeContractHash to the state manager
This commit is contained in:
parent
8363569f29
commit
81991a3d29
2 changed files with 22 additions and 0 deletions
|
|
@ -22,6 +22,7 @@ var funcs = map[string]stateManagerFunction{
|
|||
"getOvmContractNonce(address)": getOvmContractNonce,
|
||||
"getCodeContractBytecode(address)": getCodeContractBytecode,
|
||||
"getCodeContractHash(address)": getCodeContractHash,
|
||||
"getCodeContractAddress(address)": getCodeContractAddress,
|
||||
"incrementOvmContractNonce(address)": incrementOvmContractNonce,
|
||||
}
|
||||
var methodIds map[[4]byte]stateManagerFunction
|
||||
|
|
@ -74,6 +75,11 @@ func getCodeContractHash(evm *EVM, contract *Contract, input []byte) (ret []byte
|
|||
return codeHash.Bytes(), nil
|
||||
}
|
||||
|
||||
func getCodeContractAddress(evm *EVM, contract *Contract, input []byte) (ret []byte, err error) {
|
||||
address := input[4:36]
|
||||
return address, nil
|
||||
}
|
||||
|
||||
func getOvmContractNonce(evm *EVM, contract *Contract, input []byte) (ret []byte, err error) {
|
||||
address := common.BytesToAddress(input[4:36])
|
||||
b := make([]byte, 8)
|
||||
|
|
|
|||
|
|
@ -99,6 +99,22 @@ func TestGetAndIncrementNonce(t *testing.T) {
|
|||
}
|
||||
}
|
||||
|
||||
func TestGetCodeContractAddress(t *testing.T) {
|
||||
rawStateManagerAbi, _ := ioutil.ReadFile("./StateManagerABI.json")
|
||||
stateManagerAbi, _ := abi.JSON(strings.NewReader(string(rawStateManagerAbi)))
|
||||
state := newState()
|
||||
|
||||
address := common.HexToAddress("9999999999999999999999999999999999999999")
|
||||
|
||||
getCodeContractAddressCalldata, _ := stateManagerAbi.Pack("getCodeContractAddress", address)
|
||||
|
||||
getCodeContractAddressReturnValue, _ := call(t, state, vm.StateManagerAddress, getCodeContractAddressCalldata)
|
||||
|
||||
if !bytes.Equal(getCodeContractAddressReturnValue, address.Bytes()) {
|
||||
t.Errorf("Expected %020x; got %020x", getCodeContractAddressReturnValue, address.Bytes())
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetCodeContractBytecode(t *testing.T) {
|
||||
state := newState()
|
||||
initCode, _ := hex.DecodeString("6080604052348015600f57600080fd5b5060b28061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80639b0b0fda14602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506062565b005b8060008084815260200190815260200160002081905550505056fea265627a7a7231582053ac32a8b70d1cf87fb4ebf5a538ea9d9e773351e6c8afbc4bf6a6c273187f4a64736f6c63430005110032")
|
||||
|
|
|
|||
Loading…
Reference in a new issue