From 23d54b8519aec96c971d5119686e2e7c7f54bb2b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernani=20S=C3=A3o=20Thiago?= Date: Sun, 12 Nov 2023 17:42:12 -0500 Subject: [PATCH] fixed tests --- hardhat.config.ts | 2 +- test/SftRolesRegistry/SftRolesRegistry.spec.ts | 6 +++--- test/SftRolesRegistry/helpers.ts | 4 ---- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/hardhat.config.ts b/hardhat.config.ts index 4d4146b..e3ee99f 100644 --- a/hardhat.config.ts +++ b/hardhat.config.ts @@ -39,7 +39,7 @@ const BASE_CONFIG = { timeout: 840000, }, gasReporter: { - enabled: false, + enabled: true, excludeContracts: ['contracts/test'], gasPrice: 100, token: 'MATIC', diff --git a/test/SftRolesRegistry/SftRolesRegistry.spec.ts b/test/SftRolesRegistry/SftRolesRegistry.spec.ts index ad48393..b57471f 100644 --- a/test/SftRolesRegistry/SftRolesRegistry.spec.ts +++ b/test/SftRolesRegistry/SftRolesRegistry.spec.ts @@ -3,9 +3,9 @@ import { Contract } from 'ethers' import { beforeEach } from 'mocha' import { expect } from 'chai' import { solidityKeccak256 } from 'ethers/lib/utils' -import { loadFixture } from '@nomicfoundation/hardhat-network-helpers' +import { loadFixture, time } from '@nomicfoundation/hardhat-network-helpers' import { SignerWithAddress } from '@nomiclabs/hardhat-ethers/signers' -import { buildRoleAssignment, currentUnixTimestamp, ONE_DAY, generateRoleId, buildRevokeRoleData } from './helpers' +import { buildRoleAssignment, ONE_DAY, generateRoleId, buildRevokeRoleData } from './helpers' import { RoleAssignment, RevokeRoleData } from './types' import { generateRandomInt } from '../helpers' @@ -42,7 +42,7 @@ describe('SftRolesRegistry', async () => { it('should revert if expirationDate is in the past', async () => { const roleAssignment = await buildRoleAssignment({ - expirationDate: currentUnixTimestamp() - ONE_DAY, + expirationDate: (await time.latest()) - ONE_DAY, }) await expect(SftRolesRegistry.grantRoleFrom(roleAssignment)).to.be.revertedWith( 'SftRolesRegistry: expiration date must be in the future', diff --git a/test/SftRolesRegistry/helpers.ts b/test/SftRolesRegistry/helpers.ts index 72366be..d1697d3 100644 --- a/test/SftRolesRegistry/helpers.ts +++ b/test/SftRolesRegistry/helpers.ts @@ -60,7 +60,3 @@ export function buildRevokeRoleData(roleAssignment: RoleAssignment): RevokeRoleD export function generateRoleId(role: string) { return solidityKeccak256(['string'], [role]) } - -export function currentUnixTimestamp() { - return Math.floor(Date.now() / 1000) -}