@@ -10,65 +10,65 @@ contract LibraryBacktraceTest is DSTest {
10
10
Vm constant vm = Vm (HEVM_ADDRESS);
11
11
LibraryConsumer consumer;
12
12
address constant EXTERNAL_LIB_ADDRESS = 0x1234567890123456789012345678901234567890 ;
13
-
13
+
14
14
function setUp () public {
15
15
// Deploy the external library at the configured address
16
16
bytes memory libraryBytecode = type (ExternalMathLib).runtimeCode;
17
17
vm.etch (EXTERNAL_LIB_ADDRESS, libraryBytecode);
18
-
18
+
19
19
// Deploy consumer contract
20
20
consumer = new LibraryConsumer ();
21
21
}
22
-
22
+
23
23
// Internal library tests (should show inlined source locations)
24
-
24
+
25
25
/// @notice Test division by zero in internal library
26
26
function testInternalDivisionByZero () public {
27
27
consumer.internalDivide (100 , 0 );
28
28
}
29
-
29
+
30
30
/// @notice Test underflow in internal library
31
31
function testInternalUnderflow () public {
32
32
consumer.internalSubtract (10 , 20 );
33
33
}
34
-
34
+
35
35
/// @notice Test overflow in internal library
36
36
function testInternalOverflow () public {
37
37
consumer.internalMultiply (type (uint256 ).max, 2 );
38
38
}
39
-
39
+
40
40
/// @notice Test require in internal library
41
41
function testInternalRequire () public {
42
42
consumer.internalCheckPositive (0 );
43
43
}
44
-
44
+
45
45
// External library tests (should show delegatecall to library address)
46
-
46
+
47
47
/// @notice Test division by zero in external library
48
48
function testExternalDivisionByZero () public {
49
49
consumer.externalDivide (100 , 0 );
50
50
}
51
-
51
+
52
52
/// @notice Test underflow in external library
53
53
function testExternalUnderflow () public {
54
54
consumer.externalSubtract (10 , 20 );
55
55
}
56
-
56
+
57
57
/// @notice Test overflow in external library
58
58
function testExternalOverflow () public {
59
59
consumer.externalMultiply (type (uint256 ).max, 2 );
60
60
}
61
-
61
+
62
62
/// @notice Test require in external library
63
63
function testExternalRequire () public {
64
64
consumer.externalCheckPositive (0 );
65
65
}
66
-
66
+
67
67
// Mixed library usage test
68
-
68
+
69
69
/// @notice Test mixed library usage with failure in external library
70
70
function testMixedLibraryFailure () public {
71
71
// This will fail at the external library division step (50 - 50 = 0, then divide by 0)
72
72
consumer.mixedCalculation (50 , 50 , 0 );
73
73
}
74
- }
74
+ }
0 commit comments