Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
AustinGreen committed Dec 10, 2023
1 parent cb4a78c commit fdcc2b6
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 17 deletions.
4 changes: 2 additions & 2 deletions src/token-voting/LlamaTokenHolderCaster.sol
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ abstract contract LlamaTokenHolderCaster is Initializable {
if (votesFor <= votesAgainst) revert ForDoesNotSurpassAgainst(votesFor, votesAgainst);

casts[actionInfo.id].approvalSubmitted = true;
llamaCore.castVote(role, actionInfo, "");
llamaCore.castApproval(role, actionInfo, "");
emit ApprovalSubmitted(actionInfo.id, votesFor, votesAgainst, votesAbstain);
}

Expand Down Expand Up @@ -321,7 +321,7 @@ abstract contract LlamaTokenHolderCaster is Initializable {
if (vetoesFor <= vetoesAgainst) revert ForDoesNotSurpassAgainst(vetoesFor, vetoesAgainst);

casts[actionInfo.id].disapprovalSubmitted = true;
llamaCore.castVeto(role, actionInfo, "");
llamaCore.castDisapproval(role, actionInfo, "");
emit DisapprovalSubmitted(actionInfo.id, vetoesFor, vetoesAgainst, vetoesAbstain);
}

Expand Down
12 changes: 6 additions & 6 deletions test/token-voting/ERC20TokenholderCaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ contract CastApprovalBySig is LlamaERC20TokenHolderCasterTest {
(uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey);

vm.prank(tokenHolder1);
llamaERC20TokenHolderCaster.incrementNonce(ILlamaCore.castVoteBySig.selector);
llamaERC20TokenHolderCaster.incrementNonce(ILlamaCore.castApprovalBySig.selector);

// Invalid Signature error since the recovered signer address during the call is not the same as
// erc20VotesTokenholder since nonce has increased.
Expand Down Expand Up @@ -460,9 +460,9 @@ contract CastDisapprovalBySig is LlamaERC20TokenHolderCasterTest {
function test_CheckNonceIncrements() public {
(uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey);

assertEq(llamaERC20TokenHolderCaster.nonces(tokenHolder1, ILlamaCore.castVetoBySig.selector), 0);
assertEq(llamaERC20TokenHolderCaster.nonces(tokenHolder1, ILlamaCore.castDisapprovalBySig.selector), 0);
castDisapprovalBySig(actionInfo, v, r, s);
assertEq(llamaERC20TokenHolderCaster.nonces(tokenHolder1, ILlamaCore.castVetoBySig.selector), 1);
assertEq(llamaERC20TokenHolderCaster.nonces(tokenHolder1, ILlamaCore.castDisapprovalBySig.selector), 1);
}

function test_OperationCannotBeReplayed() public {
Expand Down Expand Up @@ -497,7 +497,7 @@ contract CastDisapprovalBySig is LlamaERC20TokenHolderCasterTest {
(uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey);

vm.prank(tokenHolder1);
llamaERC20TokenHolderCaster.incrementNonce(ILlamaCore.castVetoBySig.selector);
llamaERC20TokenHolderCaster.incrementNonce(ILlamaCore.castDisapprovalBySig.selector);

// Invalid Signature error since the recovered signer address during the second call is not the same as policyholder
// since nonce has increased.
Expand Down Expand Up @@ -571,7 +571,7 @@ contract SubmitApprovals is LlamaERC20TokenHolderCasterTest {
function test_RevertsIf_InsufficientVotes() public {
actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy);
vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS);
vm.expectRevert(abi.encodeWithSelector(LlamaTokenHolderCaster.InsufficientVote.selector, 0, 75_000e18));
vm.expectRevert(abi.encodeWithSelector(LlamaTokenHolderCaster.InsufficientVotes.selector, 0, 75_000e18));
llamaERC20TokenHolderCaster.submitApproval(actionInfo);
}

Expand Down Expand Up @@ -669,7 +669,7 @@ contract SubmitDisapprovals is LlamaERC20TokenHolderCasterTest {

//TODO why add 1 here
vm.warp(block.timestamp + 1 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS);
vm.expectRevert(abi.encodeWithSelector(LlamaTokenHolderCaster.InsufficientVote.selector, 0, 75_000e18));
vm.expectRevert(abi.encodeWithSelector(LlamaTokenHolderCaster.InsufficientVotes.selector, 0, 75_000e18));
llamaERC20TokenHolderCaster.submitDisapproval(actionInfo);
}

Expand Down
12 changes: 6 additions & 6 deletions test/token-voting/ERC721TokenholderCaster.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ contract CastApprovalBySig is LlamaERC721TokenHolderCasterTest {
(uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey);

vm.prank(tokenHolder1);
llamaERC721TokenHolderCaster.incrementNonce(ILlamaCore.castVoteBySig.selector);
llamaERC721TokenHolderCaster.incrementNonce(ILlamaCore.castApprovalBySig.selector);

// Invalid Signature error since the recovered signer address during the call is not the same as
// erc20VotesTokenholder since nonce has increased.
Expand Down Expand Up @@ -466,9 +466,9 @@ contract CastDisapprovalBySig is LlamaERC721TokenHolderCasterTest {
function test_CheckNonceIncrements() public {
(uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey);

assertEq(llamaERC721TokenHolderCaster.nonces(tokenHolder1, ILlamaCore.castVetoBySig.selector), 0);
assertEq(llamaERC721TokenHolderCaster.nonces(tokenHolder1, ILlamaCore.castDisapprovalBySig.selector), 0);
castDisapprovalBySig(actionInfo, v, r, s);
assertEq(llamaERC721TokenHolderCaster.nonces(tokenHolder1, ILlamaCore.castVetoBySig.selector), 1);
assertEq(llamaERC721TokenHolderCaster.nonces(tokenHolder1, ILlamaCore.castDisapprovalBySig.selector), 1);
}

function test_OperationCannotBeReplayed() public {
Expand Down Expand Up @@ -503,7 +503,7 @@ contract CastDisapprovalBySig is LlamaERC721TokenHolderCasterTest {
(uint8 v, bytes32 r, bytes32 s) = createOffchainSignature(actionInfo, tokenHolder1PrivateKey);

vm.prank(tokenHolder1);
llamaERC721TokenHolderCaster.incrementNonce(ILlamaCore.castVetoBySig.selector);
llamaERC721TokenHolderCaster.incrementNonce(ILlamaCore.castDisapprovalBySig.selector);

// Invalid Signature error since the recovered signer address during the second call is not the same as policyholder
// since nonce has increased.
Expand Down Expand Up @@ -577,7 +577,7 @@ contract SubmitApprovals is LlamaERC721TokenHolderCasterTest {
function test_RevertsIf_InsufficientVotes() public {
actionInfo = _createActionWithTokenVotingStrategy(tokenVotingStrategy);
vm.warp(block.timestamp + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS);
vm.expectRevert(abi.encodeWithSelector(LlamaTokenHolderCaster.InsufficientVote.selector, 0, 1));
vm.expectRevert(abi.encodeWithSelector(LlamaTokenHolderCaster.InsufficientVotes.selector, 0, 1));
llamaERC721TokenHolderCaster.submitApproval(actionInfo);
}

Expand Down Expand Up @@ -675,7 +675,7 @@ contract SubmitDisapprovals is LlamaERC721TokenHolderCasterTest {

//TODO why add 1 here
vm.warp(block.timestamp + 1 + (1 days * TWO_THIRDS_IN_BPS) / ONE_HUNDRED_IN_BPS);
vm.expectRevert(abi.encodeWithSelector(LlamaTokenHolderCaster.InsufficientVote.selector, 0, 1));
vm.expectRevert(abi.encodeWithSelector(LlamaTokenHolderCaster.InsufficientVotes.selector, 0, 1));
llamaERC721TokenHolderCaster.submitDisapproval(actionInfo);
}

Expand Down
6 changes: 3 additions & 3 deletions test/token-voting/LlamaTokenVotingFactory.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ contract DeployTokenVotingModule is LlamaTokenVotingFactoryTest {
actionInfo = ActionInfo(actionId, coreTeam4, CORE_TEAM_ROLE, STRATEGY, address(tokenVotingFactory), 0, data);

vm.prank(coreTeam1);
CORE.castVote(CORE_TEAM_ROLE, actionInfo, "");
CORE.castApproval(CORE_TEAM_ROLE, actionInfo, "");
vm.prank(coreTeam2);
CORE.castVote(CORE_TEAM_ROLE, actionInfo, "");
CORE.castApproval(CORE_TEAM_ROLE, actionInfo, "");
vm.prank(coreTeam3);
CORE.castVote(CORE_TEAM_ROLE, actionInfo, "");
CORE.castApproval(CORE_TEAM_ROLE, actionInfo, "");
}

function test_CanDeployERC20TokenVotingModule() public {
Expand Down

0 comments on commit fdcc2b6

Please sign in to comment.