Skip to content

Commit bbb6f1c

Browse files
Kiril RadkovKiril Radkov
authored andcommitted
update test
1 parent b29cb63 commit bbb6f1c

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

test/BondingCurve.t.sol

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff 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 {

0 commit comments

Comments
 (0)