Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabnock01 committed Nov 2, 2023
1 parent 328a7f7 commit b6e0ae9
Show file tree
Hide file tree
Showing 3 changed files with 174 additions and 1 deletion.
86 changes: 86 additions & 0 deletions test/deploy/DeployBaseGoerli.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Test } from "forge-std/Test.sol";

import { AuthorshipToken } from "@/contracts/AuthorshipToken.sol";
import { Curta } from "@/contracts/Curta.sol";
import { DeployBaseGoerli } from "@/script/deploy/DeployBaseGoerli.s.sol";

/// @notice Tests the Base Goerli deploy script.
contract DeployBaseGoerliTest is Test {
// -------------------------------------------------------------------------
// Contracts
// -------------------------------------------------------------------------

/// @notice The Base Goerli deploy script.
DeployBaseGoerli internal deployBaseGoerli;

// -------------------------------------------------------------------------
// Setup
// -------------------------------------------------------------------------

function setUp() public {
vm.deal(vm.addr(vm.envUint("DEPLOYER_PRIVATE_KEY")), type(uint64).max);

deployBaseGoerli = new DeployBaseGoerli();
deployBaseGoerli.run();
}

// -------------------------------------------------------------------------
// Tests
// -------------------------------------------------------------------------

/// @notice Test that the addresses were set correctly in each contract's
/// deploy.
function test_AddressInitializationCorrectness() public {
assertEq(address(deployBaseGoerli.curta().flagRenderer()), address(deployBaseGoerli.flagRenderer()));
assertEq(
address(deployBaseGoerli.curta().authorshipToken()), address(deployBaseGoerli.authorshipToken())
);
assertEq(deployBaseGoerli.authorshipToken().curta(), address(deployBaseGoerli.curta()));
}

/// @notice Test that the Authorship Token's issue length was set correctly.
function test_authorshipTokenIssueLengthEquality() public {
assertEq(deployBaseGoerli.authorshipToken().issueLength(), deployBaseGoerli.issueLength());
}

/// @notice Test that the Authorship Token's authors were set.
function test_authorshipTokenAuthorsEquality() public {
uint256 totalSupply = deployBaseGoerli.authorshipToken().totalSupply();
assertEq(totalSupply, deployBaseGoerli.authorsLength());

unchecked {
for (uint256 i; i < totalSupply; ++i) {
assertEq(deployBaseGoerli.authorshipToken().ownerOf(i + 1), deployBaseGoerli.authors(i));
}
}
}

/// @notice Test that an Authorship Token can be minted after deploy.
function test_authorshipTokenMinting() public {
AuthorshipToken authorshipToken = deployBaseGoerli.authorshipToken();

// Warp 1 `issueLength` period forward in time to ensure the owner can
// mint 1.
vm.warp(block.timestamp + authorshipToken.issueLength() + 1);

// Mint as owner.
vm.prank(authorshipToken.owner());
authorshipToken.ownerMint(address(this));
}

/// @notice Test that the Authorship Token's ownership was transferred
/// correctly.
function test_authorshipTokenOwnerEquality() public {
assertEq(deployBaseGoerli.authorshipToken().owner(), deployBaseGoerli.authorshipTokenOwner());
}

/// @notice Test that Curta's ownership was transferred correctly.
function test_curtaOwnerEquality() public {
assertEq(deployBaseGoerli.curta().owner(), deployBaseGoerli.curtaOwner());
}

}

87 changes: 87 additions & 0 deletions test/deploy/DeployBaseMainnet.t.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.17;

import { Test } from "forge-std/Test.sol";

import { AuthorshipToken } from "@/contracts/AuthorshipToken.sol";
import { Curta } from "@/contracts/Curta.sol";
import { DeployBaseMainnet } from "@/script/deploy/DeployBaseMainnet.s.sol";

/// @notice Tests the Base mainnet deploy script.
contract DeployBaseMainnetTest is Test {
// -------------------------------------------------------------------------
// Contracts
// -------------------------------------------------------------------------

/// @notice The Base mainnet deploy script.
DeployBaseMainnet internal deployBaseMainnet;

// -------------------------------------------------------------------------
// Setup
// -------------------------------------------------------------------------

function setUp() public {
vm.deal(vm.addr(vm.envUint("DEPLOYER_PRIVATE_KEY")), type(uint64).max);

deployBaseMainnet = new DeployBaseMainnet();
deployBaseMainnet.run();
}

// -------------------------------------------------------------------------
// Tests
// -------------------------------------------------------------------------

/// @notice Test that the addresses were set correctly in each contract's
/// deploy.
function test_AddressInitializationCorrectness() public {
assertEq(
address(deployBaseMainnet.curta().flagRenderer()), address(deployBaseMainnet.flagRenderer())
);
assertEq(
address(deployBaseMainnet.curta().authorshipToken()),
address(deployBaseMainnet.authorshipToken())
);
assertEq(deployBaseMainnet.authorshipToken().curta(), address(deployBaseMainnet.curta()));
}

/// @notice Test that the Authorship Token's issue length was set correctly.
function test_authorshipTokenIssueLengthEquality() public {
assertEq(deployBaseMainnet.authorshipToken().issueLength(), deployBaseMainnet.issueLength());
}

/// @notice Test that the Authorship Token's authors were set.
function test_authorshipTokenAuthorsEquality() public {
uint256 totalSupply = deployBaseMainnet.authorshipToken().totalSupply();
assertEq(totalSupply, deployBaseMainnet.authorsLength());

unchecked {
for (uint256 i; i < totalSupply; ++i) {
assertEq(deployBaseMainnet.authorshipToken().ownerOf(i + 1), deployBaseMainnet.authors(i));
}
}
}

/// @notice Test that an Authorship Token can be minted after deploy.
function test_authorshipTokenMinting() public {
AuthorshipToken authorshipToken = deployBaseMainnet.authorshipToken();

// Warp 1 `issueLength` period forward in time to ensure the owner can
// mint 1.
vm.warp(block.timestamp + authorshipToken.issueLength() + 1);

// Mint as owner.
vm.prank(authorshipToken.owner());
authorshipToken.ownerMint(address(this));
}

/// @notice Test that the Authorship Token's ownership was transferred
/// correctly.
function test_authorshipTokenOwnerEquality() public {
assertEq(deployBaseMainnet.authorshipToken().owner(), deployBaseMainnet.authorshipTokenOwner());
}

/// @notice Test that Curta's ownership was transferred correctly.
function test_curtaOwnerEquality() public {
assertEq(deployBaseMainnet.curta().owner(), deployBaseMainnet.curtaOwner());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Test } from "forge-std/Test.sol";

import { AuthorshipToken } from "@/contracts/AuthorshipToken.sol";
import { Curta } from "@/contracts/Curta.sol";
import { DeployConstellation } from "@/script/deploy/DeployConstellation.s.sol";
import { DeployConstellation } from "@/script/deploy/deprecated/DeployConstellation.s.sol";

/// @notice Tests the Constellation chain deploy script.
contract DeployConstellationTest is Test {
Expand Down

0 comments on commit b6e0ae9

Please sign in to comment.