Add support for EOA target in Governor.relay (#3730)

This commit is contained in:
Hadrien Croubois
2022-09-26 20:27:33 +02:00
committed by GitHub
parent 5e8e8bb9f0
commit ed12acfb0a
3 changed files with 37 additions and 2 deletions

View File

@ -293,6 +293,39 @@ contract('GovernorTimelockControl', function (accounts) {
);
});
it('is payable and can transfer eth to EOA', async function () {
const t2g = web3.utils.toBN(128); // timelock to governor
const g2o = web3.utils.toBN(100); // governor to eoa (other)
this.helper.setProposal([
{
target: this.mock.address,
value: t2g,
data: this.mock.contract.methods.relay(
other,
g2o,
'0x',
).encodeABI(),
},
], '<proposal description>');
expect(await web3.eth.getBalance(this.mock.address)).to.be.bignumber.equal(web3.utils.toBN(0));
const timelockBalance = await web3.eth.getBalance(this.timelock.address).then(web3.utils.toBN);
const otherBalance = await web3.eth.getBalance(other).then(web3.utils.toBN);
await this.helper.propose();
await this.helper.waitForSnapshot();
await this.helper.vote({ support: Enums.VoteType.For }, { from: voter1 });
await this.helper.waitForDeadline();
await this.helper.queue();
await this.helper.waitForEta();
await this.helper.execute();
expect(await web3.eth.getBalance(this.timelock.address)).to.be.bignumber.equal(timelockBalance.sub(t2g));
expect(await web3.eth.getBalance(this.mock.address)).to.be.bignumber.equal(t2g.sub(g2o));
expect(await web3.eth.getBalance(other)).to.be.bignumber.equal(otherBalance.add(g2o));
});
it('protected against other proposers', async function () {
await this.timelock.schedule(
this.mock.address,