@godzillaba/mutest 1.0.1 → 1.1.0

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.
Files changed (81) hide show
  1. package/README.md +1 -1
  2. package/index.ts +23 -6
  3. package/package.json +4 -1
  4. package/.devcontainer/Dockerfile +0 -117
  5. package/.devcontainer/devcontainer.json +0 -62
  6. package/.devcontainer/init-firewall.sh +0 -118
  7. package/.github/workflows/test.yml +0 -38
  8. package/.gitmodules +0 -3
  9. package/CLAUDE.md +0 -39
  10. package/foundry.lock +0 -8
  11. package/foundry.toml +0 -6
  12. package/lib/forge-std/.gitattributes +0 -1
  13. package/lib/forge-std/.github/CODEOWNERS +0 -1
  14. package/lib/forge-std/.github/dependabot.yml +0 -6
  15. package/lib/forge-std/.github/workflows/ci.yml +0 -125
  16. package/lib/forge-std/.github/workflows/sync.yml +0 -36
  17. package/lib/forge-std/CONTRIBUTING.md +0 -193
  18. package/lib/forge-std/LICENSE-APACHE +0 -203
  19. package/lib/forge-std/LICENSE-MIT +0 -25
  20. package/lib/forge-std/README.md +0 -314
  21. package/lib/forge-std/RELEASE_CHECKLIST.md +0 -12
  22. package/lib/forge-std/foundry.toml +0 -18
  23. package/lib/forge-std/package.json +0 -16
  24. package/lib/forge-std/scripts/vm.py +0 -636
  25. package/lib/forge-std/src/Base.sol +0 -48
  26. package/lib/forge-std/src/Config.sol +0 -60
  27. package/lib/forge-std/src/LibVariable.sol +0 -477
  28. package/lib/forge-std/src/Script.sol +0 -28
  29. package/lib/forge-std/src/StdAssertions.sol +0 -779
  30. package/lib/forge-std/src/StdChains.sol +0 -303
  31. package/lib/forge-std/src/StdCheats.sol +0 -825
  32. package/lib/forge-std/src/StdConfig.sol +0 -632
  33. package/lib/forge-std/src/StdConstants.sol +0 -30
  34. package/lib/forge-std/src/StdError.sol +0 -15
  35. package/lib/forge-std/src/StdInvariant.sol +0 -140
  36. package/lib/forge-std/src/StdJson.sol +0 -275
  37. package/lib/forge-std/src/StdMath.sol +0 -47
  38. package/lib/forge-std/src/StdStorage.sol +0 -475
  39. package/lib/forge-std/src/StdStyle.sol +0 -333
  40. package/lib/forge-std/src/StdToml.sol +0 -275
  41. package/lib/forge-std/src/StdUtils.sol +0 -200
  42. package/lib/forge-std/src/Test.sol +0 -32
  43. package/lib/forge-std/src/Vm.sol +0 -2533
  44. package/lib/forge-std/src/console.sol +0 -1551
  45. package/lib/forge-std/src/console2.sol +0 -4
  46. package/lib/forge-std/src/interfaces/IERC1155.sol +0 -105
  47. package/lib/forge-std/src/interfaces/IERC165.sol +0 -12
  48. package/lib/forge-std/src/interfaces/IERC20.sol +0 -43
  49. package/lib/forge-std/src/interfaces/IERC4626.sol +0 -190
  50. package/lib/forge-std/src/interfaces/IERC6909.sol +0 -72
  51. package/lib/forge-std/src/interfaces/IERC721.sol +0 -164
  52. package/lib/forge-std/src/interfaces/IERC7540.sol +0 -144
  53. package/lib/forge-std/src/interfaces/IERC7575.sol +0 -241
  54. package/lib/forge-std/src/interfaces/IMulticall3.sol +0 -68
  55. package/lib/forge-std/src/safeconsole.sol +0 -13248
  56. package/lib/forge-std/test/CommonBase.t.sol +0 -44
  57. package/lib/forge-std/test/Config.t.sol +0 -381
  58. package/lib/forge-std/test/LibVariable.t.sol +0 -452
  59. package/lib/forge-std/test/StdAssertions.t.sol +0 -141
  60. package/lib/forge-std/test/StdChains.t.sol +0 -227
  61. package/lib/forge-std/test/StdCheats.t.sol +0 -638
  62. package/lib/forge-std/test/StdConstants.t.sol +0 -38
  63. package/lib/forge-std/test/StdError.t.sol +0 -119
  64. package/lib/forge-std/test/StdJson.t.sol +0 -49
  65. package/lib/forge-std/test/StdMath.t.sol +0 -202
  66. package/lib/forge-std/test/StdStorage.t.sol +0 -485
  67. package/lib/forge-std/test/StdStyle.t.sol +0 -110
  68. package/lib/forge-std/test/StdToml.t.sol +0 -49
  69. package/lib/forge-std/test/StdUtils.t.sol +0 -342
  70. package/lib/forge-std/test/Vm.t.sol +0 -18
  71. package/lib/forge-std/test/compilation/CompilationScript.sol +0 -8
  72. package/lib/forge-std/test/compilation/CompilationScriptBase.sol +0 -8
  73. package/lib/forge-std/test/compilation/CompilationTest.sol +0 -8
  74. package/lib/forge-std/test/compilation/CompilationTestBase.sol +0 -8
  75. package/lib/forge-std/test/fixtures/broadcast.log.json +0 -187
  76. package/lib/forge-std/test/fixtures/config.toml +0 -81
  77. package/lib/forge-std/test/fixtures/test.json +0 -8
  78. package/lib/forge-std/test/fixtures/test.toml +0 -6
  79. package/script/Counter.s.sol +0 -19
  80. package/src/Counter.sol +0 -14
  81. package/test/Counter.t.sol +0 -24
@@ -1,119 +0,0 @@
1
- // SPDX-License-Identifier: MIT OR Apache-2.0
2
- pragma solidity >=0.8.13 <0.9.0;
3
-
4
- import {stdError} from "../src/StdError.sol";
5
- import {Test} from "../src/Test.sol";
6
-
7
- contract StdErrorsTest is Test {
8
- ErrorsTest test;
9
-
10
- function setUp() public {
11
- test = new ErrorsTest();
12
- }
13
-
14
- function test_RevertIf_AssertionError() public {
15
- vm.expectRevert(stdError.assertionError);
16
- test.assertionError();
17
- }
18
-
19
- function test_RevertIf_ArithmeticError() public {
20
- vm.expectRevert(stdError.arithmeticError);
21
- test.arithmeticError(10);
22
- }
23
-
24
- function test_RevertIf_DivisionError() public {
25
- vm.expectRevert(stdError.divisionError);
26
- test.divError(0);
27
- }
28
-
29
- function test_RevertIf_ModError() public {
30
- vm.expectRevert(stdError.divisionError);
31
- test.modError(0);
32
- }
33
-
34
- function test_RevertIf_EnumConversionError() public {
35
- vm.expectRevert(stdError.enumConversionError);
36
- test.enumConversion(1);
37
- }
38
-
39
- function test_RevertIf_EncodeStgError() public {
40
- vm.expectRevert(stdError.encodeStorageError);
41
- test.encodeStgError();
42
- }
43
-
44
- function test_RevertIf_PopError() public {
45
- vm.expectRevert(stdError.popError);
46
- test.pop();
47
- }
48
-
49
- function test_RevertIf_IndexOOBError() public {
50
- vm.expectRevert(stdError.indexOOBError);
51
- test.indexOOBError(1);
52
- }
53
-
54
- function test_RevertIf_MemOverflowError() public {
55
- vm.expectRevert(stdError.memOverflowError);
56
- test.mem();
57
- }
58
-
59
- function test_RevertIf_InternError() public {
60
- vm.expectRevert(stdError.zeroVarError);
61
- test.intern();
62
- }
63
- }
64
-
65
- contract ErrorsTest {
66
- enum T {
67
- T1
68
- }
69
-
70
- uint256[] public someArr;
71
- bytes someBytes;
72
-
73
- function assertionError() public pure {
74
- assert(false);
75
- }
76
-
77
- function arithmeticError(uint256 a) public pure {
78
- a -= 100;
79
- }
80
-
81
- function divError(uint256 a) public pure {
82
- 100 / a;
83
- }
84
-
85
- function modError(uint256 a) public pure {
86
- 100 % a;
87
- }
88
-
89
- function enumConversion(uint256 a) public pure {
90
- T(a);
91
- }
92
-
93
- function encodeStgError() public {
94
- assembly ("memory-safe") {
95
- sstore(someBytes.slot, 1)
96
- }
97
- keccak256(someBytes);
98
- }
99
-
100
- function pop() public {
101
- someArr.pop();
102
- }
103
-
104
- function indexOOBError(uint256 a) public pure {
105
- uint256[] memory t = new uint256[](0);
106
- t[a];
107
- }
108
-
109
- function mem() public pure {
110
- uint256 l = 2 ** 256 / 32;
111
- new uint256[](l);
112
- }
113
-
114
- function intern() public returns (uint256) {
115
- function(uint256) internal returns (uint256) x;
116
- x(2);
117
- return 7;
118
- }
119
- }
@@ -1,49 +0,0 @@
1
- // SPDX-License-Identifier: MIT OR Apache-2.0
2
- pragma solidity >=0.8.13 <0.9.0;
3
-
4
- import {Test, stdJson} from "../src/Test.sol";
5
-
6
- contract StdJsonTest is Test {
7
- using stdJson for string;
8
-
9
- string root;
10
- string path;
11
-
12
- function setUp() public {
13
- root = vm.projectRoot();
14
- path = string.concat(root, "/test/fixtures/test.json");
15
- }
16
-
17
- struct SimpleJson {
18
- uint256 a;
19
- string b;
20
- }
21
-
22
- struct NestedJson {
23
- uint256 a;
24
- string b;
25
- SimpleJson c;
26
- }
27
-
28
- function test_readJson() public view {
29
- string memory json = vm.readFile(path);
30
- assertEq(json.readUint(".a"), 123);
31
- }
32
-
33
- function test_writeJson() public {
34
- string memory json = "json";
35
- json.serialize("a", uint256(123));
36
- string memory semiFinal = json.serialize("b", string("test"));
37
- string memory finalJson = json.serialize("c", semiFinal);
38
- finalJson.write(path);
39
-
40
- string memory json_ = vm.readFile(path);
41
- bytes memory data = json_.parseRaw("$");
42
- NestedJson memory decodedData = abi.decode(data, (NestedJson));
43
-
44
- assertEq(decodedData.a, 123);
45
- assertEq(decodedData.b, "test");
46
- assertEq(decodedData.c.a, 123);
47
- assertEq(decodedData.c.b, "test");
48
- }
49
- }
@@ -1,202 +0,0 @@
1
- // SPDX-License-Identifier: MIT OR Apache-2.0
2
- pragma solidity >=0.8.13 <0.9.0;
3
-
4
- import {stdMath} from "../src/StdMath.sol";
5
- import {Test, stdError} from "../src/Test.sol";
6
-
7
- contract StdMathMock is Test {
8
- function exposedPercentDelta(uint256 a, uint256 b) public pure returns (uint256) {
9
- return stdMath.percentDelta(a, b);
10
- }
11
-
12
- function exposedPercentDelta(int256 a, int256 b) public pure returns (uint256) {
13
- return stdMath.percentDelta(a, b);
14
- }
15
- }
16
-
17
- contract StdMathTest is Test {
18
- function test_GetAbs() external pure {
19
- assertEq(stdMath.abs(-50), 50);
20
- assertEq(stdMath.abs(50), 50);
21
- assertEq(stdMath.abs(-1337), 1337);
22
- assertEq(stdMath.abs(0), 0);
23
-
24
- assertEq(stdMath.abs(type(int256).min), (type(uint256).max >> 1) + 1);
25
- assertEq(stdMath.abs(type(int256).max), (type(uint256).max >> 1));
26
- }
27
-
28
- function testFuzz_GetAbs(int256 a) external pure {
29
- uint256 manualAbs = getAbs(a);
30
-
31
- uint256 abs = stdMath.abs(a);
32
-
33
- assertEq(abs, manualAbs);
34
- }
35
-
36
- function test_GetDelta_Uint() external pure {
37
- assertEq(stdMath.delta(uint256(0), uint256(0)), 0);
38
- assertEq(stdMath.delta(uint256(0), uint256(1337)), 1337);
39
- assertEq(stdMath.delta(uint256(0), type(uint64).max), type(uint64).max);
40
- assertEq(stdMath.delta(uint256(0), type(uint128).max), type(uint128).max);
41
- assertEq(stdMath.delta(uint256(0), type(uint256).max), type(uint256).max);
42
-
43
- assertEq(stdMath.delta(0, uint256(0)), 0);
44
- assertEq(stdMath.delta(1337, uint256(0)), 1337);
45
- assertEq(stdMath.delta(type(uint64).max, uint256(0)), type(uint64).max);
46
- assertEq(stdMath.delta(type(uint128).max, uint256(0)), type(uint128).max);
47
- assertEq(stdMath.delta(type(uint256).max, uint256(0)), type(uint256).max);
48
-
49
- assertEq(stdMath.delta(1337, uint256(1337)), 0);
50
- assertEq(stdMath.delta(type(uint256).max, type(uint256).max), 0);
51
- assertEq(stdMath.delta(5000, uint256(1250)), 3750);
52
- }
53
-
54
- function testFuzz_GetDelta_Uint(uint256 a, uint256 b) external pure {
55
- uint256 manualDelta = a > b ? a - b : b - a;
56
-
57
- uint256 delta = stdMath.delta(a, b);
58
-
59
- assertEq(delta, manualDelta);
60
- }
61
-
62
- function test_GetDelta_Int() external pure {
63
- assertEq(stdMath.delta(int256(0), int256(0)), 0);
64
- assertEq(stdMath.delta(int256(0), int256(1337)), 1337);
65
- assertEq(stdMath.delta(int256(0), type(int64).max), type(uint64).max >> 1);
66
- assertEq(stdMath.delta(int256(0), type(int128).max), type(uint128).max >> 1);
67
- assertEq(stdMath.delta(int256(0), type(int256).max), type(uint256).max >> 1);
68
-
69
- assertEq(stdMath.delta(0, int256(0)), 0);
70
- assertEq(stdMath.delta(1337, int256(0)), 1337);
71
- assertEq(stdMath.delta(type(int64).max, int256(0)), type(uint64).max >> 1);
72
- assertEq(stdMath.delta(type(int128).max, int256(0)), type(uint128).max >> 1);
73
- assertEq(stdMath.delta(type(int256).max, int256(0)), type(uint256).max >> 1);
74
-
75
- assertEq(stdMath.delta(-0, int256(0)), 0);
76
- assertEq(stdMath.delta(-1337, int256(0)), 1337);
77
- assertEq(stdMath.delta(type(int64).min, int256(0)), (type(uint64).max >> 1) + 1);
78
- assertEq(stdMath.delta(type(int128).min, int256(0)), (type(uint128).max >> 1) + 1);
79
- assertEq(stdMath.delta(type(int256).min, int256(0)), (type(uint256).max >> 1) + 1);
80
-
81
- assertEq(stdMath.delta(int256(0), -0), 0);
82
- assertEq(stdMath.delta(int256(0), -1337), 1337);
83
- assertEq(stdMath.delta(int256(0), type(int64).min), (type(uint64).max >> 1) + 1);
84
- assertEq(stdMath.delta(int256(0), type(int128).min), (type(uint128).max >> 1) + 1);
85
- assertEq(stdMath.delta(int256(0), type(int256).min), (type(uint256).max >> 1) + 1);
86
-
87
- assertEq(stdMath.delta(1337, int256(1337)), 0);
88
- assertEq(stdMath.delta(type(int256).max, type(int256).max), 0);
89
- assertEq(stdMath.delta(type(int256).min, type(int256).min), 0);
90
- assertEq(stdMath.delta(type(int256).min, type(int256).max), type(uint256).max);
91
- assertEq(stdMath.delta(5000, int256(1250)), 3750);
92
- }
93
-
94
- function testFuzz_GetDelta_Int(int256 a, int256 b) external pure {
95
- uint256 absA = getAbs(a);
96
- uint256 absB = getAbs(b);
97
- uint256 absDelta = absA > absB ? absA - absB : absB - absA;
98
-
99
- uint256 manualDelta;
100
- if ((a >= 0 && b >= 0) || (a < 0 && b < 0)) {
101
- manualDelta = absDelta;
102
- }
103
- // (a < 0 && b >= 0) || (a >= 0 && b < 0)
104
- else {
105
- manualDelta = absA + absB;
106
- }
107
-
108
- uint256 delta = stdMath.delta(a, b);
109
-
110
- assertEq(delta, manualDelta);
111
- }
112
-
113
- function test_GetPercentDelta_Uint() external {
114
- StdMathMock stdMathMock = new StdMathMock();
115
-
116
- assertEq(stdMath.percentDelta(uint256(0), uint256(1337)), 1e18);
117
- assertEq(stdMath.percentDelta(uint256(0), type(uint64).max), 1e18);
118
- assertEq(stdMath.percentDelta(uint256(0), type(uint128).max), 1e18);
119
- assertEq(stdMath.percentDelta(uint256(0), type(uint192).max), 1e18);
120
-
121
- assertEq(stdMath.percentDelta(1337, uint256(1337)), 0);
122
- assertEq(stdMath.percentDelta(type(uint192).max, type(uint192).max), 0);
123
- assertEq(stdMath.percentDelta(0, uint256(2500)), 1e18);
124
- assertEq(stdMath.percentDelta(2500, uint256(2500)), 0);
125
- assertEq(stdMath.percentDelta(5000, uint256(2500)), 1e18);
126
- assertEq(stdMath.percentDelta(7500, uint256(2500)), 2e18);
127
-
128
- vm.expectRevert("stdMath percentDelta(uint256,uint256): Divisor is zero");
129
- stdMathMock.exposedPercentDelta(uint256(1), 0);
130
- }
131
-
132
- function testFuzz_GetPercentDelta_Uint(uint192 a, uint192 b) external pure {
133
- vm.assume(b != 0);
134
- uint256 manualDelta = a > b ? a - b : b - a;
135
-
136
- uint256 manualPercentDelta = manualDelta * 1e18 / b;
137
- uint256 percentDelta = stdMath.percentDelta(a, b);
138
-
139
- assertEq(percentDelta, manualPercentDelta);
140
- }
141
-
142
- function test_GetPercentDelta_Int() external {
143
- // We deploy a mock version so we can properly test the revert.
144
- StdMathMock stdMathMock = new StdMathMock();
145
-
146
- assertEq(stdMath.percentDelta(int256(0), int256(1337)), 1e18);
147
- assertEq(stdMath.percentDelta(int256(0), -1337), 1e18);
148
- assertEq(stdMath.percentDelta(int256(0), type(int64).min), 1e18);
149
- assertEq(stdMath.percentDelta(int256(0), type(int128).min), 1e18);
150
- assertEq(stdMath.percentDelta(int256(0), type(int192).min), 1e18);
151
- assertEq(stdMath.percentDelta(int256(0), type(int64).max), 1e18);
152
- assertEq(stdMath.percentDelta(int256(0), type(int128).max), 1e18);
153
- assertEq(stdMath.percentDelta(int256(0), type(int192).max), 1e18);
154
-
155
- assertEq(stdMath.percentDelta(1337, int256(1337)), 0);
156
- assertEq(stdMath.percentDelta(type(int192).max, type(int192).max), 0);
157
- assertEq(stdMath.percentDelta(type(int192).min, type(int192).min), 0);
158
-
159
- assertEq(stdMath.percentDelta(type(int192).min, type(int192).max), 2e18); // rounds the 1 wei diff down
160
- assertEq(stdMath.percentDelta(type(int192).max, type(int192).min), 2e18 - 1); // rounds the 1 wei diff down
161
- assertEq(stdMath.percentDelta(0, int256(2500)), 1e18);
162
- assertEq(stdMath.percentDelta(2500, int256(2500)), 0);
163
- assertEq(stdMath.percentDelta(5000, int256(2500)), 1e18);
164
- assertEq(stdMath.percentDelta(7500, int256(2500)), 2e18);
165
-
166
- vm.expectRevert("stdMath percentDelta(int256,int256): Divisor is zero");
167
- stdMathMock.exposedPercentDelta(int256(1), 0);
168
- }
169
-
170
- function testFuzz_GetPercentDelta_Int(int192 a, int192 b) external pure {
171
- vm.assume(b != 0);
172
- uint256 absA = getAbs(a);
173
- uint256 absB = getAbs(b);
174
- uint256 absDelta = absA > absB ? absA - absB : absB - absA;
175
-
176
- uint256 manualDelta;
177
- if ((a >= 0 && b >= 0) || (a < 0 && b < 0)) {
178
- manualDelta = absDelta;
179
- }
180
- // (a < 0 && b >= 0) || (a >= 0 && b < 0)
181
- else {
182
- manualDelta = absA + absB;
183
- }
184
-
185
- uint256 manualPercentDelta = manualDelta * 1e18 / absB;
186
- uint256 percentDelta = stdMath.percentDelta(a, b);
187
-
188
- assertEq(percentDelta, manualPercentDelta);
189
- }
190
-
191
- /*//////////////////////////////////////////////////////////////////////////
192
- HELPERS
193
- //////////////////////////////////////////////////////////////////////////*/
194
-
195
- function getAbs(int256 a) private pure returns (uint256) {
196
- if (a < 0) {
197
- return a == type(int256).min ? uint256(type(int256).max) + 1 : uint256(-a);
198
- }
199
-
200
- return uint256(a);
201
- }
202
- }