Skip to content

Commit

Permalink
chore: run only forked/non-forked test per run (#285)
Browse files Browse the repository at this point in the history
* All forked tests in `ForkedTest` contract

* avoid duplicate testing

* change ci commands

* fix issues introduced at rebase
  • Loading branch information
arr00 authored Sep 5, 2023
1 parent a070d1b commit 251bb6e
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 214 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
- name: Install dependencies
run: forge install
- name: "Run Foundry tests"
run: forge test -vvv --ffi
run: forge test -vvv --no-match-contract "ForkedTest" --ffi
test-forked:
runs-on: ubuntu-latest
steps:
Expand All @@ -60,7 +60,7 @@ jobs:
- name: Install dependencies
run: forge install
- name: "Run Foundry tests"
run: forge test -vvv --fork-url $FORK_URL --ffi
run: forge test -vvv --fork-url $FORK_URL --match-contract "ForkedTest" --ffi
coverage:
runs-on: ubuntu-latest
steps:
Expand Down
8 changes: 6 additions & 2 deletions test/crowdfund/InitialETHCrowdfund.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import "../../contracts/gatekeepers/AllowListGateKeeper.sol";
import "../TestUtils.sol";
import { LintJSON } from "../utils/LintJSON.sol";

contract InitialETHCrowdfundTest is LintJSON, TestUtils, ERC721Receiver {
contract InitialETHCrowdfundTestBase is LintJSON, TestUtils, ERC721Receiver {
event Contributed(
address indexed sender,
address indexed contributor,
Expand Down Expand Up @@ -93,7 +93,7 @@ contract InitialETHCrowdfundTest is LintJSON, 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 @@ -132,7 +132,9 @@ contract InitialETHCrowdfundTest is LintJSON, TestUtils, ERC721Receiver {
)
);
}
}

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

contract InitialETHCrowdfundForkedTest is InitialETHCrowdfundTestBase {
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
54 changes: 29 additions & 25 deletions test/party/PartyGovernanceNFT.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import "../TestUsers.sol";
import "../TestUtils.sol";
import { LintJSON } from "../utils/LintJSON.sol";

contract PartyGovernanceNFTTest is LintJSON, TestUtils {
contract PartyGovernanceNFTTestBase is LintJSON, TestUtils {
Party partyImpl;
PartyFactory partyFactory;
DummySimpleProposalEngineImpl eng;
Expand Down Expand Up @@ -91,7 +91,9 @@ contract PartyGovernanceNFTTest is LintJSON, TestUtils {
toadz = new DummyERC721();
toadz.mint(nftHolderAddress);
}
}

contract PartyGovernanceNFTTest is PartyGovernanceNFTTestBase {
function testMint() external {
(Party party, , ) = partyAdmin.createParty(
partyImpl,
Expand Down Expand Up @@ -1272,30 +1274,6 @@ contract PartyGovernanceNFTTest is LintJSON, 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);

_lintEncodedJSON(tokenURI);

// 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 @@ -1648,6 +1626,32 @@ contract DummyParty is ReadOnlyDelegateCall {
}
}

contract PartyGovernanceNFTForkedTest is PartyGovernanceNFTTestBase {
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);

_lintEncodedJSON(tokenURI);

// 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 251bb6e

Please sign in to comment.