Implement suggestions from audit of 4.9 (#4176)

Co-authored-by: Ernesto García <ernestognw@gmail.com>
This commit is contained in:
Francisco
2023-04-21 12:35:07 +01:00
committed by GitHub
parent 8d633cb7d1
commit 91df66c4a9
15 changed files with 97 additions and 76 deletions

View File

@ -70,7 +70,7 @@ contract('Governor', function (accounts) {
);
});
shouldSupportInterfaces(['ERC165', 'ERC1155Receiver', 'Governor', 'GovernorWithParams']);
shouldSupportInterfaces(['ERC165', 'ERC1155Receiver', 'Governor', 'GovernorWithParams', 'GovernorCancel']);
shouldBehaveLikeEIP6372(mode);
it('deployment check', async function () {
@ -84,7 +84,7 @@ contract('Governor', function (accounts) {
it('nominal workflow', async function () {
// Before
expect(await this.mock.$_proposalProposer(this.proposal.id)).to.be.equal(constants.ZERO_ADDRESS);
expect(await this.mock.proposalProposer(this.proposal.id)).to.be.equal(constants.ZERO_ADDRESS);
expect(await this.mock.hasVoted(this.proposal.id, owner)).to.be.equal(false);
expect(await this.mock.hasVoted(this.proposal.id, voter1)).to.be.equal(false);
expect(await this.mock.hasVoted(this.proposal.id, voter2)).to.be.equal(false);
@ -149,7 +149,7 @@ contract('Governor', function (accounts) {
await expectEvent.inTransaction(txExecute.tx, this.receiver, 'MockFunctionCalled');
// After
expect(await this.mock.$_proposalProposer(this.proposal.id)).to.be.equal(proposer);
expect(await this.mock.proposalProposer(this.proposal.id)).to.be.equal(proposer);
expect(await this.mock.hasVoted(this.proposal.id, owner)).to.be.equal(false);
expect(await this.mock.hasVoted(this.proposal.id, voter1)).to.be.equal(true);
expect(await this.mock.hasVoted(this.proposal.id, voter2)).to.be.equal(true);

View File

@ -90,6 +90,7 @@ const INTERFACES = {
'castVoteBySig(uint256,uint8,uint8,bytes32,bytes32)',
'castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32)',
],
GovernorCancel: ['proposalProposer(uint256)', 'cancel(address[],uint256[],bytes[],bytes32)'],
GovernorTimelock: ['timelock()', 'proposalEta(uint256)', 'queue(address[],uint256[],bytes[],bytes32)'],
ERC2981: ['royaltyInfo(uint256,uint256)'],
};
@ -120,7 +121,7 @@ function shouldSupportInterfaces(interfaces = []) {
it('all interfaces are reported as supported', async function () {
for (const k of interfaces) {
const interfaceId = INTERFACE_IDS[k] ?? k;
expect(await this.contractUnderTest.supportsInterface(interfaceId)).to.equal(true);
expect(await this.contractUnderTest.supportsInterface(interfaceId)).to.equal(true, `does not support ${k}`);
}
});
@ -130,7 +131,10 @@ function shouldSupportInterfaces(interfaces = []) {
if (INTERFACES[k] === undefined) continue;
for (const fnName of INTERFACES[k]) {
const fnSig = FN_SIGNATURES[fnName];
expect(this.contractUnderTest.abi.filter(fn => fn.signature === fnSig).length).to.equal(1);
expect(this.contractUnderTest.abi.filter(fn => fn.signature === fnSig).length).to.equal(
1,
`did not find ${fnName}`,
);
}
}
});