From d79c2ecb6d31f82650fe71fef08364c208a4abea Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 14 Feb 2023 17:53:49 -0300 Subject: [PATCH 01/11] Fix flaky timestamp tests --- test/helpers/time.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/helpers/time.js b/test/helpers/time.js index 2e5f6d85a90..4c97bca5c17 100644 --- a/test/helpers/time.js +++ b/test/helpers/time.js @@ -1,16 +1,16 @@ -const { time } = 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.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: helpers.mineUpTo, + timestamp: helpers.time.increaseTo, }, }; From f7c96e2677b70c7fcb264d4bfc0e829b0f1a6b0e Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 14 Feb 2023 17:53:57 -0300 Subject: [PATCH 02/11] refactor .then to async --- test/helpers/governance.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/test/helpers/governance.js b/test/helpers/governance.js index ae88e151aae..1ffa086cbd8 100644 --- a/test/helpers/governance.js +++ b/test/helpers/governance.js @@ -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)); } /** From b18037d2e7e0e4af26a9e05661076c85eccd9530 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 14 Feb 2023 20:06:13 -0300 Subject: [PATCH 03/11] fix helper use --- test/helpers/time.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/helpers/time.js b/test/helpers/time.js index 4c97bca5c17..65dcd461e90 100644 --- a/test/helpers/time.js +++ b/test/helpers/time.js @@ -2,7 +2,7 @@ const helpers = require('@nomicfoundation/hardhat-network-helpers'); module.exports = { clock: { - blocknumber: () => helpers.latestBlock(), + blocknumber: () => helpers.time.latestBlock(), timestamp: () => helpers.time.latest(), }, clockFromReceipt: { From c90e2b893f3de3cb90115f7d9fdaa1f0b58b5813 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 14 Feb 2023 20:50:11 -0300 Subject: [PATCH 04/11] disable gas report --- .github/workflows/checks.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 02664e85c8c..30afb986c1d 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -26,7 +26,6 @@ jobs: runs-on: ubuntu-latest env: FORCE_COLOR: 1 - GAS: true steps: - uses: actions/checkout@v3 - name: Set up environment From f0e42d67caca733b446dabadf79f24de1b6d62f7 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Tue, 14 Feb 2023 21:02:14 -0300 Subject: [PATCH 05/11] increase heap size --- .github/workflows/checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 30afb986c1d..6594a4ea419 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -26,6 +26,7 @@ jobs: runs-on: ubuntu-latest env: FORCE_COLOR: 1 + NODE_OPTIONS: --max_old_space_size=4096 steps: - uses: actions/checkout@v3 - name: Set up environment From 2a728c0d9fc62e440b7b6a96a55ef8adb3949ff7 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 15 Feb 2023 10:56:35 -0300 Subject: [PATCH 06/11] Revert "disable gas report" This reverts commit c90e2b893f3de3cb90115f7d9fdaa1f0b58b5813. --- .github/workflows/checks.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 6594a4ea419..8bb32dcc30c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -27,6 +27,7 @@ jobs: env: FORCE_COLOR: 1 NODE_OPTIONS: --max_old_space_size=4096 + GAS: true steps: - uses: actions/checkout@v3 - name: Set up environment From 2808f0e38b0545ec7b14b103f05b9dc2492dd8d8 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 15 Feb 2023 10:58:48 -0300 Subject: [PATCH 07/11] revert back to openzeppelin test helpers --- test/helpers/time.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/helpers/time.js b/test/helpers/time.js index 65dcd461e90..2e5f6d85a90 100644 --- a/test/helpers/time.js +++ b/test/helpers/time.js @@ -1,16 +1,16 @@ -const helpers = require('@nomicfoundation/hardhat-network-helpers'); +const { time } = require('@openzeppelin/test-helpers'); module.exports = { clock: { - blocknumber: () => helpers.time.latestBlock(), - timestamp: () => helpers.time.latest(), + blocknumber: () => web3.eth.getBlock('latest').then(block => block.number), + timestamp: () => web3.eth.getBlock('latest').then(block => block.timestamp), }, clockFromReceipt: { blocknumber: receipt => Promise.resolve(receipt.blockNumber), timestamp: receipt => web3.eth.getBlock(receipt.blockNumber).then(block => block.timestamp), }, forward: { - blocknumber: helpers.mineUpTo, - timestamp: helpers.time.increaseTo, + blocknumber: time.advanceBlockTo, + timestamp: time.increaseTo, }, }; From 49ccb68fa7dad71bd9b824c881968ea8a781217e Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 15 Feb 2023 11:22:23 -0300 Subject: [PATCH 08/11] disable gas report --- .github/workflows/checks.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 8bb32dcc30c..6594a4ea419 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -27,7 +27,6 @@ jobs: env: FORCE_COLOR: 1 NODE_OPTIONS: --max_old_space_size=4096 - GAS: true steps: - uses: actions/checkout@v3 - name: Set up environment From ebba0155c9d9cb9730e240a8893a764f2a888df6 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 15 Feb 2023 11:54:59 -0300 Subject: [PATCH 09/11] gas + nomic + only mineUpTo --- .github/workflows/checks.yml | 1 + test/helpers/time.js | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index 6594a4ea419..8bb32dcc30c 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -27,6 +27,7 @@ jobs: env: FORCE_COLOR: 1 NODE_OPTIONS: --max_old_space_size=4096 + GAS: true steps: - uses: actions/checkout@v3 - name: Set up environment diff --git a/test/helpers/time.js b/test/helpers/time.js index 2e5f6d85a90..56e3cf862ab 100644 --- a/test/helpers/time.js +++ b/test/helpers/time.js @@ -1,4 +1,5 @@ const { time } = require('@openzeppelin/test-helpers'); +const helpers = require('@nomicfoundation/hardhat-network-helpers'); module.exports = { clock: { @@ -10,7 +11,7 @@ module.exports = { timestamp: receipt => web3.eth.getBlock(receipt.blockNumber).then(block => block.timestamp), }, forward: { - blocknumber: time.advanceBlockTo, + blocknumber: helpers.mineUpTo, timestamp: time.increaseTo, }, }; From 052bd4345c37966b6313f0d46a4f697c0aba5693 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 15 Feb 2023 18:49:24 -0300 Subject: [PATCH 10/11] use advanceBlockTo from oz helpers --- test/helpers/time.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/test/helpers/time.js b/test/helpers/time.js index 56e3cf862ab..f8d15a91fe6 100644 --- a/test/helpers/time.js +++ b/test/helpers/time.js @@ -1,17 +1,17 @@ -const { time } = require('@openzeppelin/test-helpers'); +const { time: { advanceBlockTo } } = 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: helpers.mineUpTo, - timestamp: time.increaseTo, + blocknumber: advanceBlockTo, + timestamp: helpers.time.increaseTo, }, }; From cdb4f122967837c1d8f9f89bcb4b19e515d259d3 Mon Sep 17 00:00:00 2001 From: Francisco Giordano Date: Wed, 15 Feb 2023 18:52:39 -0300 Subject: [PATCH 11/11] lint --- test/helpers/time.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/helpers/time.js b/test/helpers/time.js index f8d15a91fe6..30df8dc32ea 100644 --- a/test/helpers/time.js +++ b/test/helpers/time.js @@ -1,4 +1,4 @@ -const { time: { advanceBlockTo } } = require('@openzeppelin/test-helpers'); +const ozHelpers = require('@openzeppelin/test-helpers'); const helpers = require('@nomicfoundation/hardhat-network-helpers'); module.exports = { @@ -11,7 +11,7 @@ module.exports = { timestamp: receipt => web3.eth.getBlock(receipt.blockNumber).then(block => block.timestamp), }, forward: { - blocknumber: advanceBlockTo, + blocknumber: ozHelpers.time.advanceBlockTo, timestamp: helpers.time.increaseTo, }, };