Skip to content

Commit

Permalink
add tests for logic contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
malteish committed Sep 19, 2023
1 parent 3a18e4b commit e1f7666
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 2 additions & 3 deletions test/ContinuousFundraising.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,8 @@ contract ContinuousFundraisingTest is Test {
paymentToken.approve(address(raise), paymentTokenAmount);
}

function testLogicContractCreation(address forwarder) public {
vm.assume(forwarder != address(0));
ContinuousFundraising _logic = new ContinuousFundraising(forwarder);
function testLogicContractCreation() public {
ContinuousFundraising _logic = new ContinuousFundraising(address(1));

console.log("address of logic contract: ", address(_logic));

Expand Down
21 changes: 21 additions & 0 deletions test/Token.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ pragma solidity ^0.8.13;
import "../lib/forge-std/src/Test.sol";
import "../contracts/TokenCloneFactory.sol";
import "../contracts/FeeSettings.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

contract tokenTest is Test {
event RequirementsChanged(uint newRequirements);
Expand Down Expand Up @@ -72,6 +73,26 @@ contract tokenTest is Test {
assertTrue(keccak256(bytes(token.symbol())) == keccak256(bytes("TEST")));
}

function testLogicContractCreation() public {
Token _logic = new Token(address(1));

console.log("address of logic contract: ", address(_logic));

// try to initialize
vm.expectRevert("Initializable: contract is already initialized");
_logic.initialize(IFeeSettingsV1(address(2)), address(3), AllowList(address(4)), 3, "testToken", "TEST");

// all settings are 0
assertTrue(address(_logic.feeSettings()) == address(0));
assertTrue(address(_logic.allowList()) == address(0));
assertTrue(_logic.requirements() == 0);
assertTrue(keccak256(abi.encodePacked(_logic.name())) == keccak256(bytes("")));
assertTrue(keccak256(abi.encodePacked(_logic.symbol())) == keccak256(bytes("")));

// we are not the admin
assertFalse(_logic.hasRole(_logic.DEFAULT_ADMIN_ROLE(), address(this)));
}

function testAllowList0() public {
AllowList _noList = AllowList(address(0));
vm.expectRevert("AllowList must not be zero address");
Expand Down

0 comments on commit e1f7666

Please sign in to comment.