File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -101,8 +101,23 @@ contract BondingCurveTest is Test {
101101
102102 // Try to sell more tokens than possible
103103 uint256 maxTokens = BondingCurve.calculatePurchaseReturn (0 , ethSupply);
104- vm.expectRevert (BondingCurve.FormulaInvalidTokenAmount.selector );
105- BondingCurve.calculateSellReturn (ethSupply, maxTokens * 2 );
104+ try this .callCalculateSellReturn (ethSupply, maxTokens * 2 ) {
105+ fail ();
106+ } catch Error (string memory ) {
107+ fail ();
108+ } catch (bytes memory returnData ) {
109+ bytes4 expectedSelector = BondingCurve.FormulaInvalidTokenAmount.selector ;
110+ bytes4 actualSelector;
111+ assembly {
112+ actualSelector := mload (add (returnData, 0x20 ))
113+ }
114+ assertEq (actualSelector, expectedSelector, "Wrong error selector " );
115+ }
116+ }
117+
118+ // Helper function to call the library function externally
119+ function callCalculateSellReturn (uint256 ethSupply , uint256 tokenAmount ) external pure returns (uint256 ) {
120+ return BondingCurve.calculateSellReturn (ethSupply, tokenAmount);
106121 }
107122
108123 function test_PriceProgression () public {
You can’t perform that action at this time.
0 commit comments