Skip to content

Commit

Permalink
All forked tests in ForkedTest contract
Browse files Browse the repository at this point in the history
  • Loading branch information
arr00 committed Aug 31, 2023
1 parent 837f9eb commit 598a234
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 209 deletions.
8 changes: 6 additions & 2 deletions test/crowdfund/InitialETHCrowdfund.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import "../../contracts/gatekeepers/AllowListGateKeeper.sol";

import "../TestUtils.sol";

contract InitialETHCrowdfundTest is Test, TestUtils, ERC721Receiver {
contract InitialETHCrowdfundBaseTest is Test, TestUtils, ERC721Receiver {
event Contributed(
address indexed sender,
address indexed contributor,
Expand Down Expand Up @@ -92,7 +92,7 @@ contract InitialETHCrowdfundTest is Test, TestUtils, ERC721Receiver {

function _createCrowdfund(
CreateCrowdfundArgs memory args
) private returns (InitialETHCrowdfund crowdfund) {
) internal returns (InitialETHCrowdfund crowdfund) {
InitialETHCrowdfund.InitialETHCrowdfundOptions memory crowdfundOpts;
crowdfundOpts.initialContributor = args.initialContributor;
crowdfundOpts.initialDelegate = args.initialDelegate;
Expand Down Expand Up @@ -131,7 +131,9 @@ contract InitialETHCrowdfundTest is Test, TestUtils, ERC721Receiver {
)
);
}
}

contract InitialETHCrowdfundTest is InitialETHCrowdfundBaseTest {
function test_initialization_cannotReinitialize() public {
InitialETHCrowdfund crowdfund = _createCrowdfund(
CreateCrowdfundArgs({
Expand Down Expand Up @@ -1673,7 +1675,9 @@ contract InitialETHCrowdfundTest is Test, TestUtils, ERC721Receiver {
vm.expectRevert(ETHCrowdfundBase.FundingSplitNotConfiguredError.selector);
crowdfund.sendFundingSplit();
}
}

contract InitialETHCrowdfundForkedTest is InitialETHCrowdfundBaseTest {
function testForked_partyCardTokenURI_whileCrowdfundActive() public onlyForked {
InitialETHCrowdfund crowdfund = _createCrowdfund(
CreateCrowdfundArgs({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import "../../contracts/globals/Globals.sol";
import "../../contracts/globals/LibGlobals.sol";
import "../../contracts/utils/Proxy.sol";

contract OpenseaFulfillOrderTest is Test, TestUtils, OpenseaTestUtils {
contract OpenseaFulfillOrderForkedTest is Test, TestUtils, OpenseaTestUtils {
BuyCrowdfund cf;
Crowdfund.FixedGovernanceOpts govOpts;
ProposalStorage.ProposalEngineOpts proposalEngineOpts;
Expand Down
46 changes: 24 additions & 22 deletions test/party/PartyGovernanceNFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -1269,28 +1269,6 @@ contract PartyGovernanceNFTTest is Test, TestUtils {
assertTrue(bytes(tokenURI).length > 0);
}

function testTokenURI_withFixedCrowdfundType() public onlyForked {
// Create party
DummyParty party = new DummyParty(address(globals), "Party of the Living Dead");

// Setup party as fixed membership mint party
party.setTokenCount(100);
party.mint(33);
party.setVotingPowerPercentage(33, 0.1e18);
party.mint(66);
party.setVotingPowerPercentage(66, 0.1e18);
party.mint(99);
party.setVotingPowerPercentage(99, 0.1e18);

// Get token URI
string memory tokenURI = party.tokenURI(33);

// Uncomment for testing rendering:
// console.log(tokenURI);

assertTrue(bytes(tokenURI).length > 0);
}

// Test rendering using a preset ID 0, which is reserved to indicate to
// parties to use the same preset as the crowdfund that created it (or of
// whatever `authority()` chose if created outside the conventional flow).
Expand Down Expand Up @@ -1633,6 +1611,30 @@ contract DummyParty is ReadOnlyDelegateCall {
}
}

contract PartyGovernanceNFTForkedTest is PartyGovernanceNFTTest {
function testTokenURI_withFixedCrowdfundType() public onlyForked {
// Create party
DummyParty party = new DummyParty(address(globals), "Party of the Living Dead");

// Setup party as fixed membership mint party
party.setTokenCount(100);
party.mint(33);
party.setVotingPowerPercentage(33, 0.1e18);
party.mint(66);
party.setVotingPowerPercentage(66, 0.1e18);
party.mint(99);
party.setVotingPowerPercentage(99, 0.1e18);

// Get token URI
string memory tokenURI = party.tokenURI(33);

// Uncomment for testing rendering:
// console.log(tokenURI);

assertTrue(bytes(tokenURI).length > 0);
}
}

contract TestTokenDistributor {
mapping(Party => uint256) public lastDistributionIdPerParty;
bool private _hasClaimed;
Expand Down
52 changes: 52 additions & 0 deletions test/proposals/ListOnZoraProposalForked.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,58 @@ contract ListOnZoraProposalForkedTest is SetupPartyHelper {
assertEq(address(party).balance, proposalData.listPrice);
}

function testForked_simpleZora() public onlyForked {
DummyERC721 toadz = new DummyERC721();
toadz.mint(address(party));

ListOnZoraProposal.ZoraProposalData memory zpd = ListOnZoraProposal.ZoraProposalData({
listPrice: 1.5 ether,
timeout: 20 minutes,
duration: 20 minutes,
token: address(toadz),
tokenId: 1
});

bytes memory proposalData = abi.encodeWithSelector(
bytes4(uint32(ProposalExecutionEngine.ProposalType.ListOnZora)),
zpd
);

PartyGovernance.Proposal memory proposal = PartyGovernance.Proposal({
maxExecutableTime: uint40(block.timestamp + 10000 hours),
cancelDelay: uint40(1 days),
proposalData: proposalData
});

(uint256 proposalId, bytes memory executionData) = _proposePassAndExecuteProposal(proposal);

// zora auction lifecycle tests
{
// bid up zora auction
address auctionFinalizer = 0x000000000000000000000000000000000000dEaD;
address auctionWinner = 0x000000000000000000000000000000000000D00d;
_bidOnListing(auctionFinalizer, address(toadz), 1, 1.6 ether);
_bidOnListing(0x0000000000000000000000000000000000001337, address(toadz), 1, 4.2 ether);
_bidOnListing(auctionWinner, address(toadz), 1, 13.37 ether);

// have zora auction finish
vm.warp(block.timestamp + ZORA.auctionForNFT(address(toadz), 1).duration);

// finalize zora auction
ZORA.settleAuction(address(toadz), 1);

vm.expectEmit(true, true, true, true);
emit ZoraAuctionSold(address(toadz), 1);
_executeProposal(proposalId, proposal, executionData);

// ensure NFT is held by winner
assertEq(toadz.ownerOf(1), auctionWinner);
}

// ensure ETH is held by party
assertEq(address(party).balance, 13.37 ether);
}

/// MARK: Helpers
function _bidOnListing(address tokenContract, uint256 tokenId, uint256 bid) private {
_bidOnListing(_randomAddress(), tokenContract, tokenId, bid);
Expand Down
184 changes: 0 additions & 184 deletions test/proposals/ListOnZoraProposalIntegration.t.sol

This file was deleted.

0 comments on commit 598a234

Please sign in to comment.