Migrate to Hardhat (#2397)

This commit is contained in:
Francisco Giordano
2020-10-28 17:03:05 -03:00
committed by GitHub
parent 0c27ecc536
commit f06738828b
75 changed files with 4229 additions and 20338 deletions

View File

@@ -18,6 +18,8 @@
"contract": false,
"assert": false,
"web3": false,
"usePlugin": false,
"extendEnvironment": false,
},
"rules": {

7
.gitignore vendored
View File

@@ -50,3 +50,10 @@ contracts/README.md
# temporary artifact from solidity-coverage
allFiredEvents
.coverage_artifacts
.coverage_cache
.coverage_contracts
# buidler
cache
artifacts

View File

@@ -4,5 +4,8 @@ module.exports = {
compileCommand: 'npm run compile',
skipFiles: [
'mocks',
]
],
providerOptions: {
default_balance_ether: '10000000000000000000000000',
},
}

23
buidler.config.js Normal file
View File

@@ -0,0 +1,23 @@
usePlugin('solidity-coverage');
usePlugin('@nomiclabs/buidler-truffle5');
extendEnvironment(env => {
const { contract } = env;
env.contract = function (name, body) {
// remove the default account from the accounts list used in tests, in order
// to protect tests against accidentally passing due to the contract
// deployer being used subsequently as function caller
contract(name, accounts => body(accounts.slice(1)));
};
});
module.exports = {
networks: {
buidlerevm: {
blockGasLimit: 10000000,
},
},
solc: {
version: '0.6.12',
},
};

23958
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -10,8 +10,8 @@
"/test/behaviors"
],
"scripts": {
"compile": "scripts/compile.sh",
"coverage": "scripts/coverage.js",
"compile": "buidler compile",
"coverage": "scripts/coverage.sh",
"docs": "oz-docs",
"docs:watch": "npm run docs watch contracts 'docs/*.hbs'",
"prepare-docs": "scripts/prepare-docs.sh",
@@ -20,12 +20,12 @@
"lint:js": "eslint --ignore-path .gitignore .",
"lint:js:fix": "eslint --ignore-path .gitignore . --fix",
"lint:sol": "solhint --max-warnings 0 \"contracts/**/*.sol\"",
"prepublish": "rimraf build contracts/build",
"prepublish": "rimraf build contracts/build artifacts",
"prepare": "npm run compile",
"prepack": "node scripts/remove-ignored-artifacts.js",
"prepack": "scripts/prepack.sh",
"release": "scripts/release/release.sh",
"version": "scripts/release/version.sh",
"test": "mocha --exit --recursive"
"test": "buidler test"
},
"repository": {
"type": "git",
@@ -46,12 +46,13 @@
},
"homepage": "https://openzeppelin.com/contracts/",
"devDependencies": {
"@openzeppelin/cli": "^2.8.2",
"@nomiclabs/buidler": "^1.4.8",
"@nomiclabs/buidler-truffle5": "^1.3.4",
"@nomiclabs/buidler-web3": "^1.3.4",
"@openzeppelin/docs-utils": "^0.1.0",
"@openzeppelin/gsn-helpers": "^0.2.3",
"@openzeppelin/gsn-provider": "^0.1.10",
"@openzeppelin/test-environment": "^0.1.5",
"@openzeppelin/test-helpers": "^0.5.6",
"@openzeppelin/test-helpers": "^0.5.9",
"chai": "^4.2.0",
"eslint": "^6.5.1",
"eslint-config-standard": "^14.1.1",
@@ -68,7 +69,7 @@
"mocha": "^8.0.1",
"rimraf": "^3.0.2",
"solhint": "^3.2.0",
"solidity-coverage": "^0.7.8",
"solidity-coverage": "^0.7.11",
"solidity-docgen": "^0.5.3"
},
"dependencies": {}

View File

@@ -1,9 +0,0 @@
#!/usr/bin/env sh
if [ "$SOLC_NIGHTLY" = true ]; then
docker pull ethereum/solc:nightly
fi
export OPENZEPPELIN_NON_INTERACTIVE=true
npx oz compile

View File

@@ -1,21 +0,0 @@
#!/usr/bin/env node
const { execSync } = require('child_process');
const { runCoverage } = require('@openzeppelin/test-environment');
async function main () {
await runCoverage(
['mocks'],
'npm run compile',
'./node_modules/.bin/mocha --exit --timeout 10000 --recursive'.split(' '),
);
if (process.env.CI) {
execSync('curl -s https://codecov.io/bash | bash -s -- -C "$CIRCLE_SHA1"', { stdio: 'inherit' });
}
}
main().catch(e => {
console.error(e);
process.exit(1);
});

9
scripts/coverage.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/usr/bin/env bash
set -euo pipefail
buidler coverage
if [ -n "$CI" ]; then
curl -s https://codecov.io/bash | bash -s -- -C "$CIRCLE_SHA1"
fi

10
scripts/prepack.sh Executable file
View File

@@ -0,0 +1,10 @@
#!/usr/bin/env bash
set -euo pipefail
# cross platform `mkdir -p`
node -e 'fs.mkdirSync("build/contracts", { recursive: true })'
cp artifacts/*.json build/contracts
node scripts/remove-ignored-artifacts.js

0
scripts/prepare-contracts-package.sh Normal file → Executable file
View File

View File

@@ -23,20 +23,19 @@ const ignorePatternsSubtrees = ignorePatterns
.concat(ignorePatterns.map(pat => path.join(pat, '**/*')))
.map(p => p.replace(/^\//, ''));
const solcOutput = readJSON('cache/solc-output.json');
const artifactsDir = 'build/contracts';
let n = 0;
for (const artifact of fs.readdirSync(artifactsDir)) {
const fullArtifactPath = path.join(artifactsDir, artifact);
const { sourcePath: fullSourcePath } = readJSON(fullArtifactPath);
const sourcePath = path.relative('.', fullSourcePath);
for (const sourcePath in solcOutput.contracts) {
const ignore = match.any(sourcePath, ignorePatternsSubtrees);
if (ignore) {
fs.unlinkSync(fullArtifactPath);
n += 1;
for (const contract in solcOutput.contracts[sourcePath]) {
fs.unlinkSync(path.join(artifactsDir, contract + '.json'));
n += 1;
}
}
}

View File

@@ -1,22 +0,0 @@
const { GSNDevProvider } = require('@openzeppelin/gsn-provider');
module.exports = {
accounts: {
ether: 1e6,
},
contracts: {
type: 'truffle',
},
setupProvider: (baseProvider) => {
const { accounts } = require('@openzeppelin/test-environment');
return new GSNDevProvider(baseProvider, {
txfee: 70,
useGSN: false,
ownerAddress: accounts[8],
relayerAddress: accounts[9],
});
},
};

View File

@@ -1,8 +1,6 @@
const { contract } = require('@openzeppelin/test-environment');
const { BN, expectEvent } = require('@openzeppelin/test-helpers');
const ContextMock = contract.fromArtifact('ContextMock');
const ContextMock = artifacts.require('ContextMock');
function shouldBehaveLikeRegularContext (sender) {
describe('msgSender', function () {

View File

@@ -1,13 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
require('@openzeppelin/test-helpers');
const ContextMock = contract.fromArtifact('ContextMock');
const ContextMockCaller = contract.fromArtifact('ContextMockCaller');
const ContextMock = artifacts.require('ContextMock');
const ContextMockCaller = artifacts.require('ContextMockCaller');
const { shouldBehaveLikeRegularContext } = require('./Context.behavior');
describe('Context', function () {
contract('Context', function (accounts) {
const [ sender ] = accounts;
beforeEach(async function () {

View File

@@ -1,20 +1,23 @@
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const { constants, expectEvent } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const gsn = require('@openzeppelin/gsn-helpers');
const { fixSignature } = require('../helpers/sign');
const { setGSNProvider } = require('../helpers/set-gsn-provider');
const { utils: { toBN } } = require('web3');
const ERC721GSNRecipientMock = contract.fromArtifact('ERC721GSNRecipientMock');
const ERC721GSNRecipientMock = artifacts.require('ERC721GSNRecipientMock');
describe('ERC721GSNRecipient (integration)', function () {
contract('ERC721GSNRecipient (integration)', function (accounts) {
const [ signer, sender ] = accounts;
const name = 'Non Fungible Token';
const symbol = 'NFT';
const tokenId = '42';
before(function () {
setGSNProvider(ERC721GSNRecipientMock, accounts);
});
beforeEach(async function () {
this.token = await ERC721GSNRecipientMock.new(name, symbol, signer);
});

View File

@@ -1,20 +1,24 @@
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const { balance, BN, constants, ether, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const gsn = require('@openzeppelin/gsn-helpers');
const { setGSNProvider } = require('../helpers/set-gsn-provider');
const { expect } = require('chai');
const GSNRecipientMock = contract.fromArtifact('GSNRecipientMock');
const ContextMockCaller = contract.fromArtifact('ContextMockCaller');
const GSNRecipientMock = artifacts.require('GSNRecipientMock');
const ContextMockCaller = artifacts.require('ContextMockCaller');
const { shouldBehaveLikeRegularContext } = require('./Context.behavior');
describe('GSNRecipient', function () {
contract('GSNRecipient', function (accounts) {
const [ payee, sender, newRelayHub ] = accounts;
before(function () {
setGSNProvider(GSNRecipientMock, accounts);
setGSNProvider(ContextMockCaller, accounts);
});
beforeEach(async function () {
this.recipient = await GSNRecipientMock.new();
});

View File

@@ -1,20 +1,25 @@
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const { ether, expectEvent } = require('@openzeppelin/test-helpers');
const gsn = require('@openzeppelin/gsn-helpers');
const { setGSNProvider } = require('../helpers/set-gsn-provider');
const { expect } = require('chai');
const GSNRecipientERC20FeeMock = contract.fromArtifact('GSNRecipientERC20FeeMock');
const ERC20 = contract.fromArtifact('ERC20');
const IRelayHub = contract.fromArtifact('IRelayHub');
const GSNRecipientERC20FeeMock = artifacts.require('GSNRecipientERC20FeeMock');
const ERC20 = artifacts.require('ERC20');
const IRelayHub = artifacts.require('IRelayHub');
describe('GSNRecipientERC20Fee', function () {
contract('GSNRecipientERC20Fee', function (accounts) {
const [ sender ] = accounts;
const name = 'FeeToken';
const symbol = 'FTKN';
before(function () {
setGSNProvider(GSNRecipientERC20FeeMock, accounts);
setGSNProvider(ERC20, accounts);
setGSNProvider(IRelayHub, accounts);
});
beforeEach(async function () {
this.recipient = await GSNRecipientERC20FeeMock.new(name, symbol);
this.token = await ERC20.at(await this.recipient.token());

View File

@@ -1,16 +1,19 @@
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const { expectEvent, expectRevert, constants } = require('@openzeppelin/test-helpers');
const gsn = require('@openzeppelin/gsn-helpers');
const { fixSignature } = require('../helpers/sign');
const { setGSNProvider } = require('../helpers/set-gsn-provider');
const { utils: { toBN } } = require('web3');
const { ZERO_ADDRESS } = constants;
const GSNRecipientSignatureMock = contract.fromArtifact('GSNRecipientSignatureMock');
const GSNRecipientSignatureMock = artifacts.require('GSNRecipientSignatureMock');
describe('GSNRecipientSignature', function () {
contract('GSNRecipientSignature', function (accounts) {
const [ signer, other ] = accounts;
before(function () {
setGSNProvider(GSNRecipientSignatureMock, accounts);
});
beforeEach(async function () {
this.recipient = await GSNRecipientSignatureMock.new(signer);
});

View File

@@ -1,12 +1,10 @@
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const AccessControlMock = contract.fromArtifact('AccessControlMock');
const AccessControlMock = artifacts.require('AccessControlMock');
describe('AccessControl', function () {
contract('AccessControl', function (accounts) {
const [ admin, authorized, otherAuthorized, other, otherAdmin ] = accounts;
const DEFAULT_ADMIN_ROLE = '0x0000000000000000000000000000000000000000000000000000000000000000';

View File

@@ -1,12 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const Ownable = contract.fromArtifact('OwnableMock');
const Ownable = artifacts.require('OwnableMock');
describe('Ownable', function () {
contract('Ownable', function (accounts) {
const [ owner, other ] = accounts;
beforeEach(async function () {

View File

@@ -1,12 +1,11 @@
const { accounts, contract, web3, config } = require('@openzeppelin/test-environment');
const { constants, expectEvent, expectRevert, time } = require('@openzeppelin/test-helpers');
const { ZERO_BYTES32 } = constants;
const { expect } = require('chai');
const TimelockController = contract.fromArtifact('TimelockController');
const CallReceiverMock = contract.fromArtifact('CallReceiverMock');
const Implementation2 = contract.fromArtifact('Implementation2');
const TimelockController = artifacts.require('TimelockController');
const CallReceiverMock = artifacts.require('CallReceiverMock');
const Implementation2 = artifacts.require('Implementation2');
const MINDELAY = time.duration.days(1);
function genOperation (target, value, data, predecessor, salt) {
@@ -43,7 +42,7 @@ function genOperationBatch (targets, values, datas, predecessor, salt) {
return { id, targets, values, datas, predecessor, salt };
}
describe('TimelockController', function () {
contract('TimelockController', function (accounts) {
const [ admin, proposer, executor, other ] = accounts;
beforeEach(async function () {
@@ -247,7 +246,7 @@ describe('TimelockController', function () {
it('revert if execution comes too early 2/2', async function () {
const timestamp = await this.timelock.getTimestamp(this.operation.id);
await time.increaseTo(timestamp - 2); // -1 is too tight, test sometime fails
await time.increaseTo(timestamp - 5); // -1 is too tight, test sometime fails
await expectRevert(
this.timelock.execute(
@@ -454,7 +453,7 @@ describe('TimelockController', function () {
it('revert if execution comes too early 2/2', async function () {
const timestamp = await this.timelock.getTimestamp(this.operation.id);
await time.increaseTo(timestamp - 2); // -1 is to tight, test sometime fails
await time.increaseTo(timestamp - 5); // -1 is to tight, test sometime fails
await expectRevert(
this.timelock.executeBatch(
@@ -844,11 +843,7 @@ describe('TimelockController', function () {
);
});
// Skipped in a coverage mode due to coverage mode setting a block gas limit to 0xffffffffff
// which cause a mockFunctionOutOfGas function to crash Ganache and the
// subsequent tests before running out of gas.
it('call out of gas', async function () {
if (config.coverage) { return this.skip(); }
const operation = genOperation(
this.callreceivermock.address,
0,
@@ -874,7 +869,7 @@ describe('TimelockController', function () {
operation.data,
operation.predecessor,
operation.salt,
{ from: executor },
{ from: executor, gas: '70000' },
),
'TimelockController: underlying transaction reverted',
);

View File

@@ -1,16 +1,14 @@
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const { expectRevert } = require('@openzeppelin/test-helpers');
const { toEthSignedMessageHash, fixSignature } = require('../helpers/sign');
const { expect } = require('chai');
const ECDSAMock = contract.fromArtifact('ECDSAMock');
const ECDSAMock = artifacts.require('ECDSAMock');
const TEST_MESSAGE = web3.utils.sha3('OpenZeppelin');
const WRONG_MESSAGE = web3.utils.sha3('Nope');
describe('ECDSA', function () {
contract('ECDSA', function (accounts) {
const [ other ] = accounts;
beforeEach(async function () {

View File

@@ -1,5 +1,3 @@
const { contract } = require('@openzeppelin/test-environment');
require('@openzeppelin/test-helpers');
const { MerkleTree } = require('../helpers/merkleTree.js');
@@ -7,9 +5,9 @@ const { keccakFromString, bufferToHex } = require('ethereumjs-util');
const { expect } = require('chai');
const MerkleProofWrapper = contract.fromArtifact('MerkleProofWrapper');
const MerkleProofWrapper = artifacts.require('MerkleProofWrapper');
describe('MerkleProof', function () {
contract('MerkleProof', function (accounts) {
beforeEach(async function () {
this.merkleProof = await MerkleProofWrapper.new();
});

View File

@@ -0,0 +1,15 @@
const { GSNDevProvider } = require('@openzeppelin/gsn-provider');
function setGSNProvider (Contract, accounts) {
const baseProvider = Contract.currentProvider;
Contract.setProvider(
new GSNDevProvider(baseProvider, {
txfee: 70,
useGSN: false,
ownerAddress: accounts[8],
relayerAddress: accounts[9],
}),
);
};
module.exports = { setGSNProvider };

View File

@@ -1,5 +1,3 @@
const { web3 } = require('@openzeppelin/test-environment');
function toEthSignedMessageHash (messageHex) {
const messageBuffer = Buffer.from(messageHex.substring(2), 'hex');
const prefix = Buffer.from(`\u0019Ethereum Signed Message:\n${messageBuffer.length}`);

View File

@@ -1,11 +1,10 @@
const { contract } = require('@openzeppelin/test-environment');
const { expectRevert } = require('@openzeppelin/test-helpers');
const { shouldSupportInterfaces } = require('./SupportsInterface.behavior');
const ERC165Mock = contract.fromArtifact('ERC165Mock');
const ERC165Mock = artifacts.require('ERC165Mock');
describe('ERC165', function () {
contract('ERC165', function (accounts) {
beforeEach(async function () {
this.mock = await ERC165Mock.new();
});

View File

@@ -1,11 +1,10 @@
const { contract } = require('@openzeppelin/test-environment');
require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ERC165CheckerMock = contract.fromArtifact('ERC165CheckerMock');
const ERC165NotSupported = contract.fromArtifact('ERC165NotSupported');
const ERC165InterfacesSupported = contract.fromArtifact('ERC165InterfacesSupported');
const ERC165CheckerMock = artifacts.require('ERC165CheckerMock');
const ERC165NotSupported = artifacts.require('ERC165NotSupported');
const ERC165InterfacesSupported = artifacts.require('ERC165InterfacesSupported');
const DUMMY_ID = '0xdeadbeef';
const DUMMY_ID_2 = '0xcafebabe';
@@ -14,7 +13,7 @@ const DUMMY_UNSUPPORTED_ID = '0xbaddcafe';
const DUMMY_UNSUPPORTED_ID_2 = '0xbaadcafe';
const DUMMY_ACCOUNT = '0x1111111111111111111111111111111111111111';
describe('ERC165Checker', function () {
contract('ERC165Checker', function (accounts) {
beforeEach(async function () {
this.mock = await ERC165CheckerMock.new();
});

View File

@@ -1,13 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { expectRevert, singletons } = require('@openzeppelin/test-helpers');
const { bufferToHex, keccakFromString } = require('ethereumjs-util');
const { expect } = require('chai');
const ERC1820ImplementerMock = contract.fromArtifact('ERC1820ImplementerMock');
const ERC1820ImplementerMock = artifacts.require('ERC1820ImplementerMock');
describe('ERC1820Implementer', function () {
contract('ERC1820Implementer', function (accounts) {
const [ registryFunder, implementee, other ] = accounts;
const ERC1820_ACCEPT_MAGIC = bufferToHex(keccakFromString('ERC1820_ACCEPT_MAGIC'));

View File

@@ -1,11 +1,10 @@
const { contract } = require('@openzeppelin/test-environment');
const { BN } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const MathMock = contract.fromArtifact('MathMock');
const MathMock = artifacts.require('MathMock');
describe('Math', function () {
contract('Math', function (accounts) {
const min = new BN('1234');
const max = new BN('5678');

View File

@@ -1,12 +1,11 @@
const { contract } = require('@openzeppelin/test-environment');
const { BN, constants, expectRevert } = require('@openzeppelin/test-helpers');
const { MAX_UINT256 } = constants;
const { expect } = require('chai');
const SafeMathMock = contract.fromArtifact('SafeMathMock');
const SafeMathMock = artifacts.require('SafeMathMock');
describe('SafeMath', function () {
contract('SafeMath', function (accounts) {
beforeEach(async function () {
this.safeMath = await SafeMathMock.new();
});

View File

@@ -1,13 +1,11 @@
const { contract } = require('@openzeppelin/test-environment');
const { BN, constants, expectRevert } = require('@openzeppelin/test-helpers');
const { MAX_INT256, MIN_INT256 } = constants;
const { expect } = require('chai');
const SignedSafeMathMock = contract.fromArtifact('SignedSafeMathMock');
const SignedSafeMathMock = artifacts.require('SignedSafeMathMock');
describe('SignedSafeMath', function () {
contract('SignedSafeMath', function (accounts) {
beforeEach(async function () {
this.safeMath = await SignedSafeMathMock.new();
});

View File

@@ -1,13 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { balance, constants, ether, expectEvent, send, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const PaymentSplitter = contract.fromArtifact('PaymentSplitter');
const PaymentSplitter = artifacts.require('PaymentSplitter');
describe('PaymentSplitter', function () {
contract('PaymentSplitter', function (accounts) {
const [ owner, payee1, payee2, payee3, nonpayee1, payer1 ] = accounts;
const amount = ether('1');

View File

@@ -1,12 +1,10 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { balance, ether } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const PullPaymentMock = contract.fromArtifact('PullPaymentMock');
const PullPaymentMock = artifacts.require('PullPaymentMock');
describe('PullPayment', function () {
contract('PullPayment', function (accounts) {
const [ payer, payee1, payee2 ] = accounts;
const amount = ether('17');

View File

@@ -1,11 +1,9 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { ether, expectRevert } = require('@openzeppelin/test-helpers');
const { shouldBehaveLikeEscrow } = require('./Escrow.behavior');
const ConditionalEscrowMock = contract.fromArtifact('ConditionalEscrowMock');
const ConditionalEscrowMock = artifacts.require('ConditionalEscrowMock');
describe('ConditionalEscrow', function () {
contract('ConditionalEscrow', function (accounts) {
const [ owner, payee, ...otherAccounts ] = accounts;
beforeEach(async function () {

View File

@@ -1,11 +1,9 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
require('@openzeppelin/test-helpers');
const { shouldBehaveLikeEscrow } = require('./Escrow.behavior');
const Escrow = contract.fromArtifact('Escrow');
const Escrow = artifacts.require('Escrow');
describe('Escrow', function () {
contract('Escrow', function (accounts) {
const [ owner, ...otherAccounts ] = accounts;
beforeEach(async function () {

View File

@@ -1,13 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { balance, constants, ether, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const RefundEscrow = contract.fromArtifact('RefundEscrow');
const RefundEscrow = artifacts.require('RefundEscrow');
describe('RefundEscrow', function () {
contract('RefundEscrow', function (accounts) {
const [ owner, beneficiary, refundee1, refundee2 ] = accounts;
const amount = ether('54');

View File

@@ -1,13 +1,11 @@
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const ERC1155PresetMinterPauser = contract.fromArtifact('ERC1155PresetMinterPauser');
const ERC1155PresetMinterPauser = artifacts.require('ERC1155PresetMinterPauser');
describe('ERC1155PresetMinterPauser', function () {
contract('ERC1155PresetMinterPauser', function (accounts) {
const [ deployer, other ] = accounts;
const firstTokenId = new BN('845');

View File

@@ -1,13 +1,11 @@
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const ERC20PresetMinterPauser = contract.fromArtifact('ERC20PresetMinterPauser');
const ERC20PresetMinterPauser = artifacts.require('ERC20PresetMinterPauser');
describe('ERC20PresetMinterPauser', function () {
contract('ERC20PresetMinterPauser', function (accounts) {
const [ deployer, other ] = accounts;
const name = 'MinterPauserToken';

View File

@@ -1,13 +1,11 @@
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const ERC721PresetMinterPauserAutoId = contract.fromArtifact('ERC721PresetMinterPauserAutoId');
const ERC721PresetMinterPauserAutoId = artifacts.require('ERC721PresetMinterPauserAutoId');
describe('ERC721PresetMinterPauserAutoId', function () {
contract('ERC721PresetMinterPauserAutoId', function (accounts) {
const [ deployer, other ] = accounts;
const name = 'MinterAutoIDToken';

View File

@@ -1,13 +1,11 @@
const { contract } = require('@openzeppelin/test-environment');
const { expectRevert } = require('@openzeppelin/test-helpers');
const { assert } = require('chai');
const InitializableMock = contract.fromArtifact('InitializableMock');
const SampleChild = contract.fromArtifact('SampleChild');
const InitializableMock = artifacts.require('InitializableMock');
const SampleChild = artifacts.require('SampleChild');
describe('Initializable', function () {
contract('Initializable', function (accounts) {
describe('basic testing without inheritance', function () {
beforeEach('deploying', async function () {
this.contract = await InitializableMock.new();

View File

@@ -1,15 +1,13 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ImplV1 = contract.fromArtifact('DummyImplementation');
const ImplV2 = contract.fromArtifact('DummyImplementationV2');
const ProxyAdmin = contract.fromArtifact('ProxyAdmin');
const TransparentUpgradeableProxy = contract.fromArtifact('TransparentUpgradeableProxy');
const ImplV1 = artifacts.require('DummyImplementation');
const ImplV2 = artifacts.require('DummyImplementationV2');
const ProxyAdmin = artifacts.require('ProxyAdmin');
const TransparentUpgradeableProxy = artifacts.require('TransparentUpgradeableProxy');
describe('ProxyAdmin', function () {
contract('ProxyAdmin', function (accounts) {
const [proxyAdminOwner, newAdmin, anotherAccount] = accounts;
before('set implementations', async function () {

View File

@@ -1,22 +1,20 @@
const { contract, web3 } = require('@openzeppelin/test-environment');
const { BN, expectRevert, expectEvent, constants } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { toChecksumAddress, keccak256 } = require('ethereumjs-util');
const { expect } = require('chai');
const Proxy = contract.fromArtifact('Proxy');
const Implementation1 = contract.fromArtifact('Implementation1');
const Implementation2 = contract.fromArtifact('Implementation2');
const Implementation3 = contract.fromArtifact('Implementation3');
const Implementation4 = contract.fromArtifact('Implementation4');
const MigratableMockV1 = contract.fromArtifact('MigratableMockV1');
const MigratableMockV2 = contract.fromArtifact('MigratableMockV2');
const MigratableMockV3 = contract.fromArtifact('MigratableMockV3');
const InitializableMock = contract.fromArtifact('InitializableMock');
const DummyImplementation = contract.fromArtifact('DummyImplementation');
const ClashingImplementation = contract.fromArtifact('ClashingImplementation');
const Proxy = artifacts.require('Proxy');
const Implementation1 = artifacts.require('Implementation1');
const Implementation2 = artifacts.require('Implementation2');
const Implementation3 = artifacts.require('Implementation3');
const Implementation4 = artifacts.require('Implementation4');
const MigratableMockV1 = artifacts.require('MigratableMockV1');
const MigratableMockV2 = artifacts.require('MigratableMockV2');
const MigratableMockV3 = artifacts.require('MigratableMockV3');
const InitializableMock = artifacts.require('InitializableMock');
const DummyImplementation = artifacts.require('DummyImplementation');
const ClashingImplementation = artifacts.require('ClashingImplementation');
const IMPLEMENTATION_LABEL = 'eip1967.proxy.implementation';
const ADMIN_LABEL = 'eip1967.proxy.admin';
@@ -409,7 +407,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
await proxy.upgradeTo(instance4.address, { from: proxyAdminAddress });
const proxyInstance4 = new Implementation4(proxy.address);
const data = '';
const data = '0x';
await web3.eth.sendTransaction({ to: proxy.address, from: anotherAccount, data });
const res = await proxyInstance4.getValue();
@@ -423,7 +421,7 @@ module.exports = function shouldBehaveLikeTransparentUpgradeableProxy (createPro
const instance2 = await Implementation2.new();
await proxy.upgradeTo(instance2.address, { from: proxyAdminAddress });
const data = '';
const data = '0x';
await expectRevert.unspecified(
web3.eth.sendTransaction({ to: proxy.address, from: anotherAccount, data }),
);

View File

@@ -1,11 +1,9 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const shouldBehaveLikeUpgradeableProxy = require('./UpgradeableProxy.behaviour');
const shouldBehaveLikeTransparentUpgradeableProxy = require('./TransparentUpgradeableProxy.behaviour');
const TransparentUpgradeableProxy = contract.fromArtifact('TransparentUpgradeableProxy');
const TransparentUpgradeableProxy = artifacts.require('TransparentUpgradeableProxy');
describe('TransparentUpgradeableProxy', function () {
contract('TransparentUpgradeableProxy', function (accounts) {
const [proxyAdminAddress, proxyAdminOwner] = accounts;
const createProxy = async function (logic, admin, initData, opts) {

View File

@@ -1,11 +1,9 @@
const { contract, web3 } = require('@openzeppelin/test-environment');
const { BN, expectRevert } = require('@openzeppelin/test-helpers');
const { toChecksumAddress, keccak256 } = require('ethereumjs-util');
const { expect } = require('chai');
const DummyImplementation = contract.fromArtifact('DummyImplementation');
const DummyImplementation = artifacts.require('DummyImplementation');
const IMPLEMENTATION_LABEL = 'eip1967.proxy.implementation';

View File

@@ -1,10 +1,8 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const shouldBehaveLikeUpgradeableProxy = require('./UpgradeableProxy.behaviour');
const UpgradeableProxy = contract.fromArtifact('UpgradeableProxy');
const UpgradeableProxy = artifacts.require('UpgradeableProxy');
describe('UpgradeableProxy', function () {
contract('UpgradeableProxy', function (accounts) {
const [proxyAdminOwner] = accounts;
const createProxy = async function (implementation, _admin, initData, opts) {

View File

@@ -1,6 +1,6 @@
const { defaultSender, web3 } = require('@openzeppelin/test-environment');
const { deployRelayHub } = require('@openzeppelin/gsn-helpers');
before('deploy GSN RelayHub', async function () {
const [defaultSender] = await web3.eth.getAccounts();
await deployRelayHub(web3, { from: defaultSender });
});

View File

@@ -1,5 +1,3 @@
const { contract } = require('@openzeppelin/test-environment');
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
@@ -7,7 +5,7 @@ const { expect } = require('chai');
const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
const ERC1155ReceiverMock = contract.fromArtifact('ERC1155ReceiverMock');
const ERC1155ReceiverMock = artifacts.require('ERC1155ReceiverMock');
function shouldBehaveLikeERC1155 ([minter, firstTokenHolder, secondTokenHolder, multiTokenHolder, recipient, proxy]) {
const firstTokenId = new BN(1);

View File

@@ -1,14 +1,12 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const { shouldBehaveLikeERC1155 } = require('./ERC1155.behavior');
const ERC1155Mock = contract.fromArtifact('ERC1155Mock');
const ERC1155Mock = artifacts.require('ERC1155Mock');
describe('ERC1155', function () {
contract('ERC1155', function (accounts) {
const [operator, tokenHolder, tokenBatchHolder, ...otherAccounts] = accounts;
const initialURI = 'https://token-cdn-domain/{id}.json';

View File

@@ -1,12 +1,10 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ERC1155BurnableMock = contract.fromArtifact('ERC1155BurnableMock');
const ERC1155BurnableMock = artifacts.require('ERC1155BurnableMock');
describe('ERC1155Burnable', function () {
contract('ERC1155Burnable', function (accounts) {
const [ holder, operator, other ] = accounts;
const uri = 'https://token.com';

View File

@@ -1,14 +1,13 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN } = require('@openzeppelin/test-helpers');
const ERC1155Holder = contract.fromArtifact('ERC1155Holder');
const ERC1155Mock = contract.fromArtifact('ERC1155Mock');
const ERC1155Holder = artifacts.require('ERC1155Holder');
const ERC1155Mock = artifacts.require('ERC1155Mock');
const { expect } = require('chai');
const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
describe('ERC1155Holder', function () {
contract('ERC1155Holder', function (accounts) {
const [creator] = accounts;
const uri = 'https://token-cdn-domain/{id}.json';
const multiTokenIds = [new BN(1), new BN(2), new BN(3)];

View File

@@ -1,12 +1,10 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ERC1155PausableMock = contract.fromArtifact('ERC1155PausableMock');
const ERC1155PausableMock = artifacts.require('ERC1155PausableMock');
describe('ERC1155Pausable', function () {
contract('ERC1155Pausable', function (accounts) {
const [ holder, operator, receiver, other ] = accounts;
const uri = 'https://token.com';

View File

@@ -1,5 +1,3 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const { ZERO_ADDRESS } = constants;
@@ -10,10 +8,10 @@ const {
shouldBehaveLikeERC20Approve,
} = require('./ERC20.behavior');
const ERC20Mock = contract.fromArtifact('ERC20Mock');
const ERC20DecimalsMock = contract.fromArtifact('ERC20DecimalsMock');
const ERC20Mock = artifacts.require('ERC20Mock');
const ERC20DecimalsMock = artifacts.require('ERC20DecimalsMock');
describe('ERC20', function () {
contract('ERC20', function (accounts) {
const [ initialHolder, recipient, anotherAccount ] = accounts;
const name = 'My Token';

View File

@@ -1,11 +1,9 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN } = require('@openzeppelin/test-helpers');
const { shouldBehaveLikeERC20Burnable } = require('./behaviors/ERC20Burnable.behavior');
const ERC20BurnableMock = contract.fromArtifact('ERC20BurnableMock');
const ERC20BurnableMock = artifacts.require('ERC20BurnableMock');
describe('ERC20Burnable', function () {
contract('ERC20Burnable', function (accounts) {
const [ owner, ...otherAccounts ] = accounts;
const initialBalance = new BN(1000);

View File

@@ -1,11 +1,9 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, ether, expectRevert } = require('@openzeppelin/test-helpers');
const { shouldBehaveLikeERC20Capped } = require('./behaviors/ERC20Capped.behavior');
const ERC20Capped = contract.fromArtifact('ERC20CappedMock');
const ERC20Capped = artifacts.require('ERC20CappedMock');
describe('ERC20Capped', function () {
contract('ERC20Capped', function (accounts) {
const [ minter, ...otherAccounts ] = accounts;
const cap = ether('1000');

View File

@@ -1,12 +1,10 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ERC20PausableMock = contract.fromArtifact('ERC20PausableMock');
const ERC20PausableMock = artifacts.require('ERC20PausableMock');
describe('ERC20Pausable', function () {
contract('ERC20Pausable', function (accounts) {
const [ holder, recipient, anotherAccount ] = accounts;
const initialSupply = new BN(100);

View File

@@ -1,11 +1,9 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const ERC20SnapshotMock = contract.fromArtifact('ERC20SnapshotMock');
const ERC20SnapshotMock = artifacts.require('ERC20SnapshotMock');
const { expect } = require('chai');
describe('ERC20Snapshot', function () {
contract('ERC20Snapshot', function (accounts) {
const [ initialHolder, recipient, other ] = accounts;
const initialSupply = new BN(100);

View File

@@ -1,13 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { expectRevert } = require('@openzeppelin/test-helpers');
const ERC20ReturnFalseMock = contract.fromArtifact('ERC20ReturnFalseMock');
const ERC20ReturnTrueMock = contract.fromArtifact('ERC20ReturnTrueMock');
const ERC20NoReturnMock = contract.fromArtifact('ERC20NoReturnMock');
const SafeERC20Wrapper = contract.fromArtifact('SafeERC20Wrapper');
const ERC20ReturnFalseMock = artifacts.require('ERC20ReturnFalseMock');
const ERC20ReturnTrueMock = artifacts.require('ERC20ReturnTrueMock');
const ERC20NoReturnMock = artifacts.require('ERC20NoReturnMock');
const SafeERC20Wrapper = artifacts.require('SafeERC20Wrapper');
describe('SafeERC20', function () {
contract('SafeERC20', function (accounts) {
const [ hasNoCode ] = accounts;
describe('with address that has no contract code', function () {

View File

@@ -1,13 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, expectRevert, time } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ERC20Mock = contract.fromArtifact('ERC20Mock');
const TokenTimelock = contract.fromArtifact('TokenTimelock');
const ERC20Mock = artifacts.require('ERC20Mock');
const TokenTimelock = artifacts.require('TokenTimelock');
describe('TokenTimelock', function () {
contract('TokenTimelock', function (accounts) {
const [ beneficiary ] = accounts;
const name = 'My Token';

View File

@@ -1,5 +1,3 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
@@ -7,10 +5,10 @@ const { expect } = require('chai');
const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
const ERC721Mock = contract.fromArtifact('ERC721Mock');
const ERC721ReceiverMock = contract.fromArtifact('ERC721ReceiverMock');
const ERC721Mock = artifacts.require('ERC721Mock');
const ERC721ReceiverMock = artifacts.require('ERC721ReceiverMock');
describe('ERC721', function () {
contract('ERC721', function (accounts) {
const [owner, newOwner, approved, anotherApproved, operator, other] = accounts;
const name = 'Non Fungible Token';

View File

@@ -1,13 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const ERC721BurnableMock = contract.fromArtifact('ERC721BurnableMock');
const ERC721BurnableMock = artifacts.require('ERC721BurnableMock');
describe('ERC721Burnable', function () {
contract('ERC721Burnable', function (accounts) {
const [owner, approved] = accounts;
const firstTokenId = new BN(1);

View File

@@ -1,13 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ERC721Holder = contract.fromArtifact('ERC721Holder');
const ERC721Mock = contract.fromArtifact('ERC721Mock');
const ERC721Holder = artifacts.require('ERC721Holder');
const ERC721Mock = artifacts.require('ERC721Mock');
describe('ERC721Holder', function () {
contract('ERC721Holder', function (accounts) {
const [ owner ] = accounts;
const name = 'Non Fungible Token';

View File

@@ -1,13 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, constants, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const ERC721PausableMock = contract.fromArtifact('ERC721PausableMock');
const ERC721PausableMock = artifacts.require('ERC721PausableMock');
describe('ERC721Pausable', function () {
contract('ERC721Pausable', function (accounts) {
const [ owner, receiver, operator ] = accounts;
const name = 'Non Fungible Token';

View File

@@ -1,10 +1,9 @@
const { contract, web3 } = require('@openzeppelin/test-environment');
const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
const { expect } = require('chai');
const ERC777SenderRecipientMock = contract.fromArtifact('ERC777SenderRecipientMock');
const ERC777SenderRecipientMock = artifacts.require('ERC777SenderRecipientMock');
function shouldBehaveLikeERC777DirectSendBurn (holder, recipient, data) {
shouldBehaveLikeERC777DirectSend(holder, recipient, data);

View File

@@ -1,5 +1,3 @@
const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
const { BN, constants, expectEvent, expectRevert, singletons } = require('@openzeppelin/test-helpers');
const { ZERO_ADDRESS } = constants;
@@ -19,10 +17,10 @@ const {
shouldBehaveLikeERC20Approve,
} = require('../ERC20/ERC20.behavior');
const ERC777 = contract.fromArtifact('ERC777Mock');
const ERC777SenderRecipientMock = contract.fromArtifact('ERC777SenderRecipientMock');
const ERC777 = artifacts.require('ERC777Mock');
const ERC777SenderRecipientMock = artifacts.require('ERC777SenderRecipientMock');
describe('ERC777', function () {
contract('ERC777', function (accounts) {
const [ registryFunder, holder, defaultOperatorA, defaultOperatorB, newOperator, anyone ] = accounts;
const initialSupply = new BN('10000');

View File

@@ -1,15 +1,11 @@
const { accounts, contract, web3, config } = require('@openzeppelin/test-environment');
const { balance, ether, expectRevert, send, expectEvent } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const AddressImpl = contract.fromArtifact('AddressImpl');
const EtherReceiver = contract.fromArtifact('EtherReceiverMock');
const CallReceiverMock = contract.fromArtifact('CallReceiverMock');
const AddressImpl = artifacts.require('AddressImpl');
const EtherReceiver = artifacts.require('EtherReceiverMock');
const CallReceiverMock = artifacts.require('CallReceiverMock');
const coverage = config.coverage;
describe('Address', function () {
contract('Address', function (accounts) {
const [ recipient, other ] = accounts;
beforeEach(async function () {
@@ -139,12 +135,7 @@ describe('Address', function () {
);
});
// Skipped in a coverage mode due to coverage mode setting a block gas limit to 0xffffffffff
// which cause a mockFunctionOutOfGas function to crash Ganache and the
// subsequent tests before running out of gas.
it('reverts when the called function runs out of gas', async function () {
this.timeout(10000);
if (coverage) { return this.skip(); }
const abiEncodedCall = web3.eth.abi.encodeFunctionCall({
name: 'mockFunctionOutOfGas',
type: 'function',
@@ -152,7 +143,7 @@ describe('Address', function () {
}, []);
await expectRevert(
this.mock.functionCall(this.contractRecipient.address, abiEncodedCall),
this.mock.functionCall(this.contractRecipient.address, abiEncodedCall, { gas: '90000' }),
'Address: low-level call failed',
);
});

View File

@@ -1,11 +1,10 @@
const { contract } = require('@openzeppelin/test-environment');
require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ArraysImpl = contract.fromArtifact('ArraysImpl');
const ArraysImpl = artifacts.require('ArraysImpl');
describe('Arrays', function () {
contract('Arrays', function (accounts) {
describe('findUpperBound', function () {
context('Even number of elements', function () {
const EVEN_ELEMENTS_ARRAY = [11, 12, 13, 14, 15, 16, 17, 18, 19, 20];

View File

@@ -1,11 +1,10 @@
const { contract } = require('@openzeppelin/test-environment');
const { expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const CountersImpl = contract.fromArtifact('CountersImpl');
const CountersImpl = artifacts.require('CountersImpl');
describe('Counters', function () {
contract('Counters', function (accounts) {
beforeEach(async function () {
this.counter = await CountersImpl.new();
});

View File

@@ -1,13 +1,12 @@
const { contract, accounts, web3 } = require('@openzeppelin/test-environment');
const { balance, BN, ether, expectRevert, send } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const Create2Impl = contract.fromArtifact('Create2Impl');
const ERC20Mock = contract.fromArtifact('ERC20Mock');
const ERC1820Implementer = contract.fromArtifact('ERC1820Implementer');
const Create2Impl = artifacts.require('Create2Impl');
const ERC20Mock = artifacts.require('ERC20Mock');
const ERC1820Implementer = artifacts.require('ERC1820Implementer');
describe('Create2', function () {
contract('Create2', function (accounts) {
const [deployerAccount] = accounts;
const salt = 'salt message';

View File

@@ -1,12 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN, expectEvent } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const zip = require('lodash.zip');
const EnumerableMapMock = contract.fromArtifact('EnumerableMapMock');
const EnumerableMapMock = artifacts.require('EnumerableMapMock');
describe('EnumerableMap', function () {
contract('EnumerableMap', function (accounts) {
const [ accountA, accountB, accountC ] = accounts;
const keyA = new BN('7891');

View File

@@ -1,12 +1,11 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { BN } = require('@openzeppelin/test-helpers');
const EnumerableAddressSetMock = contract.fromArtifact('EnumerableAddressSetMock');
const EnumerableUintSetMock = contract.fromArtifact('EnumerableUintSetMock');
const EnumerableAddressSetMock = artifacts.require('EnumerableAddressSetMock');
const EnumerableUintSetMock = artifacts.require('EnumerableUintSetMock');
const { shouldBehaveLikeSet } = require('./EnumerableSet.behavior');
describe('EnumerableSet', function () {
contract('EnumerableSet', function (accounts) {
// AddressSet
describe('EnumerableAddressSet', function () {
const [ accountA, accountB, accountC ] = accounts;

View File

@@ -1,12 +1,10 @@
const { accounts, contract } = require('@openzeppelin/test-environment');
const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const PausableMock = contract.fromArtifact('PausableMock');
const PausableMock = artifacts.require('PausableMock');
describe('Pausable', function () {
contract('Pausable', function (accounts) {
const [ pauser ] = accounts;
beforeEach(async function () {

View File

@@ -1,12 +1,11 @@
const { contract } = require('@openzeppelin/test-environment');
const { expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const ReentrancyMock = contract.fromArtifact('ReentrancyMock');
const ReentrancyAttack = contract.fromArtifact('ReentrancyAttack');
const ReentrancyMock = artifacts.require('ReentrancyMock');
const ReentrancyAttack = artifacts.require('ReentrancyAttack');
describe('ReentrancyGuard', function () {
contract('ReentrancyGuard', function (accounts) {
beforeEach(async function () {
this.reentrancyMock = await ReentrancyMock.new();
expect(await this.reentrancyMock.counter()).to.be.bignumber.equal('0');

View File

@@ -1,11 +1,10 @@
const { contract } = require('@openzeppelin/test-environment');
const { BN, expectRevert } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const SafeCastMock = contract.fromArtifact('SafeCastMock');
const SafeCastMock = artifacts.require('SafeCastMock');
describe('SafeCast', async () => {
contract('SafeCast', async (accounts) => {
beforeEach(async function () {
this.safeCast = await SafeCastMock.new();
});

View File

@@ -1,11 +1,10 @@
const { contract } = require('@openzeppelin/test-environment');
const { constants } = require('@openzeppelin/test-helpers');
const { expect } = require('chai');
const StringsMock = contract.fromArtifact('StringsMock');
const StringsMock = artifacts.require('StringsMock');
describe('Strings', function () {
contract('Strings', function (accounts) {
beforeEach(async function () {
this.strings = await StringsMock.new();
});