Add a relay mechanism in the governor (#2926)

Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
Hadrien Croubois
2021-11-30 21:19:20 +01:00
committed by GitHub
parent 3536587665
commit 6089f11c2f
4 changed files with 119 additions and 2 deletions

View File

@ -21,7 +21,7 @@ function makeContractAddress (creator, nonce) {
}
contract('GovernorTimelockCompound', function (accounts) {
const [ admin, voter ] = accounts;
const [ admin, voter, other ] = accounts;
const name = 'OZ-Governor';
// const version = '1';
@ -328,6 +328,57 @@ contract('GovernorTimelockCompound', function (accounts) {
runGovernorWorkflow();
});
describe('relay', function () {
beforeEach(async function () {
await this.token.mint(this.mock.address, 1);
this.call = [
this.token.address,
0,
this.token.contract.methods.transfer(other, 1).encodeABI(),
];
});
it('protected', async function () {
await expectRevert(
this.mock.relay(...this.call),
'Governor: onlyGovernance',
);
});
describe('using workflow', function () {
beforeEach(async function () {
this.settings = {
proposal: [
[
this.mock.address,
],
[
web3.utils.toWei('0'),
],
[
this.mock.contract.methods.relay(...this.call).encodeABI(),
],
'<proposal description>',
],
voters: [
{ voter: voter, support: Enums.VoteType.For },
],
steps: {
queue: { delay: 7 * 86400 },
},
};
expect(await this.token.balanceOf(this.mock.address), 1);
expect(await this.token.balanceOf(other), 0);
});
afterEach(async function () {
expect(await this.token.balanceOf(this.mock.address), 0);
expect(await this.token.balanceOf(other), 1);
});
runGovernorWorkflow();
});
});
describe('updateTimelock', function () {
beforeEach(async function () {
this.newTimelock = await Timelock.new(this.mock.address, 7 * 86400);