From 65829dd1e446830ceec287504888106580ffb50d Mon Sep 17 00:00:00 2001 From: Arr00 <13561405+arr00@users.noreply.github.com> Date: Tue, 5 Sep 2023 11:48:37 -0400 Subject: [PATCH] chore: run only forked/non-forked test per run (#285) * All forked tests in `ForkedTest` contract * avoid duplicate testing * change ci commands * fix issues introduced at rebase --- .github/workflows/ci.yml | 4 +- test/crowdfund/InitialETHCrowdfund.t.sol | 8 +- ...ol => OpenseaFulfillOrderForkedTest.t.sol} | 2 +- test/party/PartyGovernanceNFT.t.sol | 54 ++--- test/proposals/ListOnZoraProposalForked.t.sol | 52 +++++ .../ListOnZoraProposalIntegration.t.sol | 184 ------------------ 6 files changed, 90 insertions(+), 214 deletions(-) rename test/crowdfund/{OpenseaForked.t.sol => OpenseaFulfillOrderForkedTest.t.sol} (98%) delete mode 100644 test/proposals/ListOnZoraProposalIntegration.t.sol diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 169ae88c..91290e5e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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: @@ -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: diff --git a/test/crowdfund/InitialETHCrowdfund.t.sol b/test/crowdfund/InitialETHCrowdfund.t.sol index 02cbe22b..a8d9362e 100644 --- a/test/crowdfund/InitialETHCrowdfund.t.sol +++ b/test/crowdfund/InitialETHCrowdfund.t.sol @@ -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, @@ -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; @@ -132,7 +132,9 @@ contract InitialETHCrowdfundTest is LintJSON, TestUtils, ERC721Receiver { ) ); } +} +contract InitialETHCrowdfundTest is InitialETHCrowdfundTestBase { function test_initialization_cannotReinitialize() public { InitialETHCrowdfund crowdfund = _createCrowdfund( CreateCrowdfundArgs({ @@ -1721,7 +1723,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({ diff --git a/test/crowdfund/OpenseaForked.t.sol b/test/crowdfund/OpenseaFulfillOrderForkedTest.t.sol similarity index 98% rename from test/crowdfund/OpenseaForked.t.sol rename to test/crowdfund/OpenseaFulfillOrderForkedTest.t.sol index f41b853d..4851bf8d 100644 --- a/test/crowdfund/OpenseaForked.t.sol +++ b/test/crowdfund/OpenseaFulfillOrderForkedTest.t.sol @@ -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; diff --git a/test/party/PartyGovernanceNFT.t.sol b/test/party/PartyGovernanceNFT.t.sol index 1cd16ad7..f983d087 100644 --- a/test/party/PartyGovernanceNFT.t.sol +++ b/test/party/PartyGovernanceNFT.t.sol @@ -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; @@ -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, @@ -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). @@ -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; diff --git a/test/proposals/ListOnZoraProposalForked.t.sol b/test/proposals/ListOnZoraProposalForked.t.sol index b0f25778..9346a193 100644 --- a/test/proposals/ListOnZoraProposalForked.t.sol +++ b/test/proposals/ListOnZoraProposalForked.t.sol @@ -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); diff --git a/test/proposals/ListOnZoraProposalIntegration.t.sol b/test/proposals/ListOnZoraProposalIntegration.t.sol deleted file mode 100644 index 498971de..00000000 --- a/test/proposals/ListOnZoraProposalIntegration.t.sol +++ /dev/null @@ -1,184 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8; - -import "forge-std/Test.sol"; - -import "../../contracts/globals/Globals.sol"; -import "../../contracts/globals/LibGlobals.sol"; -import "../../contracts/proposals/ProposalExecutionEngine.sol"; -import "../../contracts/distribution/TokenDistributor.sol"; - -import "../TestUtils.sol"; -import "../DummyERC721.sol"; -import "./ZoraTestUtils.sol"; -import "../TestUsers.sol"; - -contract ListOnZoraProposalIntegrationTest is Test, TestUtils, ZoraTestUtils { - IReserveAuctionCoreEth ZORA = - IReserveAuctionCoreEth(0x5f7072E1fA7c01dfAc7Cf54289621AFAaD2184d0); - - GlobalsAdmin globalsAdmin; - Globals globals; - Party partyImpl; - TokenDistributor tokenDistributor; - PartyFactory partyFactory; - PartyParticipant john; - PartyParticipant danny; - PartyParticipant steve; - PartyAdmin partyAdmin; - address johnAddress; - address dannyAddress; - address steveAddress; - - constructor() ZoraTestUtils(ZORA) {} - - function setUp() public onlyForked { - globalsAdmin = new GlobalsAdmin(); - globals = globalsAdmin.globals(); - partyImpl = new Party(globals); - address globalDaoWalletAddress = address(420); - globalsAdmin.setGlobalDaoWallet(globalDaoWalletAddress); - - tokenDistributor = new TokenDistributor(globals, 0); - globalsAdmin.setTokenDistributor(address(tokenDistributor)); - - ProposalExecutionEngine pe = new ProposalExecutionEngine( - globals, - ZORA, - IFractionalV1VaultFactory(address(0)) - ); - globalsAdmin.setProposalEng(address(pe)); - - partyFactory = new PartyFactory(globals); - } - - event ZoraAuctionSold(address token, uint256 tokenid); - - function testForked_simpleZora() public onlyForked { - john = new PartyParticipant(); - danny = new PartyParticipant(); - steve = new PartyParticipant(); - partyAdmin = new PartyAdmin(partyFactory); - - johnAddress = address(john); - dannyAddress = address(danny); - steveAddress = address(steve); - - // Mint dummy NFT to partyAdmin - DummyERC721 toadz = new DummyERC721(); - toadz.mint(address(partyAdmin)); - - ( - Party party, - IERC721[] memory preciousTokens, - uint256[] memory preciousTokenIds - ) = partyAdmin.createParty( - partyImpl, - PartyAdmin.PartyCreationMinimalOptions({ - host1: address(partyAdmin), - host2: address(0), - passThresholdBps: 5100, - totalVotingPower: 150, - preciousTokenAddress: address(toadz), - preciousTokenId: 1, - rageQuitTimestamp: 0, - feeBps: 0, - feeRecipient: payable(0) - }) - ); - // transfer NFT to party - partyAdmin.transferNft(toadz, 1, address(party)); - - partyAdmin.mintGovNft(party, johnAddress, 50); - partyAdmin.mintGovNft(party, dannyAddress, 50); - partyAdmin.mintGovNft(party, steveAddress, 50); - - ListOnZoraProposal.ZoraProposalData memory zpd = ListOnZoraProposal.ZoraProposalData({ - listPrice: 1.5 ether, - timeout: 120, - duration: 120, - 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 = john.makeProposal(party, proposal, 0); - - danny.vote(party, proposalId, 0); - steve.vote(party, proposalId, 0); - - vm.warp(block.timestamp + 76 hours); - - (PartyGovernance.ProposalStatus s, ) = party.getProposalStateInfo(proposalId); - assertEq(uint40(s), uint40(PartyGovernance.ProposalStatus.Ready)); - - PartyParticipant.ExecutionOptions memory eo = PartyParticipant.ExecutionOptions({ - proposalId: proposalId, - proposal: proposal, - preciousTokens: preciousTokens, - preciousTokenIds: preciousTokenIds, - progressData: "" - }); - - john.executeProposal(party, eo); - - // zora auction lifecycle tests - { - // bid up zora auction - address auctionFinalizer = 0x000000000000000000000000000000000000dEaD; - address auctionWinner = 0x000000000000000000000000000000000000D00d; - _bidOnZoraListing(address(toadz), 1, auctionFinalizer, 1.6 ether); - _bidOnZoraListing( - address(toadz), - 1, - 0x0000000000000000000000000000000000001337, - 4.2 ether - ); - _bidOnZoraListing(address(toadz), 1, auctionWinner, 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); - // TODO: test our code path by calling execute() again john.executeProposal(party, eo); - - // ensure NFT is held by winner - assertEq(toadz.ownerOf(1), auctionWinner); - } - - // ensure ETH is held by party - assertEq(address(party).balance, 13.37 ether); - - // distribute ETH and claim distributions - { - vm.prank(johnAddress); - TokenDistributor.DistributionInfo memory distributionInfo = john.distributeEth(party); - - uint256 johnPrevBalance = johnAddress.balance; - vm.prank(johnAddress); - tokenDistributor.claim(distributionInfo, 1); - assertEq(johnAddress.balance, (4.456666666666666663 ether) + johnPrevBalance); - - uint256 dannyPrevBalance = dannyAddress.balance; - vm.prank(dannyAddress); - tokenDistributor.claim(distributionInfo, 2); - assertEq(dannyAddress.balance, (4.456666666666666663 ether) + dannyPrevBalance); - - uint256 stevePrevBalance = steveAddress.balance; - vm.prank(steveAddress); - tokenDistributor.claim(distributionInfo, 3); - assertEq(steveAddress.balance, (4.456666666666666663 ether) + stevePrevBalance); - } - } -}