Skip to content

Commit

Permalink
added simple address(this) test
Browse files Browse the repository at this point in the history
  • Loading branch information
fgimenez committed Jul 9, 2024
1 parent b90f38e commit 22130b9
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/AddressContract.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
pragma solidity ^0.8.0;

contract AddressContract {
address public contractAddress;

function setContractAddress() public {
contractAddress = address(this);
}
}
17 changes: 17 additions & 0 deletions test/Address.t.sol
Original file line number Diff line number Diff line change
@@ -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");
}
}
File renamed without changes.

0 comments on commit 22130b9

Please sign in to comment.