Help with expectRevert Usage #10036
Unanswered
TheGreatAxios
asked this question in
Help
Replies: 2 comments
-
Beta Was this translation helpful? Give feedback.
0 replies
-
Update 2: Moving the functions to the top level test solved it (of course): function testRevert_failsWithInsufficientLiquidity() public {
// _bridgeAllStableToASkaleStation(HUNDRED_USDC);
_bridgeToSkaleStation(HUNDRED_USDC, bUSDC, aUSDC, bStation);
// _bridgeFromSkaleStation(25e6, aUSDC, dUSDC, dStation, D_EID, true);
LibTypesV1.TripDetails memory details = LibTypesV1.TripDetails(address(aUSDC), address(this), 25e6);
MessagingFee memory fee = aSkaleStation.quote(D_EID, details, options, false);
skl.approve(address(aSkaleStation), fee.nativeFee);
aUSDC.approve(address(aSkaleStation), 25e6);
(uint256 userAmount, ) = _getFee(25e6, aUSDC.decimals());
vm.expectRevert(abi.encodeWithSelector(
TokenSupplyInsufficentForChain.selector,
userAmount,
0,
D_EID
));
aSkaleStation.bridge(D_EID, details, fee, options);
} Goal: Figure out how to allow the error to revert somewhere in the internal call so that I can make the test suite far more reusable. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi team!
Hoping I can get a bit of support as I've combed through issues and deep dived into the specific section of the docs on this, but can't seem to make sense of why I'm still not having the purposed revert be a failed test.
Version: foundryup: 1.0.1, Apple Mac Silicon, Sequoia 15.3.1
Project: https://github.com/Dirt-Road-Development/monorail-contracts
Problem Location: https://github.com/Dirt-Road-Development/monorail-contracts/tree/thegreataxios/hotfix/fix-native-bridgerace-condition in ./test/unit/RaceCondition.sol
Problem: This is a two-way liquidity bridge with a center-chain (SKALE) being the "hub" where tokens are bridged too. During research yesterday I determined that there are a couple possible race conditions that I need to add security checks for within the actual contract (e.g add deposits by endpoint/chain) and that should solve the actual problem. However, I want to have this fully tested to ensure that the problem is being addressed fully. However, the test suite is not working as expected.
My modified layer zero receive function is where I'm throwing the
error InsufficientFundsInBridge()
I have this public test function (which I've tried naming changes as well e.g test_RevertWhen_Insuficient) that I want to catch the revert as part of my step 1. While in theory, once I fix the exit condition I won't need this function, I still want to solve this so I understand how in the recent version of Foundry to catch thrown errors that are nested like this.
What I've Tried
Thanks for any support here!
Beta Was this translation helpful? Give feedback.
All reactions