@lemmaoracle/x402 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/broadcast/DeployPaymentVerifier.s.sol/10143/run-1775996174982.json +34 -0
- package/broadcast/DeployPaymentVerifier.s.sol/10143/run-1775996423983.json +51 -0
- package/broadcast/DeployPaymentVerifier.s.sol/10143/run-1775996907850.json +51 -0
- package/broadcast/DeployPaymentVerifier.s.sol/10143/run-latest.json +51 -0
- package/cache/DeployPaymentVerifier.s.sol/10143/run-1775996174982.json +7 -0
- package/cache/DeployPaymentVerifier.s.sol/10143/run-1775996423983.json +7 -0
- package/cache/DeployPaymentVerifier.s.sol/10143/run-1775996907850.json +7 -0
- package/cache/DeployPaymentVerifier.s.sol/10143/run-latest.json +7 -0
- package/cache/solidity-files-cache.json +1 -0
- package/circuits/README.md +78 -0
- package/circuits/payment-comprehensive.test.mjs +272 -0
- package/circuits/payment.circom +89 -0
- package/circuits/payment.test.mjs +173 -0
- package/dist/index.d.ts +48 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +83 -0
- package/dist/index.js.map +1 -0
- package/dist/proof-generator.d.ts +26 -0
- package/dist/proof-generator.d.ts.map +1 -0
- package/dist/proof-generator.js +154 -0
- package/dist/proof-generator.js.map +1 -0
- package/dist/proof-generator.test.d.ts +7 -0
- package/dist/proof-generator.test.d.ts.map +1 -0
- package/dist/proof-generator.test.js +121 -0
- package/dist/proof-generator.test.js.map +1 -0
- package/dist/transaction-watcher.d.ts +42 -0
- package/dist/transaction-watcher.d.ts.map +1 -0
- package/dist/transaction-watcher.js +88 -0
- package/dist/transaction-watcher.js.map +1 -0
- package/dist/transaction-watcher.test.d.ts +7 -0
- package/dist/transaction-watcher.test.d.ts.map +1 -0
- package/dist/transaction-watcher.test.js +111 -0
- package/dist/transaction-watcher.test.js.map +1 -0
- package/dist/types.d.ts +76 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/foundry.lock +11 -0
- package/foundry.toml +16 -0
- package/lib/forge-std/.gitattributes +1 -0
- package/lib/forge-std/.github/CODEOWNERS +1 -0
- package/lib/forge-std/.github/dependabot.yml +6 -0
- package/lib/forge-std/.github/workflows/ci.yml +161 -0
- package/lib/forge-std/.github/workflows/sync.yml +36 -0
- package/lib/forge-std/CONTRIBUTING.md +193 -0
- package/lib/forge-std/LICENSE-APACHE +203 -0
- package/lib/forge-std/LICENSE-MIT +25 -0
- package/lib/forge-std/README.md +314 -0
- package/lib/forge-std/RELEASE_CHECKLIST.md +12 -0
- package/lib/forge-std/foundry.toml +18 -0
- package/lib/forge-std/package.json +16 -0
- package/lib/forge-std/scripts/vm.py +636 -0
- package/lib/forge-std/src/Base.sol +48 -0
- package/lib/forge-std/src/Config.sol +60 -0
- package/lib/forge-std/src/LibVariable.sol +477 -0
- package/lib/forge-std/src/Script.sol +28 -0
- package/lib/forge-std/src/StdAssertions.sol +1300 -0
- package/lib/forge-std/src/StdChains.sol +303 -0
- package/lib/forge-std/src/StdCheats.sol +825 -0
- package/lib/forge-std/src/StdConfig.sol +632 -0
- package/lib/forge-std/src/StdConstants.sol +30 -0
- package/lib/forge-std/src/StdError.sol +15 -0
- package/lib/forge-std/src/StdInvariant.sol +161 -0
- package/lib/forge-std/src/StdJson.sol +275 -0
- package/lib/forge-std/src/StdMath.sol +47 -0
- package/lib/forge-std/src/StdStorage.sol +476 -0
- package/lib/forge-std/src/StdStyle.sol +333 -0
- package/lib/forge-std/src/StdToml.sol +275 -0
- package/lib/forge-std/src/StdUtils.sol +200 -0
- package/lib/forge-std/src/Test.sol +32 -0
- package/lib/forge-std/src/Vm.sol +2533 -0
- package/lib/forge-std/src/console.sol +1551 -0
- package/lib/forge-std/src/console2.sol +4 -0
- package/lib/forge-std/src/interfaces/IERC1155.sol +105 -0
- package/lib/forge-std/src/interfaces/IERC165.sol +12 -0
- package/lib/forge-std/src/interfaces/IERC20.sol +43 -0
- package/lib/forge-std/src/interfaces/IERC4626.sol +190 -0
- package/lib/forge-std/src/interfaces/IERC6909.sol +72 -0
- package/lib/forge-std/src/interfaces/IERC721.sol +164 -0
- package/lib/forge-std/src/interfaces/IERC7540.sol +145 -0
- package/lib/forge-std/src/interfaces/IERC7575.sol +241 -0
- package/lib/forge-std/src/interfaces/IMulticall3.sol +68 -0
- package/lib/forge-std/src/safeconsole.sol +13248 -0
- package/lib/forge-std/test/CommonBase.t.sol +44 -0
- package/lib/forge-std/test/Config.t.sol +381 -0
- package/lib/forge-std/test/LibVariable.t.sol +452 -0
- package/lib/forge-std/test/StdAssertions.t.sol +141 -0
- package/lib/forge-std/test/StdChains.t.sol +227 -0
- package/lib/forge-std/test/StdCheats.t.sol +638 -0
- package/lib/forge-std/test/StdConstants.t.sol +38 -0
- package/lib/forge-std/test/StdError.t.sol +119 -0
- package/lib/forge-std/test/StdJson.t.sol +49 -0
- package/lib/forge-std/test/StdMath.t.sol +202 -0
- package/lib/forge-std/test/StdStorage.t.sol +532 -0
- package/lib/forge-std/test/StdStyle.t.sol +110 -0
- package/lib/forge-std/test/StdToml.t.sol +49 -0
- package/lib/forge-std/test/StdUtils.t.sol +342 -0
- package/lib/forge-std/test/Vm.t.sol +18 -0
- package/lib/forge-std/test/compilation/CompilationScript.sol +8 -0
- package/lib/forge-std/test/compilation/CompilationScriptBase.sol +8 -0
- package/lib/forge-std/test/compilation/CompilationTest.sol +8 -0
- package/lib/forge-std/test/compilation/CompilationTestBase.sol +8 -0
- package/lib/forge-std/test/fixtures/broadcast.log.json +187 -0
- package/lib/forge-std/test/fixtures/config.toml +81 -0
- package/lib/forge-std/test/fixtures/test.json +8 -0
- package/lib/forge-std/test/fixtures/test.toml +6 -0
- package/package.json +55 -0
- package/package.json.backup +55 -0
- package/scripts/DeployPaymentVerifier.s.sol +18 -0
- package/scripts/build.sh +61 -0
- package/scripts/deploy.sh +65 -0
- package/scripts/fix-verifier.mjs +64 -0
- package/scripts/register-circuit.ts +213 -0
- package/scripts/test-with-circuit.mjs +88 -0
- package/src/index.ts +115 -0
- package/src/proof-generator.test.ts +139 -0
- package/src/proof-generator.ts +220 -0
- package/src/transaction-watcher.test.ts +153 -0
- package/src/transaction-watcher.ts +154 -0
- package/src/types.ts +110 -0
- package/tsconfig.json +14 -0
- package/tsconfig.tsbuildinfo +1 -0
- package/vitest.config.ts +18 -0
- package/workers/x402-facilitator/src/index.ts +582 -0
- package/workers/x402-facilitator/src/x402-env.d.ts +25 -0
- package/workers/x402-facilitator/wrangler.toml +19 -0
|
@@ -0,0 +1,1300 @@
|
|
|
1
|
+
// SPDX-License-Identifier: MIT OR Apache-2.0
|
|
2
|
+
pragma solidity >=0.8.13 <0.9.0;
|
|
3
|
+
|
|
4
|
+
import {Vm} from "./Vm.sol";
|
|
5
|
+
|
|
6
|
+
/// @notice Abstract contract providing assertion utilities for Forge tests.
|
|
7
|
+
abstract contract StdAssertions {
|
|
8
|
+
Vm private constant vm = Vm(address(uint160(uint256(keccak256("hevm cheat code")))));
|
|
9
|
+
|
|
10
|
+
event log(string);
|
|
11
|
+
event logs(bytes);
|
|
12
|
+
|
|
13
|
+
event log_address(address);
|
|
14
|
+
event log_bytes32(bytes32);
|
|
15
|
+
event log_int(int256);
|
|
16
|
+
event log_uint(uint256);
|
|
17
|
+
event log_bytes(bytes);
|
|
18
|
+
event log_string(string);
|
|
19
|
+
|
|
20
|
+
event log_named_address(string key, address val);
|
|
21
|
+
event log_named_bytes32(string key, bytes32 val);
|
|
22
|
+
event log_named_decimal_int(string key, int256 val, uint256 decimals);
|
|
23
|
+
event log_named_decimal_uint(string key, uint256 val, uint256 decimals);
|
|
24
|
+
event log_named_int(string key, int256 val);
|
|
25
|
+
event log_named_uint(string key, uint256 val);
|
|
26
|
+
event log_named_bytes(string key, bytes val);
|
|
27
|
+
event log_named_string(string key, string val);
|
|
28
|
+
|
|
29
|
+
event log_array(uint256[] val);
|
|
30
|
+
event log_array(int256[] val);
|
|
31
|
+
event log_array(address[] val);
|
|
32
|
+
event log_named_array(string key, uint256[] val);
|
|
33
|
+
event log_named_array(string key, int256[] val);
|
|
34
|
+
event log_named_array(string key, address[] val);
|
|
35
|
+
|
|
36
|
+
bytes32 private constant FAILED_SLOT = bytes32("failed");
|
|
37
|
+
|
|
38
|
+
bool private _failed;
|
|
39
|
+
|
|
40
|
+
/// @notice Returns true if any test assertion has failed.
|
|
41
|
+
/// @return True if any assertion has failed, false otherwise.
|
|
42
|
+
function failed() public view returns (bool) {
|
|
43
|
+
if (_failed) {
|
|
44
|
+
return true;
|
|
45
|
+
} else {
|
|
46
|
+
return vm.load(address(vm), FAILED_SLOT) != bytes32(0);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/// @notice Marks the test as failed and records the failure in storage.
|
|
51
|
+
function fail() internal virtual {
|
|
52
|
+
vm.store(address(vm), FAILED_SLOT, bytes32(uint256(1)));
|
|
53
|
+
_failed = true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/// @notice Marks the test as failed with a custom message.
|
|
57
|
+
/// @param message The failure message to display.
|
|
58
|
+
function fail(string memory message) internal virtual {
|
|
59
|
+
fail();
|
|
60
|
+
vm.assertTrue(false, message);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/// @notice Asserts that `data` is true.
|
|
64
|
+
/// @param data The boolean value to assert.
|
|
65
|
+
function assertTrue(bool data) internal pure virtual {
|
|
66
|
+
if (!data) {
|
|
67
|
+
vm.assertTrue(data);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/// @notice Asserts that `data` is true with a custom error message.
|
|
72
|
+
/// @param data The boolean value to assert.
|
|
73
|
+
/// @param err The error message on failure.
|
|
74
|
+
function assertTrue(bool data, string memory err) internal pure virtual {
|
|
75
|
+
if (!data) {
|
|
76
|
+
vm.assertTrue(data, err);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/// @notice Asserts that `data` is false.
|
|
81
|
+
/// @param data The boolean value to assert.
|
|
82
|
+
function assertFalse(bool data) internal pure virtual {
|
|
83
|
+
if (data) {
|
|
84
|
+
vm.assertFalse(data);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/// @notice Asserts that `data` is false with a custom error message.
|
|
89
|
+
/// @param data The boolean value to assert.
|
|
90
|
+
/// @param err The error message on failure.
|
|
91
|
+
function assertFalse(bool data, string memory err) internal pure virtual {
|
|
92
|
+
if (data) {
|
|
93
|
+
vm.assertFalse(data, err);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
98
|
+
/// @param left The left-hand side value.
|
|
99
|
+
/// @param right The right-hand side value.
|
|
100
|
+
function assertEq(bool left, bool right) internal pure virtual {
|
|
101
|
+
if (left != right) {
|
|
102
|
+
vm.assertEq(left, right);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
107
|
+
/// @param left The left-hand side value.
|
|
108
|
+
/// @param right The right-hand side value.
|
|
109
|
+
/// @param err The error message on failure.
|
|
110
|
+
function assertEq(bool left, bool right, string memory err) internal pure virtual {
|
|
111
|
+
if (left != right) {
|
|
112
|
+
vm.assertEq(left, right, err);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
117
|
+
/// @param left The left-hand side value.
|
|
118
|
+
/// @param right The right-hand side value.
|
|
119
|
+
function assertEq(uint256 left, uint256 right) internal pure virtual {
|
|
120
|
+
if (left != right) {
|
|
121
|
+
vm.assertEq(left, right);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
126
|
+
/// @param left The left-hand side value.
|
|
127
|
+
/// @param right The right-hand side value.
|
|
128
|
+
/// @param err The error message on failure.
|
|
129
|
+
function assertEq(uint256 left, uint256 right, string memory err) internal pure virtual {
|
|
130
|
+
if (left != right) {
|
|
131
|
+
vm.assertEq(left, right, err);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/// @notice Asserts that `left` is equal to `right`, formatting values with `decimals` decimal places on failure.
|
|
136
|
+
/// @param left The left-hand side value.
|
|
137
|
+
/// @param right The right-hand side value.
|
|
138
|
+
/// @param decimals The number of decimals for formatting.
|
|
139
|
+
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual {
|
|
140
|
+
vm.assertEqDecimal(left, right, decimals);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/// @notice Asserts that `left` is equal to `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
144
|
+
/// @param left The left-hand side value.
|
|
145
|
+
/// @param right The right-hand side value.
|
|
146
|
+
/// @param decimals The number of decimals for formatting.
|
|
147
|
+
/// @param err The error message on failure.
|
|
148
|
+
function assertEqDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual {
|
|
149
|
+
vm.assertEqDecimal(left, right, decimals, err);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
153
|
+
/// @param left The left-hand side value.
|
|
154
|
+
/// @param right The right-hand side value.
|
|
155
|
+
function assertEq(int256 left, int256 right) internal pure virtual {
|
|
156
|
+
if (left != right) {
|
|
157
|
+
vm.assertEq(left, right);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
162
|
+
/// @param left The left-hand side value.
|
|
163
|
+
/// @param right The right-hand side value.
|
|
164
|
+
/// @param err The error message on failure.
|
|
165
|
+
function assertEq(int256 left, int256 right, string memory err) internal pure virtual {
|
|
166
|
+
if (left != right) {
|
|
167
|
+
vm.assertEq(left, right, err);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
/// @notice Asserts that `left` is equal to `right`, formatting values with `decimals` decimal places on failure.
|
|
172
|
+
/// @param left The left-hand side value.
|
|
173
|
+
/// @param right The right-hand side value.
|
|
174
|
+
/// @param decimals The number of decimals for formatting.
|
|
175
|
+
function assertEqDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual {
|
|
176
|
+
vm.assertEqDecimal(left, right, decimals);
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/// @notice Asserts that `left` is equal to `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
180
|
+
/// @param left The left-hand side value.
|
|
181
|
+
/// @param right The right-hand side value.
|
|
182
|
+
/// @param decimals The number of decimals for formatting.
|
|
183
|
+
/// @param err The error message on failure.
|
|
184
|
+
function assertEqDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual {
|
|
185
|
+
vm.assertEqDecimal(left, right, decimals, err);
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
189
|
+
/// @param left The left-hand side value.
|
|
190
|
+
/// @param right The right-hand side value.
|
|
191
|
+
function assertEq(address left, address right) internal pure virtual {
|
|
192
|
+
if (left != right) {
|
|
193
|
+
vm.assertEq(left, right);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
198
|
+
/// @param left The left-hand side value.
|
|
199
|
+
/// @param right The right-hand side value.
|
|
200
|
+
/// @param err The error message on failure.
|
|
201
|
+
function assertEq(address left, address right, string memory err) internal pure virtual {
|
|
202
|
+
if (left != right) {
|
|
203
|
+
vm.assertEq(left, right, err);
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
208
|
+
/// @param left The left-hand side value.
|
|
209
|
+
/// @param right The right-hand side value.
|
|
210
|
+
function assertEq(bytes32 left, bytes32 right) internal pure virtual {
|
|
211
|
+
if (left != right) {
|
|
212
|
+
vm.assertEq(left, right);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
217
|
+
/// @param left The left-hand side value.
|
|
218
|
+
/// @param right The right-hand side value.
|
|
219
|
+
/// @param err The error message on failure.
|
|
220
|
+
function assertEq(bytes32 left, bytes32 right, string memory err) internal pure virtual {
|
|
221
|
+
if (left != right) {
|
|
222
|
+
vm.assertEq(left, right, err);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/// @notice Asserts that `left` is equal to `right` (legacy bytes32 variant).
|
|
227
|
+
/// @dev Alias for assertEq(bytes32,bytes32) kept for backwards-compatibility.
|
|
228
|
+
/// @param left The left-hand side value.
|
|
229
|
+
/// @param right The right-hand side value.
|
|
230
|
+
function assertEq32(bytes32 left, bytes32 right) internal pure virtual {
|
|
231
|
+
if (left != right) {
|
|
232
|
+
vm.assertEq(left, right);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message (legacy bytes32 variant).
|
|
237
|
+
/// @dev Alias for assertEq(bytes32,bytes32,string) kept for backwards-compatibility.
|
|
238
|
+
/// @param left The left-hand side value.
|
|
239
|
+
/// @param right The right-hand side value.
|
|
240
|
+
/// @param err The error message on failure.
|
|
241
|
+
function assertEq32(bytes32 left, bytes32 right, string memory err) internal pure virtual {
|
|
242
|
+
if (left != right) {
|
|
243
|
+
vm.assertEq(left, right, err);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
248
|
+
/// @param left The left-hand side value.
|
|
249
|
+
/// @param right The right-hand side value.
|
|
250
|
+
function assertEq(string memory left, string memory right) internal pure virtual {
|
|
251
|
+
vm.assertEq(left, right);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
255
|
+
/// @param left The left-hand side value.
|
|
256
|
+
/// @param right The right-hand side value.
|
|
257
|
+
/// @param err The error message on failure.
|
|
258
|
+
function assertEq(string memory left, string memory right, string memory err) internal pure virtual {
|
|
259
|
+
vm.assertEq(left, right, err);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
263
|
+
/// @param left The left-hand side value.
|
|
264
|
+
/// @param right The right-hand side value.
|
|
265
|
+
function assertEq(bytes memory left, bytes memory right) internal pure virtual {
|
|
266
|
+
vm.assertEq(left, right);
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
270
|
+
/// @param left The left-hand side value.
|
|
271
|
+
/// @param right The right-hand side value.
|
|
272
|
+
/// @param err The error message on failure.
|
|
273
|
+
function assertEq(bytes memory left, bytes memory right, string memory err) internal pure virtual {
|
|
274
|
+
vm.assertEq(left, right, err);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
278
|
+
/// @param left The left-hand side value.
|
|
279
|
+
/// @param right The right-hand side value.
|
|
280
|
+
function assertEq(bool[] memory left, bool[] memory right) internal pure virtual {
|
|
281
|
+
vm.assertEq(left, right);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
285
|
+
/// @param left The left-hand side value.
|
|
286
|
+
/// @param right The right-hand side value.
|
|
287
|
+
/// @param err The error message on failure.
|
|
288
|
+
function assertEq(bool[] memory left, bool[] memory right, string memory err) internal pure virtual {
|
|
289
|
+
vm.assertEq(left, right, err);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
293
|
+
/// @param left The left-hand side value.
|
|
294
|
+
/// @param right The right-hand side value.
|
|
295
|
+
function assertEq(uint256[] memory left, uint256[] memory right) internal pure virtual {
|
|
296
|
+
vm.assertEq(left, right);
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
300
|
+
/// @param left The left-hand side value.
|
|
301
|
+
/// @param right The right-hand side value.
|
|
302
|
+
/// @param err The error message on failure.
|
|
303
|
+
function assertEq(uint256[] memory left, uint256[] memory right, string memory err) internal pure virtual {
|
|
304
|
+
vm.assertEq(left, right, err);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
308
|
+
/// @param left The left-hand side value.
|
|
309
|
+
/// @param right The right-hand side value.
|
|
310
|
+
function assertEq(int256[] memory left, int256[] memory right) internal pure virtual {
|
|
311
|
+
vm.assertEq(left, right);
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
315
|
+
/// @param left The left-hand side value.
|
|
316
|
+
/// @param right The right-hand side value.
|
|
317
|
+
/// @param err The error message on failure.
|
|
318
|
+
function assertEq(int256[] memory left, int256[] memory right, string memory err) internal pure virtual {
|
|
319
|
+
vm.assertEq(left, right, err);
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
323
|
+
/// @param left The left-hand side value.
|
|
324
|
+
/// @param right The right-hand side value.
|
|
325
|
+
function assertEq(address[] memory left, address[] memory right) internal pure virtual {
|
|
326
|
+
vm.assertEq(left, right);
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
330
|
+
/// @param left The left-hand side value.
|
|
331
|
+
/// @param right The right-hand side value.
|
|
332
|
+
/// @param err The error message on failure.
|
|
333
|
+
function assertEq(address[] memory left, address[] memory right, string memory err) internal pure virtual {
|
|
334
|
+
vm.assertEq(left, right, err);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
338
|
+
/// @param left The left-hand side value.
|
|
339
|
+
/// @param right The right-hand side value.
|
|
340
|
+
function assertEq(bytes32[] memory left, bytes32[] memory right) internal pure virtual {
|
|
341
|
+
vm.assertEq(left, right);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
345
|
+
/// @param left The left-hand side value.
|
|
346
|
+
/// @param right The right-hand side value.
|
|
347
|
+
/// @param err The error message on failure.
|
|
348
|
+
function assertEq(bytes32[] memory left, bytes32[] memory right, string memory err) internal pure virtual {
|
|
349
|
+
vm.assertEq(left, right, err);
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
353
|
+
/// @param left The left-hand side value.
|
|
354
|
+
/// @param right The right-hand side value.
|
|
355
|
+
function assertEq(string[] memory left, string[] memory right) internal pure virtual {
|
|
356
|
+
vm.assertEq(left, right);
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
360
|
+
/// @param left The left-hand side value.
|
|
361
|
+
/// @param right The right-hand side value.
|
|
362
|
+
/// @param err The error message on failure.
|
|
363
|
+
function assertEq(string[] memory left, string[] memory right, string memory err) internal pure virtual {
|
|
364
|
+
vm.assertEq(left, right, err);
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
/// @notice Asserts that `left` is equal to `right`.
|
|
368
|
+
/// @param left The left-hand side value.
|
|
369
|
+
/// @param right The right-hand side value.
|
|
370
|
+
function assertEq(bytes[] memory left, bytes[] memory right) internal pure virtual {
|
|
371
|
+
vm.assertEq(left, right);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message.
|
|
375
|
+
/// @param left The left-hand side value.
|
|
376
|
+
/// @param right The right-hand side value.
|
|
377
|
+
/// @param err The error message on failure.
|
|
378
|
+
function assertEq(bytes[] memory left, bytes[] memory right, string memory err) internal pure virtual {
|
|
379
|
+
vm.assertEq(left, right, err);
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
// Legacy helper
|
|
383
|
+
/// @notice Asserts that `left` is equal to `right` (legacy uint256 variant).
|
|
384
|
+
/// @dev Legacy helper kept for backwards-compatibility.
|
|
385
|
+
/// @param left The left-hand side value.
|
|
386
|
+
/// @param right The right-hand side value.
|
|
387
|
+
function assertEqUint(uint256 left, uint256 right) internal pure virtual {
|
|
388
|
+
assertEq(left, right);
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
392
|
+
/// @param left The left-hand side value.
|
|
393
|
+
/// @param right The right-hand side value.
|
|
394
|
+
function assertNotEq(bool left, bool right) internal pure virtual {
|
|
395
|
+
if (left == right) {
|
|
396
|
+
vm.assertNotEq(left, right);
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
401
|
+
/// @param left The left-hand side value.
|
|
402
|
+
/// @param right The right-hand side value.
|
|
403
|
+
/// @param err The error message on failure.
|
|
404
|
+
function assertNotEq(bool left, bool right, string memory err) internal pure virtual {
|
|
405
|
+
if (left == right) {
|
|
406
|
+
vm.assertNotEq(left, right, err);
|
|
407
|
+
}
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
411
|
+
/// @param left The left-hand side value.
|
|
412
|
+
/// @param right The right-hand side value.
|
|
413
|
+
function assertNotEq(uint256 left, uint256 right) internal pure virtual {
|
|
414
|
+
if (left == right) {
|
|
415
|
+
vm.assertNotEq(left, right);
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
420
|
+
/// @param left The left-hand side value.
|
|
421
|
+
/// @param right The right-hand side value.
|
|
422
|
+
/// @param err The error message on failure.
|
|
423
|
+
function assertNotEq(uint256 left, uint256 right, string memory err) internal pure virtual {
|
|
424
|
+
if (left == right) {
|
|
425
|
+
vm.assertNotEq(left, right, err);
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/// @notice Asserts that `left` is not equal to `right`, formatting values with `decimals` decimal places on failure.
|
|
430
|
+
/// @param left The left-hand side value.
|
|
431
|
+
/// @param right The right-hand side value.
|
|
432
|
+
/// @param decimals The number of decimals for formatting.
|
|
433
|
+
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual {
|
|
434
|
+
vm.assertNotEqDecimal(left, right, decimals);
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
/// @notice Asserts that `left` is not equal to `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
438
|
+
/// @param left The left-hand side value.
|
|
439
|
+
/// @param right The right-hand side value.
|
|
440
|
+
/// @param decimals The number of decimals for formatting.
|
|
441
|
+
/// @param err The error message on failure.
|
|
442
|
+
function assertNotEqDecimal(uint256 left, uint256 right, uint256 decimals, string memory err)
|
|
443
|
+
internal
|
|
444
|
+
pure
|
|
445
|
+
virtual
|
|
446
|
+
{
|
|
447
|
+
vm.assertNotEqDecimal(left, right, decimals, err);
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
451
|
+
/// @param left The left-hand side value.
|
|
452
|
+
/// @param right The right-hand side value.
|
|
453
|
+
function assertNotEq(int256 left, int256 right) internal pure virtual {
|
|
454
|
+
if (left == right) {
|
|
455
|
+
vm.assertNotEq(left, right);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
460
|
+
/// @param left The left-hand side value.
|
|
461
|
+
/// @param right The right-hand side value.
|
|
462
|
+
/// @param err The error message on failure.
|
|
463
|
+
function assertNotEq(int256 left, int256 right, string memory err) internal pure virtual {
|
|
464
|
+
if (left == right) {
|
|
465
|
+
vm.assertNotEq(left, right, err);
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
/// @notice Asserts that `left` is not equal to `right`, formatting values with `decimals` decimal places on failure.
|
|
470
|
+
/// @param left The left-hand side value.
|
|
471
|
+
/// @param right The right-hand side value.
|
|
472
|
+
/// @param decimals The number of decimals for formatting.
|
|
473
|
+
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual {
|
|
474
|
+
vm.assertNotEqDecimal(left, right, decimals);
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
/// @notice Asserts that `left` is not equal to `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
478
|
+
/// @param left The left-hand side value.
|
|
479
|
+
/// @param right The right-hand side value.
|
|
480
|
+
/// @param decimals The number of decimals for formatting.
|
|
481
|
+
/// @param err The error message on failure.
|
|
482
|
+
function assertNotEqDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual {
|
|
483
|
+
vm.assertNotEqDecimal(left, right, decimals, err);
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
487
|
+
/// @param left The left-hand side value.
|
|
488
|
+
/// @param right The right-hand side value.
|
|
489
|
+
function assertNotEq(address left, address right) internal pure virtual {
|
|
490
|
+
if (left == right) {
|
|
491
|
+
vm.assertNotEq(left, right);
|
|
492
|
+
}
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
496
|
+
/// @param left The left-hand side value.
|
|
497
|
+
/// @param right The right-hand side value.
|
|
498
|
+
/// @param err The error message on failure.
|
|
499
|
+
function assertNotEq(address left, address right, string memory err) internal pure virtual {
|
|
500
|
+
if (left == right) {
|
|
501
|
+
vm.assertNotEq(left, right, err);
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
|
|
505
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
506
|
+
/// @param left The left-hand side value.
|
|
507
|
+
/// @param right The right-hand side value.
|
|
508
|
+
function assertNotEq(bytes32 left, bytes32 right) internal pure virtual {
|
|
509
|
+
if (left == right) {
|
|
510
|
+
vm.assertNotEq(left, right);
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
515
|
+
/// @param left The left-hand side value.
|
|
516
|
+
/// @param right The right-hand side value.
|
|
517
|
+
/// @param err The error message on failure.
|
|
518
|
+
function assertNotEq(bytes32 left, bytes32 right, string memory err) internal pure virtual {
|
|
519
|
+
if (left == right) {
|
|
520
|
+
vm.assertNotEq(left, right, err);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
/// @notice Asserts that `left` is not equal to `right` (legacy bytes32 variant).
|
|
525
|
+
/// @dev Alias for assertNotEq(bytes32,bytes32) kept for backwards-compatibility.
|
|
526
|
+
/// @param left The left-hand side value.
|
|
527
|
+
/// @param right The right-hand side value.
|
|
528
|
+
function assertNotEq32(bytes32 left, bytes32 right) internal pure virtual {
|
|
529
|
+
if (left == right) {
|
|
530
|
+
vm.assertNotEq(left, right);
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message (legacy bytes32 variant).
|
|
535
|
+
/// @dev Alias for assertNotEq(bytes32,bytes32,string) kept for backwards-compatibility.
|
|
536
|
+
/// @param left The left-hand side value.
|
|
537
|
+
/// @param right The right-hand side value.
|
|
538
|
+
/// @param err The error message on failure.
|
|
539
|
+
function assertNotEq32(bytes32 left, bytes32 right, string memory err) internal pure virtual {
|
|
540
|
+
if (left == right) {
|
|
541
|
+
vm.assertNotEq(left, right, err);
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
546
|
+
/// @param left The left-hand side value.
|
|
547
|
+
/// @param right The right-hand side value.
|
|
548
|
+
function assertNotEq(string memory left, string memory right) internal pure virtual {
|
|
549
|
+
vm.assertNotEq(left, right);
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
553
|
+
/// @param left The left-hand side value.
|
|
554
|
+
/// @param right The right-hand side value.
|
|
555
|
+
/// @param err The error message on failure.
|
|
556
|
+
function assertNotEq(string memory left, string memory right, string memory err) internal pure virtual {
|
|
557
|
+
vm.assertNotEq(left, right, err);
|
|
558
|
+
}
|
|
559
|
+
|
|
560
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
561
|
+
/// @param left The left-hand side value.
|
|
562
|
+
/// @param right The right-hand side value.
|
|
563
|
+
function assertNotEq(bytes memory left, bytes memory right) internal pure virtual {
|
|
564
|
+
vm.assertNotEq(left, right);
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
568
|
+
/// @param left The left-hand side value.
|
|
569
|
+
/// @param right The right-hand side value.
|
|
570
|
+
/// @param err The error message on failure.
|
|
571
|
+
function assertNotEq(bytes memory left, bytes memory right, string memory err) internal pure virtual {
|
|
572
|
+
vm.assertNotEq(left, right, err);
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
576
|
+
/// @param left The left-hand side value.
|
|
577
|
+
/// @param right The right-hand side value.
|
|
578
|
+
function assertNotEq(bool[] memory left, bool[] memory right) internal pure virtual {
|
|
579
|
+
vm.assertNotEq(left, right);
|
|
580
|
+
}
|
|
581
|
+
|
|
582
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
583
|
+
/// @param left The left-hand side value.
|
|
584
|
+
/// @param right The right-hand side value.
|
|
585
|
+
/// @param err The error message on failure.
|
|
586
|
+
function assertNotEq(bool[] memory left, bool[] memory right, string memory err) internal pure virtual {
|
|
587
|
+
vm.assertNotEq(left, right, err);
|
|
588
|
+
}
|
|
589
|
+
|
|
590
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
591
|
+
/// @param left The left-hand side value.
|
|
592
|
+
/// @param right The right-hand side value.
|
|
593
|
+
function assertNotEq(uint256[] memory left, uint256[] memory right) internal pure virtual {
|
|
594
|
+
vm.assertNotEq(left, right);
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
598
|
+
/// @param left The left-hand side value.
|
|
599
|
+
/// @param right The right-hand side value.
|
|
600
|
+
/// @param err The error message on failure.
|
|
601
|
+
function assertNotEq(uint256[] memory left, uint256[] memory right, string memory err) internal pure virtual {
|
|
602
|
+
vm.assertNotEq(left, right, err);
|
|
603
|
+
}
|
|
604
|
+
|
|
605
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
606
|
+
/// @param left The left-hand side value.
|
|
607
|
+
/// @param right The right-hand side value.
|
|
608
|
+
function assertNotEq(int256[] memory left, int256[] memory right) internal pure virtual {
|
|
609
|
+
vm.assertNotEq(left, right);
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
613
|
+
/// @param left The left-hand side value.
|
|
614
|
+
/// @param right The right-hand side value.
|
|
615
|
+
/// @param err The error message on failure.
|
|
616
|
+
function assertNotEq(int256[] memory left, int256[] memory right, string memory err) internal pure virtual {
|
|
617
|
+
vm.assertNotEq(left, right, err);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
621
|
+
/// @param left The left-hand side value.
|
|
622
|
+
/// @param right The right-hand side value.
|
|
623
|
+
function assertNotEq(address[] memory left, address[] memory right) internal pure virtual {
|
|
624
|
+
vm.assertNotEq(left, right);
|
|
625
|
+
}
|
|
626
|
+
|
|
627
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
628
|
+
/// @param left The left-hand side value.
|
|
629
|
+
/// @param right The right-hand side value.
|
|
630
|
+
/// @param err The error message on failure.
|
|
631
|
+
function assertNotEq(address[] memory left, address[] memory right, string memory err) internal pure virtual {
|
|
632
|
+
vm.assertNotEq(left, right, err);
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
636
|
+
/// @param left The left-hand side value.
|
|
637
|
+
/// @param right The right-hand side value.
|
|
638
|
+
function assertNotEq(bytes32[] memory left, bytes32[] memory right) internal pure virtual {
|
|
639
|
+
vm.assertNotEq(left, right);
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
643
|
+
/// @param left The left-hand side value.
|
|
644
|
+
/// @param right The right-hand side value.
|
|
645
|
+
/// @param err The error message on failure.
|
|
646
|
+
function assertNotEq(bytes32[] memory left, bytes32[] memory right, string memory err) internal pure virtual {
|
|
647
|
+
vm.assertNotEq(left, right, err);
|
|
648
|
+
}
|
|
649
|
+
|
|
650
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
651
|
+
/// @param left The left-hand side value.
|
|
652
|
+
/// @param right The right-hand side value.
|
|
653
|
+
function assertNotEq(string[] memory left, string[] memory right) internal pure virtual {
|
|
654
|
+
vm.assertNotEq(left, right);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
658
|
+
/// @param left The left-hand side value.
|
|
659
|
+
/// @param right The right-hand side value.
|
|
660
|
+
/// @param err The error message on failure.
|
|
661
|
+
function assertNotEq(string[] memory left, string[] memory right, string memory err) internal pure virtual {
|
|
662
|
+
vm.assertNotEq(left, right, err);
|
|
663
|
+
}
|
|
664
|
+
|
|
665
|
+
/// @notice Asserts that `left` is not equal to `right`.
|
|
666
|
+
/// @param left The left-hand side value.
|
|
667
|
+
/// @param right The right-hand side value.
|
|
668
|
+
function assertNotEq(bytes[] memory left, bytes[] memory right) internal pure virtual {
|
|
669
|
+
vm.assertNotEq(left, right);
|
|
670
|
+
}
|
|
671
|
+
|
|
672
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message.
|
|
673
|
+
/// @param left The left-hand side value.
|
|
674
|
+
/// @param right The right-hand side value.
|
|
675
|
+
/// @param err The error message on failure.
|
|
676
|
+
function assertNotEq(bytes[] memory left, bytes[] memory right, string memory err) internal pure virtual {
|
|
677
|
+
vm.assertNotEq(left, right, err);
|
|
678
|
+
}
|
|
679
|
+
|
|
680
|
+
/// @notice Asserts that `left` is strictly less than `right`.
|
|
681
|
+
/// @param left The left-hand side value.
|
|
682
|
+
/// @param right The right-hand side value.
|
|
683
|
+
function assertLt(uint256 left, uint256 right) internal pure virtual {
|
|
684
|
+
if (left >= right) {
|
|
685
|
+
vm.assertLt(left, right);
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
|
|
689
|
+
/// @notice Asserts that `left` is strictly less than `right` with a custom error message.
|
|
690
|
+
/// @param left The left-hand side value.
|
|
691
|
+
/// @param right The right-hand side value.
|
|
692
|
+
/// @param err The error message on failure.
|
|
693
|
+
function assertLt(uint256 left, uint256 right, string memory err) internal pure virtual {
|
|
694
|
+
if (left >= right) {
|
|
695
|
+
vm.assertLt(left, right, err);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
|
|
699
|
+
/// @notice Asserts that `left` is strictly less than `right`, formatting values with `decimals` decimal places on failure.
|
|
700
|
+
/// @param left The left-hand side value.
|
|
701
|
+
/// @param right The right-hand side value.
|
|
702
|
+
/// @param decimals The number of decimals for formatting.
|
|
703
|
+
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual {
|
|
704
|
+
vm.assertLtDecimal(left, right, decimals);
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
/// @notice Asserts that `left` is strictly less than `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
708
|
+
/// @param left The left-hand side value.
|
|
709
|
+
/// @param right The right-hand side value.
|
|
710
|
+
/// @param decimals The number of decimals for formatting.
|
|
711
|
+
/// @param err The error message on failure.
|
|
712
|
+
function assertLtDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual {
|
|
713
|
+
vm.assertLtDecimal(left, right, decimals, err);
|
|
714
|
+
}
|
|
715
|
+
|
|
716
|
+
/// @notice Asserts that `left` is strictly less than `right`.
|
|
717
|
+
/// @param left The left-hand side value.
|
|
718
|
+
/// @param right The right-hand side value.
|
|
719
|
+
function assertLt(int256 left, int256 right) internal pure virtual {
|
|
720
|
+
if (left >= right) {
|
|
721
|
+
vm.assertLt(left, right);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
/// @notice Asserts that `left` is strictly less than `right` with a custom error message.
|
|
726
|
+
/// @param left The left-hand side value.
|
|
727
|
+
/// @param right The right-hand side value.
|
|
728
|
+
/// @param err The error message on failure.
|
|
729
|
+
function assertLt(int256 left, int256 right, string memory err) internal pure virtual {
|
|
730
|
+
if (left >= right) {
|
|
731
|
+
vm.assertLt(left, right, err);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
|
|
735
|
+
/// @notice Asserts that `left` is strictly less than `right`, formatting values with `decimals` decimal places on failure.
|
|
736
|
+
/// @param left The left-hand side value.
|
|
737
|
+
/// @param right The right-hand side value.
|
|
738
|
+
/// @param decimals The number of decimals for formatting.
|
|
739
|
+
function assertLtDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual {
|
|
740
|
+
vm.assertLtDecimal(left, right, decimals);
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
/// @notice Asserts that `left` is strictly less than `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
744
|
+
/// @param left The left-hand side value.
|
|
745
|
+
/// @param right The right-hand side value.
|
|
746
|
+
/// @param decimals The number of decimals for formatting.
|
|
747
|
+
/// @param err The error message on failure.
|
|
748
|
+
function assertLtDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual {
|
|
749
|
+
vm.assertLtDecimal(left, right, decimals, err);
|
|
750
|
+
}
|
|
751
|
+
|
|
752
|
+
/// @notice Asserts that `left` is strictly greater than `right`.
|
|
753
|
+
/// @param left The left-hand side value.
|
|
754
|
+
/// @param right The right-hand side value.
|
|
755
|
+
function assertGt(uint256 left, uint256 right) internal pure virtual {
|
|
756
|
+
if (left <= right) {
|
|
757
|
+
vm.assertGt(left, right);
|
|
758
|
+
}
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/// @notice Asserts that `left` is strictly greater than `right` with a custom error message.
|
|
762
|
+
/// @param left The left-hand side value.
|
|
763
|
+
/// @param right The right-hand side value.
|
|
764
|
+
/// @param err The error message on failure.
|
|
765
|
+
function assertGt(uint256 left, uint256 right, string memory err) internal pure virtual {
|
|
766
|
+
if (left <= right) {
|
|
767
|
+
vm.assertGt(left, right, err);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
|
|
771
|
+
/// @notice Asserts that `left` is strictly greater than `right`, formatting values with `decimals` decimal places on failure.
|
|
772
|
+
/// @param left The left-hand side value.
|
|
773
|
+
/// @param right The right-hand side value.
|
|
774
|
+
/// @param decimals The number of decimals for formatting.
|
|
775
|
+
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual {
|
|
776
|
+
vm.assertGtDecimal(left, right, decimals);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/// @notice Asserts that `left` is strictly greater than `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
780
|
+
/// @param left The left-hand side value.
|
|
781
|
+
/// @param right The right-hand side value.
|
|
782
|
+
/// @param decimals The number of decimals for formatting.
|
|
783
|
+
/// @param err The error message on failure.
|
|
784
|
+
function assertGtDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual {
|
|
785
|
+
vm.assertGtDecimal(left, right, decimals, err);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
|
+
/// @notice Asserts that `left` is strictly greater than `right`.
|
|
789
|
+
/// @param left The left-hand side value.
|
|
790
|
+
/// @param right The right-hand side value.
|
|
791
|
+
function assertGt(int256 left, int256 right) internal pure virtual {
|
|
792
|
+
if (left <= right) {
|
|
793
|
+
vm.assertGt(left, right);
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
|
|
797
|
+
/// @notice Asserts that `left` is strictly greater than `right` with a custom error message.
|
|
798
|
+
/// @param left The left-hand side value.
|
|
799
|
+
/// @param right The right-hand side value.
|
|
800
|
+
/// @param err The error message on failure.
|
|
801
|
+
function assertGt(int256 left, int256 right, string memory err) internal pure virtual {
|
|
802
|
+
if (left <= right) {
|
|
803
|
+
vm.assertGt(left, right, err);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
|
|
807
|
+
/// @notice Asserts that `left` is strictly greater than `right`, formatting values with `decimals` decimal places on failure.
|
|
808
|
+
/// @param left The left-hand side value.
|
|
809
|
+
/// @param right The right-hand side value.
|
|
810
|
+
/// @param decimals The number of decimals for formatting.
|
|
811
|
+
function assertGtDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual {
|
|
812
|
+
vm.assertGtDecimal(left, right, decimals);
|
|
813
|
+
}
|
|
814
|
+
|
|
815
|
+
/// @notice Asserts that `left` is strictly greater than `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
816
|
+
/// @param left The left-hand side value.
|
|
817
|
+
/// @param right The right-hand side value.
|
|
818
|
+
/// @param decimals The number of decimals for formatting.
|
|
819
|
+
/// @param err The error message on failure.
|
|
820
|
+
function assertGtDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual {
|
|
821
|
+
vm.assertGtDecimal(left, right, decimals, err);
|
|
822
|
+
}
|
|
823
|
+
|
|
824
|
+
/// @notice Asserts that `left` is less than or equal to `right`.
|
|
825
|
+
/// @param left The left-hand side value.
|
|
826
|
+
/// @param right The right-hand side value.
|
|
827
|
+
function assertLe(uint256 left, uint256 right) internal pure virtual {
|
|
828
|
+
if (left > right) {
|
|
829
|
+
vm.assertLe(left, right);
|
|
830
|
+
}
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/// @notice Asserts that `left` is less than or equal to `right` with a custom error message.
|
|
834
|
+
/// @param left The left-hand side value.
|
|
835
|
+
/// @param right The right-hand side value.
|
|
836
|
+
/// @param err The error message on failure.
|
|
837
|
+
function assertLe(uint256 left, uint256 right, string memory err) internal pure virtual {
|
|
838
|
+
if (left > right) {
|
|
839
|
+
vm.assertLe(left, right, err);
|
|
840
|
+
}
|
|
841
|
+
}
|
|
842
|
+
|
|
843
|
+
/// @notice Asserts that `left` is less than or equal to `right`, formatting values with `decimals` decimal places on failure.
|
|
844
|
+
/// @param left The left-hand side value.
|
|
845
|
+
/// @param right The right-hand side value.
|
|
846
|
+
/// @param decimals The number of decimals for formatting.
|
|
847
|
+
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual {
|
|
848
|
+
vm.assertLeDecimal(left, right, decimals);
|
|
849
|
+
}
|
|
850
|
+
|
|
851
|
+
/// @notice Asserts that `left` is less than or equal to `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
852
|
+
/// @param left The left-hand side value.
|
|
853
|
+
/// @param right The right-hand side value.
|
|
854
|
+
/// @param decimals The number of decimals for formatting.
|
|
855
|
+
/// @param err The error message on failure.
|
|
856
|
+
function assertLeDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual {
|
|
857
|
+
vm.assertLeDecimal(left, right, decimals, err);
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/// @notice Asserts that `left` is less than or equal to `right`.
|
|
861
|
+
/// @param left The left-hand side value.
|
|
862
|
+
/// @param right The right-hand side value.
|
|
863
|
+
function assertLe(int256 left, int256 right) internal pure virtual {
|
|
864
|
+
if (left > right) {
|
|
865
|
+
vm.assertLe(left, right);
|
|
866
|
+
}
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/// @notice Asserts that `left` is less than or equal to `right` with a custom error message.
|
|
870
|
+
/// @param left The left-hand side value.
|
|
871
|
+
/// @param right The right-hand side value.
|
|
872
|
+
/// @param err The error message on failure.
|
|
873
|
+
function assertLe(int256 left, int256 right, string memory err) internal pure virtual {
|
|
874
|
+
if (left > right) {
|
|
875
|
+
vm.assertLe(left, right, err);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
/// @notice Asserts that `left` is less than or equal to `right`, formatting values with `decimals` decimal places on failure.
|
|
880
|
+
/// @param left The left-hand side value.
|
|
881
|
+
/// @param right The right-hand side value.
|
|
882
|
+
/// @param decimals The number of decimals for formatting.
|
|
883
|
+
function assertLeDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual {
|
|
884
|
+
vm.assertLeDecimal(left, right, decimals);
|
|
885
|
+
}
|
|
886
|
+
|
|
887
|
+
/// @notice Asserts that `left` is less than or equal to `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
888
|
+
/// @param left The left-hand side value.
|
|
889
|
+
/// @param right The right-hand side value.
|
|
890
|
+
/// @param decimals The number of decimals for formatting.
|
|
891
|
+
/// @param err The error message on failure.
|
|
892
|
+
function assertLeDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual {
|
|
893
|
+
vm.assertLeDecimal(left, right, decimals, err);
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
/// @notice Asserts that `left` is greater than or equal to `right`.
|
|
897
|
+
/// @param left The left-hand side value.
|
|
898
|
+
/// @param right The right-hand side value.
|
|
899
|
+
function assertGe(uint256 left, uint256 right) internal pure virtual {
|
|
900
|
+
if (left < right) {
|
|
901
|
+
vm.assertGe(left, right);
|
|
902
|
+
}
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
/// @notice Asserts that `left` is greater than or equal to `right` with a custom error message.
|
|
906
|
+
/// @param left The left-hand side value.
|
|
907
|
+
/// @param right The right-hand side value.
|
|
908
|
+
/// @param err The error message on failure.
|
|
909
|
+
function assertGe(uint256 left, uint256 right, string memory err) internal pure virtual {
|
|
910
|
+
if (left < right) {
|
|
911
|
+
vm.assertGe(left, right, err);
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
|
|
915
|
+
/// @notice Asserts that `left` is greater than or equal to `right`, formatting values with `decimals` decimal places on failure.
|
|
916
|
+
/// @param left The left-hand side value.
|
|
917
|
+
/// @param right The right-hand side value.
|
|
918
|
+
/// @param decimals The number of decimals for formatting.
|
|
919
|
+
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals) internal pure virtual {
|
|
920
|
+
vm.assertGeDecimal(left, right, decimals);
|
|
921
|
+
}
|
|
922
|
+
|
|
923
|
+
/// @notice Asserts that `left` is greater than or equal to `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
924
|
+
/// @param left The left-hand side value.
|
|
925
|
+
/// @param right The right-hand side value.
|
|
926
|
+
/// @param decimals The number of decimals for formatting.
|
|
927
|
+
/// @param err The error message on failure.
|
|
928
|
+
function assertGeDecimal(uint256 left, uint256 right, uint256 decimals, string memory err) internal pure virtual {
|
|
929
|
+
vm.assertGeDecimal(left, right, decimals, err);
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
/// @notice Asserts that `left` is greater than or equal to `right`.
|
|
933
|
+
/// @param left The left-hand side value.
|
|
934
|
+
/// @param right The right-hand side value.
|
|
935
|
+
function assertGe(int256 left, int256 right) internal pure virtual {
|
|
936
|
+
if (left < right) {
|
|
937
|
+
vm.assertGe(left, right);
|
|
938
|
+
}
|
|
939
|
+
}
|
|
940
|
+
|
|
941
|
+
/// @notice Asserts that `left` is greater than or equal to `right` with a custom error message.
|
|
942
|
+
/// @param left The left-hand side value.
|
|
943
|
+
/// @param right The right-hand side value.
|
|
944
|
+
/// @param err The error message on failure.
|
|
945
|
+
function assertGe(int256 left, int256 right, string memory err) internal pure virtual {
|
|
946
|
+
if (left < right) {
|
|
947
|
+
vm.assertGe(left, right, err);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
|
|
951
|
+
/// @notice Asserts that `left` is greater than or equal to `right`, formatting values with `decimals` decimal places on failure.
|
|
952
|
+
/// @param left The left-hand side value.
|
|
953
|
+
/// @param right The right-hand side value.
|
|
954
|
+
/// @param decimals The number of decimals for formatting.
|
|
955
|
+
function assertGeDecimal(int256 left, int256 right, uint256 decimals) internal pure virtual {
|
|
956
|
+
vm.assertGeDecimal(left, right, decimals);
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
/// @notice Asserts that `left` is greater than or equal to `right`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
960
|
+
/// @param left The left-hand side value.
|
|
961
|
+
/// @param right The right-hand side value.
|
|
962
|
+
/// @param decimals The number of decimals for formatting.
|
|
963
|
+
/// @param err The error message on failure.
|
|
964
|
+
function assertGeDecimal(int256 left, int256 right, uint256 decimals, string memory err) internal pure virtual {
|
|
965
|
+
vm.assertGeDecimal(left, right, decimals, err);
|
|
966
|
+
}
|
|
967
|
+
|
|
968
|
+
/// @notice Asserts that the absolute difference between `left` and `right` is at most `maxDelta`.
|
|
969
|
+
/// @param left The left-hand side value.
|
|
970
|
+
/// @param right The right-hand side value.
|
|
971
|
+
/// @param maxDelta The maximum absolute difference allowed.
|
|
972
|
+
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta) internal pure virtual {
|
|
973
|
+
vm.assertApproxEqAbs(left, right, maxDelta);
|
|
974
|
+
}
|
|
975
|
+
|
|
976
|
+
/// @notice Asserts that the absolute difference between `left` and `right` is at most `maxDelta` with a custom error message.
|
|
977
|
+
/// @param left The left-hand side value.
|
|
978
|
+
/// @param right The right-hand side value.
|
|
979
|
+
/// @param maxDelta The maximum absolute difference allowed.
|
|
980
|
+
/// @param err The error message on failure.
|
|
981
|
+
function assertApproxEqAbs(uint256 left, uint256 right, uint256 maxDelta, string memory err) internal pure virtual {
|
|
982
|
+
vm.assertApproxEqAbs(left, right, maxDelta, err);
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
/// @notice Asserts that the absolute difference between `left` and `right` is at most `maxDelta`, formatting values with `decimals` decimal places on failure.
|
|
986
|
+
/// @param left The left-hand side value.
|
|
987
|
+
/// @param right The right-hand side value.
|
|
988
|
+
/// @param maxDelta The maximum absolute difference allowed.
|
|
989
|
+
/// @param decimals The number of decimals for formatting.
|
|
990
|
+
function assertApproxEqAbsDecimal(uint256 left, uint256 right, uint256 maxDelta, uint256 decimals)
|
|
991
|
+
internal
|
|
992
|
+
pure
|
|
993
|
+
virtual
|
|
994
|
+
{
|
|
995
|
+
vm.assertApproxEqAbsDecimal(left, right, maxDelta, decimals);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
/// @notice Asserts that the absolute difference between `left` and `right` is at most `maxDelta`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
999
|
+
/// @param left The left-hand side value.
|
|
1000
|
+
/// @param right The right-hand side value.
|
|
1001
|
+
/// @param maxDelta The maximum absolute difference allowed.
|
|
1002
|
+
/// @param decimals The number of decimals for formatting.
|
|
1003
|
+
/// @param err The error message on failure.
|
|
1004
|
+
function assertApproxEqAbsDecimal(
|
|
1005
|
+
uint256 left,
|
|
1006
|
+
uint256 right,
|
|
1007
|
+
uint256 maxDelta,
|
|
1008
|
+
uint256 decimals,
|
|
1009
|
+
string memory err
|
|
1010
|
+
) internal pure virtual {
|
|
1011
|
+
vm.assertApproxEqAbsDecimal(left, right, maxDelta, decimals, err);
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
/// @notice Asserts that the absolute difference between `left` and `right` is at most `maxDelta`.
|
|
1015
|
+
/// @param left The left-hand side value.
|
|
1016
|
+
/// @param right The right-hand side value.
|
|
1017
|
+
/// @param maxDelta The maximum absolute difference allowed.
|
|
1018
|
+
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta) internal pure virtual {
|
|
1019
|
+
vm.assertApproxEqAbs(left, right, maxDelta);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
/// @notice Asserts that the absolute difference between `left` and `right` is at most `maxDelta` with a custom error message.
|
|
1023
|
+
/// @param left The left-hand side value.
|
|
1024
|
+
/// @param right The right-hand side value.
|
|
1025
|
+
/// @param maxDelta The maximum absolute difference allowed.
|
|
1026
|
+
/// @param err The error message on failure.
|
|
1027
|
+
function assertApproxEqAbs(int256 left, int256 right, uint256 maxDelta, string memory err) internal pure virtual {
|
|
1028
|
+
vm.assertApproxEqAbs(left, right, maxDelta, err);
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
/// @notice Asserts that the absolute difference between `left` and `right` is at most `maxDelta`, formatting values with `decimals` decimal places on failure.
|
|
1032
|
+
/// @param left The left-hand side value.
|
|
1033
|
+
/// @param right The right-hand side value.
|
|
1034
|
+
/// @param maxDelta The maximum absolute difference allowed.
|
|
1035
|
+
/// @param decimals The number of decimals for formatting.
|
|
1036
|
+
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals)
|
|
1037
|
+
internal
|
|
1038
|
+
pure
|
|
1039
|
+
virtual
|
|
1040
|
+
{
|
|
1041
|
+
vm.assertApproxEqAbsDecimal(left, right, maxDelta, decimals);
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
/// @notice Asserts that the absolute difference between `left` and `right` is at most `maxDelta`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
1045
|
+
/// @param left The left-hand side value.
|
|
1046
|
+
/// @param right The right-hand side value.
|
|
1047
|
+
/// @param maxDelta The maximum absolute difference allowed.
|
|
1048
|
+
/// @param decimals The number of decimals for formatting.
|
|
1049
|
+
/// @param err The error message on failure.
|
|
1050
|
+
function assertApproxEqAbsDecimal(int256 left, int256 right, uint256 maxDelta, uint256 decimals, string memory err)
|
|
1051
|
+
internal
|
|
1052
|
+
pure
|
|
1053
|
+
virtual
|
|
1054
|
+
{
|
|
1055
|
+
vm.assertApproxEqAbsDecimal(left, right, maxDelta, decimals, err);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
/// @notice Asserts that the relative difference between `left` and `right` is at most `maxPercentDelta`.
|
|
1059
|
+
/// @param left The left-hand side value.
|
|
1060
|
+
/// @param right The right-hand side value.
|
|
1061
|
+
/// @param maxPercentDelta The maximum relative delta allowed, as an 18 decimal fixed point number where 1e18 == 100%.
|
|
1062
|
+
function assertApproxEqRel(
|
|
1063
|
+
uint256 left,
|
|
1064
|
+
uint256 right,
|
|
1065
|
+
uint256 maxPercentDelta // An 18 decimal fixed point number, where 1e18 == 100%
|
|
1066
|
+
)
|
|
1067
|
+
internal
|
|
1068
|
+
pure
|
|
1069
|
+
virtual
|
|
1070
|
+
{
|
|
1071
|
+
vm.assertApproxEqRel(left, right, maxPercentDelta);
|
|
1072
|
+
}
|
|
1073
|
+
|
|
1074
|
+
/// @notice Asserts that the relative difference between `left` and `right` is at most `maxPercentDelta` with a custom error message.
|
|
1075
|
+
/// @param left The left-hand side value.
|
|
1076
|
+
/// @param right The right-hand side value.
|
|
1077
|
+
/// @param maxPercentDelta The maximum relative delta allowed, as an 18 decimal fixed point number where 1e18 == 100%.
|
|
1078
|
+
/// @param err The error message on failure.
|
|
1079
|
+
function assertApproxEqRel(
|
|
1080
|
+
uint256 left,
|
|
1081
|
+
uint256 right,
|
|
1082
|
+
uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%
|
|
1083
|
+
string memory err
|
|
1084
|
+
)
|
|
1085
|
+
internal
|
|
1086
|
+
pure
|
|
1087
|
+
virtual
|
|
1088
|
+
{
|
|
1089
|
+
vm.assertApproxEqRel(left, right, maxPercentDelta, err);
|
|
1090
|
+
}
|
|
1091
|
+
|
|
1092
|
+
/// @notice Asserts that the relative difference between `left` and `right` is at most `maxPercentDelta`, formatting values with `decimals` decimal places on failure.
|
|
1093
|
+
/// @param left The left-hand side value.
|
|
1094
|
+
/// @param right The right-hand side value.
|
|
1095
|
+
/// @param maxPercentDelta The maximum relative delta allowed, as an 18 decimal fixed point number where 1e18 == 100%.
|
|
1096
|
+
/// @param decimals The number of decimals for formatting.
|
|
1097
|
+
function assertApproxEqRelDecimal(
|
|
1098
|
+
uint256 left,
|
|
1099
|
+
uint256 right,
|
|
1100
|
+
uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%
|
|
1101
|
+
uint256 decimals
|
|
1102
|
+
)
|
|
1103
|
+
internal
|
|
1104
|
+
pure
|
|
1105
|
+
virtual
|
|
1106
|
+
{
|
|
1107
|
+
vm.assertApproxEqRelDecimal(left, right, maxPercentDelta, decimals);
|
|
1108
|
+
}
|
|
1109
|
+
|
|
1110
|
+
/// @notice Asserts that the relative difference between `left` and `right` is at most `maxPercentDelta`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
1111
|
+
/// @param left The left-hand side value.
|
|
1112
|
+
/// @param right The right-hand side value.
|
|
1113
|
+
/// @param maxPercentDelta The maximum relative delta allowed, as an 18 decimal fixed point number where 1e18 == 100%.
|
|
1114
|
+
/// @param decimals The number of decimals for formatting.
|
|
1115
|
+
/// @param err The error message on failure.
|
|
1116
|
+
function assertApproxEqRelDecimal(
|
|
1117
|
+
uint256 left,
|
|
1118
|
+
uint256 right,
|
|
1119
|
+
uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%
|
|
1120
|
+
uint256 decimals,
|
|
1121
|
+
string memory err
|
|
1122
|
+
) internal pure virtual {
|
|
1123
|
+
vm.assertApproxEqRelDecimal(left, right, maxPercentDelta, decimals, err);
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1126
|
+
/// @notice Asserts that the relative difference between `left` and `right` is at most `maxPercentDelta`.
|
|
1127
|
+
/// @param left The left-hand side value.
|
|
1128
|
+
/// @param right The right-hand side value.
|
|
1129
|
+
/// @param maxPercentDelta The maximum relative delta allowed, as an 18 decimal fixed point number where 1e18 == 100%.
|
|
1130
|
+
function assertApproxEqRel(int256 left, int256 right, uint256 maxPercentDelta) internal pure virtual {
|
|
1131
|
+
vm.assertApproxEqRel(left, right, maxPercentDelta);
|
|
1132
|
+
}
|
|
1133
|
+
|
|
1134
|
+
/// @notice Asserts that the relative difference between `left` and `right` is at most `maxPercentDelta` with a custom error message.
|
|
1135
|
+
/// @param left The left-hand side value.
|
|
1136
|
+
/// @param right The right-hand side value.
|
|
1137
|
+
/// @param maxPercentDelta The maximum relative delta allowed, as an 18 decimal fixed point number where 1e18 == 100%.
|
|
1138
|
+
/// @param err The error message on failure.
|
|
1139
|
+
function assertApproxEqRel(
|
|
1140
|
+
int256 left,
|
|
1141
|
+
int256 right,
|
|
1142
|
+
uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%
|
|
1143
|
+
string memory err
|
|
1144
|
+
)
|
|
1145
|
+
internal
|
|
1146
|
+
pure
|
|
1147
|
+
virtual
|
|
1148
|
+
{
|
|
1149
|
+
vm.assertApproxEqRel(left, right, maxPercentDelta, err);
|
|
1150
|
+
}
|
|
1151
|
+
|
|
1152
|
+
/// @notice Asserts that the relative difference between `left` and `right` is at most `maxPercentDelta`, formatting values with `decimals` decimal places on failure.
|
|
1153
|
+
/// @param left The left-hand side value.
|
|
1154
|
+
/// @param right The right-hand side value.
|
|
1155
|
+
/// @param maxPercentDelta The maximum relative delta allowed, as an 18 decimal fixed point number where 1e18 == 100%.
|
|
1156
|
+
/// @param decimals The number of decimals for formatting.
|
|
1157
|
+
function assertApproxEqRelDecimal(
|
|
1158
|
+
int256 left,
|
|
1159
|
+
int256 right,
|
|
1160
|
+
uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%
|
|
1161
|
+
uint256 decimals
|
|
1162
|
+
)
|
|
1163
|
+
internal
|
|
1164
|
+
pure
|
|
1165
|
+
virtual
|
|
1166
|
+
{
|
|
1167
|
+
vm.assertApproxEqRelDecimal(left, right, maxPercentDelta, decimals);
|
|
1168
|
+
}
|
|
1169
|
+
|
|
1170
|
+
/// @notice Asserts that the relative difference between `left` and `right` is at most `maxPercentDelta`, formatting values with `decimals` decimal places on failure, with a custom error message.
|
|
1171
|
+
/// @param left The left-hand side value.
|
|
1172
|
+
/// @param right The right-hand side value.
|
|
1173
|
+
/// @param maxPercentDelta The maximum relative delta allowed, as an 18 decimal fixed point number where 1e18 == 100%.
|
|
1174
|
+
/// @param decimals The number of decimals for formatting.
|
|
1175
|
+
/// @param err The error message on failure.
|
|
1176
|
+
function assertApproxEqRelDecimal(
|
|
1177
|
+
int256 left,
|
|
1178
|
+
int256 right,
|
|
1179
|
+
uint256 maxPercentDelta, // An 18 decimal fixed point number, where 1e18 == 100%
|
|
1180
|
+
uint256 decimals,
|
|
1181
|
+
string memory err
|
|
1182
|
+
) internal pure virtual {
|
|
1183
|
+
vm.assertApproxEqRelDecimal(left, right, maxPercentDelta, decimals, err);
|
|
1184
|
+
}
|
|
1185
|
+
|
|
1186
|
+
// Inherited from DSTest, not used but kept for backwards-compatibility
|
|
1187
|
+
/// @notice Returns true if `left` and `right` have equal content.
|
|
1188
|
+
/// @dev Inherited from DSTest, kept for backwards-compatibility.
|
|
1189
|
+
/// @param left The left-hand side bytes.
|
|
1190
|
+
/// @param right The right-hand side bytes.
|
|
1191
|
+
/// @return True if the byte content is equal, false otherwise.
|
|
1192
|
+
function checkEq0(bytes memory left, bytes memory right) internal pure returns (bool) {
|
|
1193
|
+
return keccak256(left) == keccak256(right);
|
|
1194
|
+
}
|
|
1195
|
+
|
|
1196
|
+
/// @notice Asserts that `left` is equal to `right` (legacy bytes variant).
|
|
1197
|
+
/// @dev Alias for assertEq(bytes,bytes) kept for backwards-compatibility.
|
|
1198
|
+
/// @param left The left-hand side bytes.
|
|
1199
|
+
/// @param right The right-hand side bytes.
|
|
1200
|
+
function assertEq0(bytes memory left, bytes memory right) internal pure virtual {
|
|
1201
|
+
assertEq(left, right);
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/// @notice Asserts that `left` is equal to `right` with a custom error message (legacy bytes variant).
|
|
1205
|
+
/// @dev Alias for assertEq(bytes,bytes,string) kept for backwards-compatibility.
|
|
1206
|
+
/// @param left The left-hand side bytes.
|
|
1207
|
+
/// @param right The right-hand side bytes.
|
|
1208
|
+
/// @param err The error message on failure.
|
|
1209
|
+
function assertEq0(bytes memory left, bytes memory right, string memory err) internal pure virtual {
|
|
1210
|
+
assertEq(left, right, err);
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
/// @notice Asserts that `left` is not equal to `right` (legacy bytes variant).
|
|
1214
|
+
/// @dev Alias for assertNotEq(bytes,bytes) kept for backwards-compatibility.
|
|
1215
|
+
/// @param left The left-hand side bytes.
|
|
1216
|
+
/// @param right The right-hand side bytes.
|
|
1217
|
+
function assertNotEq0(bytes memory left, bytes memory right) internal pure virtual {
|
|
1218
|
+
assertNotEq(left, right);
|
|
1219
|
+
}
|
|
1220
|
+
|
|
1221
|
+
/// @notice Asserts that `left` is not equal to `right` with a custom error message (legacy bytes variant).
|
|
1222
|
+
/// @dev Alias for assertNotEq(bytes,bytes,string) kept for backwards-compatibility.
|
|
1223
|
+
/// @param left The left-hand side bytes.
|
|
1224
|
+
/// @param right The right-hand side bytes.
|
|
1225
|
+
/// @param err The error message on failure.
|
|
1226
|
+
function assertNotEq0(bytes memory left, bytes memory right, string memory err) internal pure virtual {
|
|
1227
|
+
assertNotEq(left, right, err);
|
|
1228
|
+
}
|
|
1229
|
+
|
|
1230
|
+
/// @notice Asserts that two calls to the same target with different calldata produce equal return or revert data.
|
|
1231
|
+
/// @param target The contract address to call.
|
|
1232
|
+
/// @param callDataA The calldata for the first call.
|
|
1233
|
+
/// @param callDataB The calldata for the second call.
|
|
1234
|
+
function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB) internal virtual {
|
|
1235
|
+
assertEqCall(target, callDataA, target, callDataB, true);
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
/// @notice Asserts that calls to two different targets produce equal return or revert data.
|
|
1239
|
+
/// @param targetA The first contract address.
|
|
1240
|
+
/// @param callDataA The calldata for the first call.
|
|
1241
|
+
/// @param targetB The second contract address.
|
|
1242
|
+
/// @param callDataB The calldata for the second call.
|
|
1243
|
+
function assertEqCall(address targetA, bytes memory callDataA, address targetB, bytes memory callDataB)
|
|
1244
|
+
internal
|
|
1245
|
+
virtual
|
|
1246
|
+
{
|
|
1247
|
+
assertEqCall(targetA, callDataA, targetB, callDataB, true);
|
|
1248
|
+
}
|
|
1249
|
+
|
|
1250
|
+
/// @notice Asserts that two calls to the same target with different calldata produce equal return or revert data.
|
|
1251
|
+
/// @param target The contract address to call.
|
|
1252
|
+
/// @param callDataA The calldata for the first call.
|
|
1253
|
+
/// @param callDataB The calldata for the second call.
|
|
1254
|
+
/// @param strictRevertData If true, also asserts that revert data matches when both calls revert.
|
|
1255
|
+
function assertEqCall(address target, bytes memory callDataA, bytes memory callDataB, bool strictRevertData)
|
|
1256
|
+
internal
|
|
1257
|
+
virtual
|
|
1258
|
+
{
|
|
1259
|
+
assertEqCall(target, callDataA, target, callDataB, strictRevertData);
|
|
1260
|
+
}
|
|
1261
|
+
|
|
1262
|
+
/// @notice Asserts that calls to two targets produce equal return or revert data.
|
|
1263
|
+
/// @param targetA The first contract address.
|
|
1264
|
+
/// @param callDataA The calldata for the first call.
|
|
1265
|
+
/// @param targetB The second contract address.
|
|
1266
|
+
/// @param callDataB The calldata for the second call.
|
|
1267
|
+
/// @param strictRevertData If true, also asserts that revert data matches when both calls revert.
|
|
1268
|
+
function assertEqCall(
|
|
1269
|
+
address targetA,
|
|
1270
|
+
bytes memory callDataA,
|
|
1271
|
+
address targetB,
|
|
1272
|
+
bytes memory callDataB,
|
|
1273
|
+
bool strictRevertData
|
|
1274
|
+
) internal virtual {
|
|
1275
|
+
(bool successA, bytes memory returnDataA) = address(targetA).call(callDataA);
|
|
1276
|
+
(bool successB, bytes memory returnDataB) = address(targetB).call(callDataB);
|
|
1277
|
+
|
|
1278
|
+
if (successA && successB) {
|
|
1279
|
+
assertEq(returnDataA, returnDataB, "Call return data does not match");
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
if (!successA && !successB && strictRevertData) {
|
|
1283
|
+
assertEq(returnDataA, returnDataB, "Call revert data does not match");
|
|
1284
|
+
}
|
|
1285
|
+
|
|
1286
|
+
if (!successA && successB) {
|
|
1287
|
+
emit log("Error: Calls were not equal");
|
|
1288
|
+
emit log_named_bytes(" Left call revert data", returnDataA);
|
|
1289
|
+
emit log_named_bytes(" Right call return data", returnDataB);
|
|
1290
|
+
revert("assertion failed");
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
if (successA && !successB) {
|
|
1294
|
+
emit log("Error: Calls were not equal");
|
|
1295
|
+
emit log_named_bytes(" Left call return data", returnDataA);
|
|
1296
|
+
emit log_named_bytes(" Right call revert data", returnDataB);
|
|
1297
|
+
revert("assertion failed");
|
|
1298
|
+
}
|
|
1299
|
+
}
|
|
1300
|
+
}
|