Fix flaky timestamp tests (#4046)
This commit is contained in:
1
.github/workflows/checks.yml
vendored
1
.github/workflows/checks.yml
vendored
@ -26,6 +26,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
FORCE_COLOR: 1
|
FORCE_COLOR: 1
|
||||||
|
NODE_OPTIONS: --max_old_space_size=4096
|
||||||
GAS: true
|
GAS: true
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|||||||
@ -115,19 +115,22 @@ class GovernorHelper {
|
|||||||
: this.governor.castVote(...concatOpts([proposal.id, vote.support], opts));
|
: this.governor.castVote(...concatOpts([proposal.id, vote.support], opts));
|
||||||
}
|
}
|
||||||
|
|
||||||
waitForSnapshot(offset = 0) {
|
async waitForSnapshot(offset = 0) {
|
||||||
const proposal = this.currentProposal;
|
const proposal = this.currentProposal;
|
||||||
return this.governor.proposalSnapshot(proposal.id).then(timepoint => forward[this.mode](timepoint.addn(offset)));
|
const timepoint = await this.governor.proposalSnapshot(proposal.id);
|
||||||
|
return forward[this.mode](timepoint.addn(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
waitForDeadline(offset = 0) {
|
async waitForDeadline(offset = 0) {
|
||||||
const proposal = this.currentProposal;
|
const proposal = this.currentProposal;
|
||||||
return this.governor.proposalDeadline(proposal.id).then(timepoint => forward[this.mode](timepoint.addn(offset)));
|
const timepoint = await this.governor.proposalDeadline(proposal.id);
|
||||||
|
return forward[this.mode](timepoint.addn(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
waitForEta(offset = 0) {
|
async waitForEta(offset = 0) {
|
||||||
const proposal = this.currentProposal;
|
const proposal = this.currentProposal;
|
||||||
return this.governor.proposalEta(proposal.id).then(timestamp => forward.timestamp(timestamp.addn(offset)));
|
const timestamp = await this.governor.proposalEta(proposal.id);
|
||||||
|
return forward.timestamp(timestamp.addn(offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -1,16 +1,17 @@
|
|||||||
const { time } = require('@openzeppelin/test-helpers');
|
const ozHelpers = require('@openzeppelin/test-helpers');
|
||||||
|
const helpers = require('@nomicfoundation/hardhat-network-helpers');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
clock: {
|
clock: {
|
||||||
blocknumber: () => web3.eth.getBlock('latest').then(block => block.number),
|
blocknumber: () => helpers.time.latestBlock(),
|
||||||
timestamp: () => web3.eth.getBlock('latest').then(block => block.timestamp),
|
timestamp: () => helpers.time.latest(),
|
||||||
},
|
},
|
||||||
clockFromReceipt: {
|
clockFromReceipt: {
|
||||||
blocknumber: receipt => Promise.resolve(receipt.blockNumber),
|
blocknumber: receipt => Promise.resolve(receipt.blockNumber),
|
||||||
timestamp: receipt => web3.eth.getBlock(receipt.blockNumber).then(block => block.timestamp),
|
timestamp: receipt => web3.eth.getBlock(receipt.blockNumber).then(block => block.timestamp),
|
||||||
},
|
},
|
||||||
forward: {
|
forward: {
|
||||||
blocknumber: time.advanceBlockTo,
|
blocknumber: ozHelpers.time.advanceBlockTo,
|
||||||
timestamp: time.increaseTo,
|
timestamp: helpers.time.increaseTo,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user