near / rainbow-bridge-rs

9 stars 6 forks source link

Test event deserialization code #10

Open MaksymZavershynskyi opened 3 years ago

MaksymZavershynskyi commented 3 years ago

Currently both MintableFungibleToken (deprecated) contract https://github.com/near/rainbow-bridge-rs/blob/master/mintable-fungible-token/src/lib.rs#L416 and token factory https://github.com/near/rainbow-token-connector/blob/master/bridge-token-factory/src/lock_event.rs#L27-L47 have code that deserializes Ethereum events. Unfortunately, we don't have tests to exhaustively check it. See how these events are generated here: https://github.com/near/rainbow-token-connector/blob/master/erc20-connector/contracts/ERC20Locker.sol#L34

We could write code that serializes Ethereum events given various content of Ethereum events (generated by our lockup contract) and then we could use this code to test our deserialization code on various inputs, including corner cases where various parameters of the event are empty, e.g. zero balance, account id is an empty string, etc (zero numbers and empty strings are treated differently by Ethereum serialization). We can repurpose ethabi for it.

MaksymZavershynskyi commented 3 years ago

FYI the tests need to be added into https://github.com/near/rainbow-token-connector. https://github.com/near/rainbow-bridge-rs/blob/master/mintable-fungible-token is an outdated contract that needs to be removed.