gnosis / mock-contract

Simple Solidity contract to mock dependent contracts in truffle tests.
94 stars 24 forks source link

Fix mocking functions that return address #11

Closed fleupold closed 5 years ago

fleupold commented 5 years ago

The added unit test currently reverts the transaction, because the way we convert address to bytes doesn't seem to be valid. This surfaces if a contract under test calls a mocked method that returns an address (originally reported from a failing test here: https://github.com/okwme/safe-contracts/blob/billy/arbitrage-module/test/arbitrageModule.js#L75). Note, that this issue doesn't happen when the mocked method is called directly from JS (however mocking only makes sense when mocked method is called from another smart contract).

Instead of using the complicated way of converting address into bytes (originally taken from: https://ethereum.stackexchange.com/questions/884/how-to-convert-an-address-to-bytes-in-solidity), it seems to be fine to convert the address into uint and use the existing uintToBytes method.