ethereum / eth-tester

Tool suite for testing ethereum applications.
MIT License
364 stars 146 forks source link

feature request: Add `set_code()` API method #246

Open antazoey opened 2 years ago

antazoey commented 2 years ago

What was wrong?

Looking for adding more options for set_code() to our framework and so this request is to have a way to change the contract code using eth-tester.

How can it be fixed?

    def set_code(self, address: AddressType, code: ContractCode) -> bool:
        vm = _get_vm_for_block_number(self.evm_backend.chain, "latest")
        vm.state.set_code(HexBytes(address), code)
        return True