Skip to content

Commit

Permalink
Used web3.utils.toBN for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ernestognw committed Aug 2, 2023
1 parent eb76991 commit 4d6d205
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
7 changes: 7 additions & 0 deletions test/helpers/constants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const MAX_UINT48 = web3.utils.toBN(1).shln(48).subn(1).toString();
const MAX_UINT64 = web3.utils.toBN(1).shln(64).subn(1).toString();

module.exports = {
MAX_UINT48,
MAX_UINT64,
};
3 changes: 1 addition & 2 deletions test/metatx/ERC2771Context.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const ethSigUtil = require('eth-sig-util');
const Wallet = require('ethereumjs-wallet').default;
const { getDomain, domainType } = require('../helpers/eip712');
const { MAX_UINT48 } = require('../helpers/constants');

const { expectEvent } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
Expand All @@ -14,8 +15,6 @@ const { shouldBehaveLikeRegularContext } = require('../utils/Context.behavior');
contract('ERC2771Context', function (accounts) {
const [, trustedForwarder] = accounts;

const MAX_UINT48 = web3.utils.toBN(1).shln(48).subn(1).toString();

beforeEach(async function () {
this.forwarder = await ERC2771Forwarder.new('ERC2771Forwarder');
this.recipient = await ERC2771ContextMock.new(this.forwarder.address);
Expand Down
3 changes: 2 additions & 1 deletion test/proxy/utils/Initializable.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const { expectEvent } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const { expectRevertCustomError } = require('../../helpers/customError');
const { MAX_UINT64 } = require('../../helpers/constants');

const InitializableMock = artifacts.require('InitializableMock');
const ConstructorInitializableMock = artifacts.require('ConstructorInitializableMock');
Expand Down Expand Up @@ -213,7 +214,7 @@ contract('Initializable', function () {
it('old and new patterns in good sequence', async function () {
const ok = await DisableOk.new();
await expectEvent.inConstruction(ok, 'Initialized', { version: '1' });
await expectEvent.inConstruction(ok, 'Initialized', { version: (2n ** 64n - 1n).toString() }); // MAX_UINT64
await expectEvent.inConstruction(ok, 'Initialized', { version: MAX_UINT64 });
});
});
});

0 comments on commit 4d6d205

Please sign in to comment.