I am curious how to mock a value like ftmscan.com/address/0x230917f8a262..., line 735, which holds a Mapping of a Mapping to a struct: mapping (uint256 => mapping (address => UserInfo)) public userInfo;
Mocking return values is the same, if it's a complex object like arrays or structs or a primitive type. The short answer is you can mock it like this
For userInfo it's a nested map. Nested maps in solidity create a getter functions that have N parameters where N is the number of maps nested. The final return from your getter is
The longer answer is Solidity creates getter functions for maps. Each of these functions has N parameters, where N is the number of maps in storage. If you take a look at the ABI for the Farm contract userInfo has two params.
I am curious how to mock a value like ftmscan.com/address/0x230917f8a262..., line 735, which holds a Mapping of a Mapping to a struct:
mapping (uint256 => mapping (address => UserInfo)) public userInfo;
Thanks and great question!
Mocking return values is the same, if it's a complex object like arrays or structs or a primitive type. The short answer is you can mock it like this
For
userInfo
it's a nested map. Nested maps in solidity create a getter functions that have N parameters where N is the number of maps nested. The final return from your getter isThe longer answer is Solidity creates getter functions for maps. Each of these functions has N parameters, where N is the number of maps in storage. If you take a look at the ABI for the
Farm
contractuserInfo
has two params.This represents a solidity interface
You can mock the
userInfo
function to return based on specific parameters or have a single general return value.Deeper info can be found in their docs smock.readthedocs.io/en/latest/fak...