Skip to content

Commit

Permalink
proposeBySigs: add test that proposer can't be signer
Browse files Browse the repository at this point in the history
  • Loading branch information
davidbrai committed Jul 18, 2023
1 parent 6ba25ce commit 64a1974
Showing 1 changed file with 27 additions and 1 deletion.
Expand Up @@ -15,7 +15,8 @@ import { IProxyRegistry } from '../../../contracts/external/opensea/IProxyRegist
import { NounsDAOExecutor } from '../../../contracts/governance/NounsDAOExecutor.sol';

contract ProposeBySigsTest is NounsDAOLogicV3BaseTest {
address proposerWithVote = makeAddr('proposerWithVote');
address proposerWithVote;
uint256 proposerWithVotePK;
address proposerWithNoVotes = makeAddr('proposerWithNoVotes');
address signerWithNoVotes;
uint256 signerWithNoVotesPK;
Expand All @@ -27,6 +28,7 @@ contract ProposeBySigsTest is NounsDAOLogicV3BaseTest {
function setUp() public override {
super.setUp();

(proposerWithVote, proposerWithVotePK) = makeAddrAndKey('proposerWithVote');
(signerWithNoVotes, signerWithNoVotesPK) = makeAddrAndKey('signerWithNoVotes');
(signerWithVote1, signerWithVote1PK) = makeAddrAndKey('signerWithVote1');
(signerWithVote2, signerWithVote2PK) = makeAddrAndKey('signerWithVote2');
Expand Down Expand Up @@ -377,6 +379,30 @@ contract ProposeBySigsTest is NounsDAOLogicV3BaseTest {
dao.proposeBySigs(proposerSignatures, txs.targets, txs.values, txs.signatures, txs.calldatas, 'description');
}

function test_givenProposerIsAlsoSigner_reverts() public {
// Minting to push proposer below threshold, while if counted twice will have enough
vm.startPrank(minter);
for (uint256 i = 0; i < 6; ++i) {
nounsToken.mint();
}
vm.roll(block.number + 1);
vm.stopPrank();
assertEq(dao.proposalThreshold(), 1);

NounsDAOV3Proposals.ProposalTxs memory txs = makeTxs(makeAddr('target'), 0, '', '');
uint256 expirationTimestamp = block.timestamp + 1234;
NounsDAOStorageV3.ProposerSignature[] memory proposerSignatures = new NounsDAOStorageV3.ProposerSignature[](1);
proposerSignatures[0] = NounsDAOStorageV3.ProposerSignature(
signProposal(proposerWithVote, proposerWithVotePK, txs, 'description', expirationTimestamp, address(dao)),
proposerWithVote,
expirationTimestamp
);

vm.prank(proposerWithVote);
vm.expectRevert(NounsDAOV3Proposals.ProposerAlreadyHasALiveProposal.selector);
dao.proposeBySigs(proposerSignatures, txs.targets, txs.values, txs.signatures, txs.calldatas, 'description');
}

function test_givenProposerWithNoVotesAndSignerWithEnoughVotes_worksAndEmitsEvents() public {
NounsDAOV3Proposals.ProposalTxs memory txs = makeTxs(makeAddr('target'), 0, '', '');
uint256 expirationTimestamp = block.timestamp + 1234;
Expand Down

0 comments on commit 64a1974

Please sign in to comment.