Skip to content

Commit a2e4b37

Browse files
committed
add comments to transient storage test file with test information
1 parent 260f401 commit a2e4b37

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

actors/evm/tests/contracts/TransientStorageTest.sol

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ contract TransientStorageTest {
66
_runTests();
77
}
88

9+
// Test 0: Initial Constructor Test
910
function runTests() public returns (bool) {
1011
_runTests();
1112
}
@@ -61,13 +62,14 @@ contract TransientStorageTest {
6162
require(retrievedValue == value, "TLOAD did not retrieve stored value within transaction");
6263
}
6364

65+
// Test 2.2: Verify transient storage clears in subsequent transactions
6466
function testLifecycleValidationSubsequentTransaction() public {
65-
// Test clearing by re-calling as a new transaction
6667
uint256 slot = 3;
6768
bool cleared = isStorageCleared(slot);
6869
require(cleared, "Transient storage was not cleared after transaction");
6970
}
7071

72+
// Utility Function: Check if transient storage is cleared
7173
function isStorageCleared(uint256 slot) public view returns (bool) {
7274
uint256 retrievedValue;
7375
assembly {
@@ -76,7 +78,7 @@ contract TransientStorageTest {
7678
return retrievedValue == 0; // True if cleared
7779
}
7880

79-
// Test 2.2: Verify nested contract independence
81+
// Test 3: Verify nested contract independence
8082
function testNestedContracts(address other) public returns (bool) {
8183
uint256 slot = 4;
8284
uint256 value = 88;
@@ -104,7 +106,7 @@ contract TransientStorageTest {
104106
return true;
105107
}
106108

107-
// New function to test reentry scenario
109+
// Test 4: Reentry scenario
108110
function testReentry(address otherContract) public returns (bool) {
109111
uint256 slot = 5;
110112
uint256 value = 123;
@@ -127,6 +129,7 @@ contract TransientStorageTest {
127129
return true;
128130
}
129131

132+
// Utility Function for Test 4: Reentry callback
130133
function reentryCallback() public {
131134
uint256 slot = 6;
132135
uint256 value = 456;
@@ -145,12 +148,14 @@ contract TransientStorageTest {
145148
require(retrievedValue == value, "Reentry callback failed to store correct value");
146149
}
147150

151+
// Utility Function for Test 3: Write to transient storage
148152
function writeTransientData(uint256 slot, uint256 value) external {
149153
assembly {
150154
tstore(slot, value)
151155
}
152156
}
153157

158+
// Utility Function for Test 3: Read from transient storage
154159
function readTransientData(uint256 slot) external view returns (uint256) {
155160
uint256 value;
156161
assembly {

0 commit comments

Comments
 (0)