diff --git a/src/test/TestTstorishContract.sol b/src/test/TestTstorishContract.sol new file mode 100644 index 0000000..b5e15c8 --- /dev/null +++ b/src/test/TestTstorishContract.sol @@ -0,0 +1,20 @@ +// SPDX-License-Identifier: MIT +pragma solidity ^0.8.24; + +import {Tstorish} from "../Tstorish.sol"; + +contract TestTstorishContract is Tstorish { + constructor() Tstorish() {} + + function setTstorish(uint256 storageSlot, uint256 value) public { + _setTstorish(storageSlot, value); + } + + function getTstorish(uint256 storageSlot) public view returns (uint256) { + return _getTstorish(storageSlot); + } + + function clearTstorish(uint256 storageSlot) public { + _clearTstorish(storageSlot); + } +} diff --git a/test/foundry/TestTstorish.t.sol b/test/foundry/TestTstorish.t.sol index f9054b4..567e1b9 100644 --- a/test/foundry/TestTstorish.t.sol +++ b/test/foundry/TestTstorish.t.sol @@ -3,27 +3,51 @@ pragma solidity ^0.8.24; import {Test} from "forge-std/Test.sol"; -import {Tstorish} from "../../src/Tstorish.sol"; +import {TestTstorishContract} from "../../src/test/TestTstorishContract.sol"; contract TestTstorish is Test { - Tstorish tstorish; + TestTstorishContract tstorishcontract; function setUp() public { - _deployTstorish(); + _deployTstorishContract(); } - function _deployTstorish() private { - tstorish = new Tstorish(); + function _deployTstorishContract() private { + tstorishcontract = new TestTstorishContract(); } function test_fail_activateTstore_alreadyActivated() public { vm.expectRevert(abi.encodeWithSignature("TStoreAlreadyActivated()")); vm.prank(address(this), address(this)); - tstorish.__activateTstore(); + tstorishcontract.__activateTstore(); } function test_fail_activateTstore_onlyDirectCalls() public { vm.expectRevert(abi.encodeWithSignature("OnlyDirectCalls()")); - tstorish.__activateTstore(); + tstorishcontract.__activateTstore(); + } + + function testSetTstorish() public { + uint256 storageSlot = 0x1337; + uint256 value = 500; + // Set the value in the storage slot + tstorishcontract.setTstorish(storageSlot, value); + // Get the value from the storage slot + uint256 result = tstorishcontract.getTstorish(storageSlot); + // Assert that the value is equal to the value we set + assertEq(result, value); + } + + function testClearTstorish() public { + uint256 storageSlot = 0x1337; + uint256 value = 500; + // Set the value in the storage slot + tstorishcontract.setTstorish(storageSlot, value); + // Clear the value in the storage slot + tstorishcontract.clearTstorish(storageSlot); + // Get the value from the storage slot + uint256 result = tstorishcontract.getTstorish(storageSlot); + // Assert that the value is equal to 0 + assertEq(result, 0); } }