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
|
||||
env:
|
||||
FORCE_COLOR: 1
|
||||
NODE_OPTIONS: --max_old_space_size=4096
|
||||
GAS: true
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
@ -115,19 +115,22 @@ class GovernorHelper {
|
||||
: this.governor.castVote(...concatOpts([proposal.id, vote.support], opts));
|
||||
}
|
||||
|
||||
waitForSnapshot(offset = 0) {
|
||||
async waitForSnapshot(offset = 0) {
|
||||
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;
|
||||
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;
|
||||
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 = {
|
||||
clock: {
|
||||
blocknumber: () => web3.eth.getBlock('latest').then(block => block.number),
|
||||
timestamp: () => web3.eth.getBlock('latest').then(block => block.timestamp),
|
||||
blocknumber: () => helpers.time.latestBlock(),
|
||||
timestamp: () => helpers.time.latest(),
|
||||
},
|
||||
clockFromReceipt: {
|
||||
blocknumber: receipt => Promise.resolve(receipt.blockNumber),
|
||||
timestamp: receipt => web3.eth.getBlock(receipt.blockNumber).then(block => block.timestamp),
|
||||
},
|
||||
forward: {
|
||||
blocknumber: time.advanceBlockTo,
|
||||
timestamp: time.increaseTo,
|
||||
blocknumber: ozHelpers.time.advanceBlockTo,
|
||||
timestamp: helpers.time.increaseTo,
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user