|
1 | 1 | // SPDX-License-Identifier: SEE LICENSE IN LICENSE |
2 | 2 | pragma solidity 0.8.19; |
3 | 3 |
|
| 4 | +import { Vm } from "forge-std/Vm.sol"; |
| 5 | + |
4 | 6 | import { Address } from "@openzeppelin/contracts/utils/Address.sol"; |
5 | 7 |
|
6 | 8 | import { TestFixture } from "./TestFixture.t.sol"; |
@@ -88,7 +90,7 @@ contract CarbonPOLTest is TestFixture { |
88 | 90 | testCaseParser = new POLTestCaseParser(); |
89 | 91 | } |
90 | 92 |
|
91 | | - function testShouldBeInitialized() public { |
| 93 | + function testShouldBeInitialized() public view { |
92 | 94 | uint16 version = carbonPOL.version(); |
93 | 95 | assertEq(version, 2); |
94 | 96 | } |
@@ -124,12 +126,22 @@ contract CarbonPOLTest is TestFixture { |
124 | 126 | carbonPOL.setMarketPriceMultiply(0); |
125 | 127 | } |
126 | 128 |
|
127 | | - /// @dev test that setMarketPriceMultiply with the same value should be ignored |
128 | | - function testFailShouldIgnoreSettingTheSameMarketPriceMultiply() public { |
129 | | - vm.prank(admin); |
130 | | - vm.expectEmit(false, false, false, false); |
131 | | - emit MarketPriceMultiplyUpdated(MARKET_PRICE_MULTIPLY_DEFAULT, MARKET_PRICE_MULTIPLY_DEFAULT); |
| 129 | + /// @dev should ignore setting the same MarketPriceMultiply (no events emitted) |
| 130 | + function testShouldIgnoreSettingTheSameMarketPriceMultiply() public { |
| 131 | + vm.startPrank(admin); |
| 132 | + |
| 133 | + // first set establishes the default value |
132 | 134 | carbonPOL.setMarketPriceMultiply(MARKET_PRICE_MULTIPLY_DEFAULT); |
| 135 | + |
| 136 | + // record logs for the redundant call |
| 137 | + vm.recordLogs(); |
| 138 | + carbonPOL.setMarketPriceMultiply(MARKET_PRICE_MULTIPLY_DEFAULT); |
| 139 | + Vm.Log[] memory logs = vm.getRecordedLogs(); |
| 140 | + |
| 141 | + // ensure no events were emitted |
| 142 | + assertEq(logs.length, 0, "expected no events to be emitted"); |
| 143 | + |
| 144 | + vm.stopPrank(); |
133 | 145 | } |
134 | 146 |
|
135 | 147 | /// @dev test that admin should be able to update the market price multiply |
@@ -165,12 +177,22 @@ contract CarbonPOLTest is TestFixture { |
165 | 177 | carbonPOL.setPriceDecayHalfLife(0); |
166 | 178 | } |
167 | 179 |
|
168 | | - /// @dev test that setPriceDecayHalfLife with the same value should be ignored |
169 | | - function testFailShouldIgnoreSettingTheSamePriceDecayHalfLife() public { |
170 | | - vm.prank(admin); |
171 | | - vm.expectEmit(false, false, false, false); |
172 | | - emit PriceDecayHalfLifeUpdated(PRICE_DECAY_HALFLIFE_DEFAULT, PRICE_DECAY_HALFLIFE_DEFAULT); |
| 180 | + /// @dev should ignore setting the same PriceDecayHalfLife (no events emitted) |
| 181 | + function testShouldIgnoreSettingTheSamePriceDecayHalfLife() public { |
| 182 | + vm.startPrank(admin); |
| 183 | + |
| 184 | + // first set establishes the default value |
| 185 | + carbonPOL.setPriceDecayHalfLife(PRICE_DECAY_HALFLIFE_DEFAULT); |
| 186 | + |
| 187 | + // record logs for the redundant call |
| 188 | + vm.recordLogs(); |
173 | 189 | carbonPOL.setPriceDecayHalfLife(PRICE_DECAY_HALFLIFE_DEFAULT); |
| 190 | + Vm.Log[] memory logs = vm.getRecordedLogs(); |
| 191 | + |
| 192 | + // ensure no events were emitted |
| 193 | + assertEq(logs.length, 0, "expected no events to be emitted"); |
| 194 | + |
| 195 | + vm.stopPrank(); |
174 | 196 | } |
175 | 197 |
|
176 | 198 | /// @dev test that admin should be able to update the price decay half-life |
@@ -206,12 +228,22 @@ contract CarbonPOLTest is TestFixture { |
206 | 228 | carbonPOL.setEthSaleAmount(0); |
207 | 229 | } |
208 | 230 |
|
209 | | - /// @dev test that setEthSaleAmount with the same value should be ignored |
210 | | - function testFailShouldIgnoreSettingTheSameEthSaleAmount() public { |
211 | | - vm.prank(admin); |
212 | | - vm.expectEmit(false, false, false, false); |
213 | | - emit EthSaleAmountUpdated(ETH_SALE_AMOUNT_DEFAULT, ETH_SALE_AMOUNT_DEFAULT); |
| 231 | + /// @dev should ignore setting the same EthSaleAmount (no events emitted) |
| 232 | + function testShouldIgnoreSettingTheSameEthSaleAmount() public { |
| 233 | + vm.startPrank(admin); |
| 234 | + |
| 235 | + // first set establishes the default value |
| 236 | + carbonPOL.setEthSaleAmount(ETH_SALE_AMOUNT_DEFAULT); |
| 237 | + |
| 238 | + // record logs for the redundant call |
| 239 | + vm.recordLogs(); |
214 | 240 | carbonPOL.setEthSaleAmount(ETH_SALE_AMOUNT_DEFAULT); |
| 241 | + Vm.Log[] memory logs = vm.getRecordedLogs(); |
| 242 | + |
| 243 | + // ensure no events were emitted |
| 244 | + assertEq(logs.length, 0, "expected no events to be emitted"); |
| 245 | + |
| 246 | + vm.stopPrank(); |
215 | 247 | } |
216 | 248 |
|
217 | 249 | /// @dev test that admin should be able to update the eth sale amount |
@@ -247,12 +279,22 @@ contract CarbonPOLTest is TestFixture { |
247 | 279 | carbonPOL.setMinEthSaleAmount(0); |
248 | 280 | } |
249 | 281 |
|
250 | | - /// @dev test that setMinEthSaleAmount with the same value should be ignored |
251 | | - function testFailShouldIgnoreSettingTheSameMinEthSaleAmount() public { |
252 | | - vm.prank(admin); |
253 | | - vm.expectEmit(false, false, false, false); |
254 | | - emit MinEthSaleAmountUpdated(MIN_ETH_SALE_AMOUNT_DEFAULT, MIN_ETH_SALE_AMOUNT_DEFAULT); |
| 282 | + /// @dev should ignore setting the same MinEthSaleAmount (no events emitted) |
| 283 | + function testShouldIgnoreSettingTheSameMinEthSaleAmount() public { |
| 284 | + vm.startPrank(admin); |
| 285 | + |
| 286 | + // first set establishes the default value |
| 287 | + carbonPOL.setMinEthSaleAmount(MIN_ETH_SALE_AMOUNT_DEFAULT); |
| 288 | + |
| 289 | + // record logs for the redundant call |
| 290 | + vm.recordLogs(); |
255 | 291 | carbonPOL.setMinEthSaleAmount(MIN_ETH_SALE_AMOUNT_DEFAULT); |
| 292 | + Vm.Log[] memory logs = vm.getRecordedLogs(); |
| 293 | + |
| 294 | + // ensure no events were emitted |
| 295 | + assertEq(logs.length, 0, "expected no events to be emitted"); |
| 296 | + |
| 297 | + vm.stopPrank(); |
256 | 298 | } |
257 | 299 |
|
258 | 300 | /// @dev test that admin should be able to update the min eth sale amount |
@@ -300,7 +342,7 @@ contract CarbonPOLTest is TestFixture { |
300 | 342 | */ |
301 | 343 |
|
302 | 344 | /// @dev test trading should be disabled initially for all tokens |
303 | | - function testTradingShouldBeDisabledInitially(uint256 i) public { |
| 345 | + function testTradingShouldBeDisabledInitially(uint256 i) public view { |
304 | 346 | // pick one of these tokens to test |
305 | 347 | Token[4] memory tokens = [token1, token2, bnt, NATIVE_TOKEN]; |
306 | 348 | // pick a random number from 0 to 2 for the tokens |
|
0 commit comments