From 9cf0150314c1f40e0e4f42b784129b7b3080b33b Mon Sep 17 00:00:00 2001 From: Mason Fischer Date: Wed, 13 May 2020 17:39:14 -0400 Subject: [PATCH] Add associateCodeContract to state manager --- core/vm/state_manager.go | 5 +++++ tests/ovm_test.go | 15 +++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/core/vm/state_manager.go b/core/vm/state_manager.go index b0ac7005de..25fbd23f71 100644 --- a/core/vm/state_manager.go +++ b/core/vm/state_manager.go @@ -23,6 +23,7 @@ var funcs = map[string]stateManagerFunction{ "getCodeContractBytecode(address)": getCodeContractBytecode, "getCodeContractHash(address)": getCodeContractHash, "getCodeContractAddress(address)": getCodeContractAddress, + "associateCodeContract(address,address)": associateCodeContract, "incrementOvmContractNonce(address)": incrementOvmContractNonce, } var methodIds map[[4]byte]stateManagerFunction @@ -75,6 +76,10 @@ func getCodeContractHash(evm *EVM, contract *Contract, input []byte) (ret []byte return codeHash.Bytes(), nil } +func associateCodeContract(evm *EVM, contract *Contract, input []byte) (ret []byte, err error) { + return nil, nil +} + func getCodeContractAddress(evm *EVM, contract *Contract, input []byte) (ret []byte, err error) { address := input[4:36] return address, nil diff --git a/tests/ovm_test.go b/tests/ovm_test.go index 388a41e704..277a06215b 100644 --- a/tests/ovm_test.go +++ b/tests/ovm_test.go @@ -115,6 +115,21 @@ func TestGetCodeContractAddress(t *testing.T) { } } +func TestAssociateCodeContract(t *testing.T) { + rawStateManagerAbi, _ := ioutil.ReadFile("./StateManagerABI.json") + stateManagerAbi, _ := abi.JSON(strings.NewReader(string(rawStateManagerAbi))) + state := newState() + + address := common.HexToAddress("9999999999999999999999999999999999999999") + + getCodeContractAddressCalldata, _ := stateManagerAbi.Pack("associateCodeContract", address, address) + + _, err := call(t, state, vm.StateManagerAddress, getCodeContractAddressCalldata) + if err != nil { + t.Errorf("Failed to call associateCodeContract: %s", err) + } +} + func TestGetCodeContractBytecode(t *testing.T) { state := newState() initCode, _ := hex.DecodeString("6080604052348015600f57600080fd5b5060b28061001e6000396000f3fe6080604052348015600f57600080fd5b506004361060285760003560e01c80639b0b0fda14602d575b600080fd5b606060048036036040811015604157600080fd5b8101908080359060200190929190803590602001909291905050506062565b005b8060008084815260200190815260200160002081905550505056fea265627a7a7231582053ac32a8b70d1cf87fb4ebf5a538ea9d9e773351e6c8afbc4bf6a6c273187f4a64736f6c63430005110032")