-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
174 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters