You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
pallet-revive: add interface to implement mocks and pranks (#9909)
Needed for: paritytech/foundry-polkadot#334.
In foundry-polkadot we need the ability to be able to manipulate the
`msg.sender` and the `tx.origin` that a solidity contract sees cheatcode
documentation, plus the ability to mock calls and functions.
Currently all create/call methods use the `bare_instantiate`/`bare_call`
to run things in pallet-revive, the caller then normally gets set
automatically, based on what is the call stack, but for `forge test` we
need to be able to manipulate, so that we can set it to custom values.
Additionally, for delegate_call, bare_call is used, so there is no way
to specify we are dealing with a delegate call, so the call is not
working correcly.
For both this paths, we need a way to inject this information into the
execution environment, hence I added an optional hooks interface that we
implement from foundry cheatcodes for prank and mock functionality.
## TODO
- [x] Add tests to make sure the hooks functionality does not regress.
---------
Signed-off-by: Alexandru Gheorghe <[email protected]>
Co-authored-by: cmd[bot] <41898282+github-actions[bot]@users.noreply.github.com>
In foundry-polkadot we need the ability to be able to manipulate the `msg.sender` and the `tx.origin` that a solidity contract sees cheatcode documentation, plus the ability to mock calls and functions.
8
+
9
+
Currently all create/call methods use the `bare_instantiate`/`bare_call` to run things in pallet-revive, the caller then normally gets set automatically, based on what is the call stack, but for `forge test` we need to be able to manipulate, so that we can set it to custom values.
10
+
11
+
Additionally, for delegate_call, bare_call is used, so there is no way to specify we are dealing with a delegate call, so the call is not working correcly.
12
+
13
+
For both this paths, we need a way to inject this information into the execution environment, hence I added an optional hooks interface that we implement from foundry cheatcodes for prank and mock functionality.
0 commit comments