diff --git a/src/AddressContract.sol b/src/AddressContract.sol new file mode 100644 index 0000000..d30b1cf --- /dev/null +++ b/src/AddressContract.sol @@ -0,0 +1,9 @@ +pragma solidity ^0.8.0; + +contract AddressContract { + address public contractAddress; + + function setContractAddress() public { + contractAddress = address(this); + } +} diff --git a/test/Address.t.sol b/test/Address.t.sol new file mode 100644 index 0000000..3c5a57b --- /dev/null +++ b/test/Address.t.sol @@ -0,0 +1,17 @@ +pragma solidity ^0.8.24; + +import {Test, console} from "forge-std/Test.sol"; +import {AddressContract} from "../src/AddressContract.sol"; + +contract AddressTest is Test { + AddressContract public addressContract; + function setUp() public { + addressContract = new AddressContract(); + } + + function test_address() public { + addressContract.setContractAddress(); + + assertEq(addressContract.contractAddress(), address(addressContract), "Contract address should match the instance address"); + } +} diff --git a/test/Test.t.sol b/test/EOF.t.sol similarity index 100% rename from test/Test.t.sol rename to test/EOF.t.sol