-
Hi team, Love foundry. Wish I could marry yall. Anyway, posted on TG but here's my issue: I have a reducer function in my application, looks like this: function _reducer(
uint16 _srcChainId,
bytes memory _srcAddress,
Message memory message
) internal {
if (message.action == DEPOSIT_ACTION) {
_depositAction(_srcChainId, message.payload);
} else if (message.action == REQUEST_WITHDRAW_ACTION) {
_requestWithdrawAction(_srcChainId, message.payload);
} else if (message.action == FINALIZE_WITHDRAW_ACTION) {
_finalizeWithdrawAction(_srcChainId, message.payload);
} else if (message.action == REPORT_UNDERLYING_ACTION) {
_reportUnderlyingAction(message.payload);
} else {
revert("XChainHub::_reducer:UNRECOGNISED ACTION");
}
} It's an internal function and I wanna test it, so I wrote a mock contract that supers the function as an external method /// @notice grant access to the internal reducer function
function reducer(
uint16 _srcChainId,
bytes memory _srcAddress,
Message memory message
) external {
super._reducer(_srcChainId, _srcAddress, message);
} My test reverts if I call: hubMockReducer.reducer(
1,
abi.encodePacked(vaultAddr),
hubMockReducer.makeMessage(245)
); But if I stick an expect revert the test fails:
FYI: Make message works fine, have tested that. Any advice much appreciated |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 5 replies
-
Does it work if you use |
Beta Was this translation helpful? Give feedback.
-
Wondering if anyone has had a chance to look into this further @onbjerg ? |
Beta Was this translation helpful? Give feedback.
-
Oh, right. This is because it works for the next call - |
Beta Was this translation helpful? Give feedback.
Oh, right. This is because it works for the next call -
makeMessage
is the next call, and it doesn't revert. I'm not sure why I didn't catch that earlier, I'm sorry. Essentially you need to callmakeMessage
before callingvm.expectRevert