Compare commits

...

9 Commits

81 changed files with 5350 additions and 25609 deletions

View File

@ -1,84 +0,0 @@
version: 2
# 2.1 does not yet support local run
# unless with workaround. For simplicity just use it.
# https://github.com/CircleCI-Public/circleci-cli/issues/79
aliases:
- &defaults
docker:
- image: circleci/node:10
- &cache_key_node_modules
key: v1-node_modules-{{ checksum "package-lock.json" }}
jobs:
dependencies:
<<: *defaults
steps:
- checkout
- restore_cache:
<<: *cache_key_node_modules
- run:
name: Install npm dependencies and prepare
command: |
if [ ! -d node_modules ]; then
npm ci
else
npm run prepare
fi
- persist_to_workspace:
root: .
paths:
- node_modules
- build
- save_cache:
paths:
- node_modules
<<: *cache_key_node_modules
lint:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Linter
command: npm run lint
test:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Unit tests
command: npm run test
coverage:
<<: *defaults
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Unit tests with coverage report
command: npm run coverage
# TODO(xinbenlv, #1839): run SOLC_NIGHTLY to be run but allow it to fail.
workflows:
version: 2
everything:
jobs:
- dependencies
- lint:
requires:
- dependencies
- test:
requires:
- dependencies
- coverage:
requires:
- dependencies

View File

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

43
.github/workflows/test.yml vendored Normal file
View File

@ -0,0 +1,43 @@
name: Test
on:
push:
branches: [master]
pull_request: {}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 10.x
- uses: actions/cache@v2
id: cache
with:
path: '**/node_modules'
key: npm-v2-${{ hashFiles('**/package-lock.json') }}
restore-keys: npm-v2-
- run: npm ci
if: steps.cache.outputs.cache-hit != 'true'
- run: npm run lint
- run: npm run test
coverage:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: 10.x
- uses: actions/cache@v2
id: cache
with:
path: '**/node_modules'
key: npm-v2-${{ hashFiles('**/package-lock.json') }}
restore-keys: npm-v2-
- run: npm ci
if: steps.cache.outputs.cache-hit != 'true'
- run: npm run coverage
- uses: codecov/codecov-action@v1

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',
},
}

View File

@ -44,13 +44,6 @@ npm test
npm run lint
```
or you can simply run CircleCI locally
```bash
circleci local execute --job build
circleci local execute --job test
```
*Note*: requires installing CircleCI and docker locally on your machine.
5) Go to [github.com/OpenZeppelin/openzeppelin-contracts](https://github.com/OpenZeppelin/openzeppelin-contracts) in your web browser and issue a new pull request.
*IMPORTANT* Read the PR template very carefully and make sure to follow all the instructions. These instructions

View File

@ -2,7 +2,6 @@
[![Docs](https://img.shields.io/badge/docs-%F0%9F%93%84-blue)](https://docs.openzeppelin.com/contracts)
[![NPM Package](https://img.shields.io/npm/v/@openzeppelin/contracts.svg)](https://www.npmjs.org/package/@openzeppelin/contracts)
[![Build Status](https://circleci.com/gh/OpenZeppelin/openzeppelin-contracts.svg?style=shield)](https://circleci.com/gh/OpenZeppelin/openzeppelin-contracts)
[![Coverage Status](https://codecov.io/gh/OpenZeppelin/openzeppelin-contracts/graph/badge.svg)](https://codecov.io/gh/OpenZeppelin/openzeppelin-contracts)
**A library for secure smart contract development.** Build on a solid foundation of community-vetted code.

20
buidler.config.js Normal file
View File

@ -0,0 +1,20 @@
const fs = require('fs');
const path = require('path');
usePlugin('solidity-coverage');
usePlugin('@nomiclabs/buidler-truffle5');
for (const f of fs.readdirSync(path.join(__dirname, 'buidler'))) {
require(path.join(__dirname, 'buidler', f));
}
module.exports = {
networks: {
buidlerevm: {
blockGasLimit: 10000000,
},
},
solc: {
version: '0.6.12',
},
};

10
buidler/env-contract.js Normal file
View File

@ -0,0 +1,10 @@
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)));
};
});

View File

@ -1,7 +1,7 @@
{
"name": "@openzeppelin/contracts",
"version": "3.2.0",
"description": "Secure Smart Contract library for Solidity",
"version": "3.2.0",
"files": [
"**/*.sol",
"/build/contracts/*.json",

View File

@ -1,4 +1,8 @@
* xref:index.adoc[Overview]
* xref:extending-contracts.adoc[Extending Contracts]
* xref:upgrade-safe.adoc[Using with Upgrades]
* xref:releases-stability.adoc[Releases & Stability]
* xref:access-control.adoc[Access Control]
@ -12,8 +16,4 @@
* xref:gsn.adoc[Gas Station Network]
** xref:gsn-strategies.adoc[Strategies]
* xref:extending-contracts.adoc[Extending Contracts]
* xref:utilities.adoc[Utilities]
* xref:releases-stability.adoc[Releases & Stability]

View File

@ -0,0 +1,71 @@
= Using with Upgrades
If your contract is going to be deployed with upgradeability, such as using the xref:upgrades-plugins::index.adoc[OpenZeppelin Upgrades Plugins], you will need to use the Upgrade Safe variant of OpenZeppelin Contracts.
This variant is available as a separate package called `@openzeppelin/contracts-upgrade-safe`, which is hosted in the repository https://github.com/OpenZeppelin/openzeppelin-contracts-upgrade-safe[OpenZeppelin/openzeppelin-contracts-upgrade-safe].
It follows all of the rules for xref:upgrades-plugins::writing-upgradeable.adoc[Writing Upgradeable Contracts]: constructors are replaced by initializer functions, state variables are initialized in initializer functions, and we additionally check for storage incompatibilities across minor versions.
== Overview
=== Installation
```console
$ npm install @openzeppelin/contracts-upgrade-safe
```
=== Usage
The package replicates the structure of the main OpenZeppelin Contracts package, but every file and contract has the suffix `UpgradeSafe`.
```diff
-import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
+import "@openzeppelin/contracts-upgrade-safe/token/ERC721/ERC721UpgradeSafe.sol";
-contract MyCollectible is ERC721 {
+contract MyCollectible is ERC721UpgradeSafe {
```
Constructors are replaced by internal initializer functions following the naming convention `+__{ContractName}_init+`. Since these are internal, you must always define your own public initializer function and call the parent initializer of the contract you extend.
```diff
- constructor() ERC721("MyCollectible", "MCO") public {
+ function initialize() initializer public {
+ __ERC721_init("MyCollectible", "MCO");
}
```
CAUTION: Use with multiple inheritance requires special attention. See the section below titled <<multiple-inheritance>>.
Once this contract is set up and compiled, you can deploy it using the xref:upgrades-plugins::index.adoc[Upgrades Plugins]. The following snippet shows an example deployment script using Hardhat.
```js
// scripts/deploy-my-collectible.js
const { ethers, upgrades } = require("hardhat");
async function main() {
const MyCollectible = await ethers.getContractFactory("MyCollectible");
const mc = await upgrades.deployProxy(MyCollectible);
await mc.deployed();
console.log("MyCollectible deployed to:", mc.address);
}
main();
```
== Further Notes
[[multiple-inheritance]]
=== Multiple Inheritance
Initializer functions are not linearized by the compiler like constructors. Because of this, each `+__{ContractName}_init+` function embeds the linearized calls to all parent initializers. As a consequence, calling two of these `init` functions can potentially initialize the same contract twice.
The function `+__{ContractName}_init_unchained+` found in every contract is the initializer function minus the calls to parent initializers, and can be used to avoid the double initialization problem, but doing this manually is not recommended. We hope to be able to implement safety checks for this in future versions of the Upgrades Plugins.
=== Storage Gaps
You may notice that every contract includes a state variable named `+__gap+`. This is empty reserved space in storage that is put in place in Upgrade Safe contracts. It allows us to freely add new state variables in the future without compromising the storage compatibility with existing deployments.
It isn't safe to simply add a state variable because it "shifts down" all of the state variables below in the inheritance chain. This makes the storage layouts incompatible, as explained in xref:upgrades-plugins::writing-upgradeable.adoc#modifying-your-contracts[Writing Upgradeable Contracts]. The size of the `+__gap+` array is calculated so that the amount of storage used by a contract always adds up to the same number (in this case 50 storage slots).

30140
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,17 +1,16 @@
{
"name": "openzeppelin-solidity",
"version": "3.2.0",
"description": "Secure Smart Contract library for Solidity",
"version": "3.2.0",
"files": [
"/contracts/**/*.sol",
"/build/contracts/*.json",
"!/contracts/mocks",
"!/contracts/examples",
"/test/behaviors"
],
"scripts": {
"compile": "scripts/compile.sh",
"coverage": "scripts/coverage.sh",
"compile": "buidler compile",
"coverage": "buidler coverage",
"docs": "oz-docs",
"docs:watch": "npm run docs watch contracts 'docs/*.hbs'",
"prepare-docs": "scripts/prepare-docs.sh",
@ -20,12 +19,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 +45,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.4",
"@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",
@ -60,15 +60,14 @@
"eslint-plugin-node": "^10.0.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.1",
"ethereumjs-util": "^7.0.1",
"ganache-core-coverage": "https://github.com/OpenZeppelin/ganache-core-coverage/releases/download/2.5.3-coverage/ganache-core-coverage-2.5.3.tgz",
"ethereumjs-util": "^7.0.7",
"lodash.startcase": "^4.4.0",
"lodash.zip": "^4.2.0",
"micromatch": "^4.0.2",
"mocha": "^8.0.1",
"rimraf": "^3.0.2",
"solhint": "^3.0.0",
"solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477",
"solhint": "^3.2.0",
"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,25 +0,0 @@
#!/usr/bin/env bash
set -o errexit -o pipefail
# Executes cleanup function at script exit.
trap cleanup EXIT
cleanup() {
# Delete the symlink created to the allFiredEvents file solidity-coverage creates
rm -f allFiredEvents
}
log() {
echo "$*" >&2
}
# The allFiredEvents file is created inside coverageEnv, but solidity-coverage
# expects it to be at the top level. We create a symlink to fix this
ln -s coverageEnv/allFiredEvents allFiredEvents
OZ_TEST_ENV_COVERAGE=true npx solidity-coverage || log "Test run failed"
if [ "$CI" = true ]; 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,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,12 +1,11 @@
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');
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,13 +1,11 @@
const { accounts, contract, web3 } = 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');
describe('Address', function () {
contract('Address', function (accounts) {
const [ recipient, other ] = accounts;
beforeEach(async function () {
@ -145,8 +143,8 @@ describe('Address', function () {
}, []);
await expectRevert(
this.mock.functionCall(this.contractRecipient.address, abiEncodedCall),
'Address: low-level call failed'
this.mock.functionCall(this.contractRecipient.address, abiEncodedCall, { gas: '90000' }),
'Address: low-level call failed',
);
}).timeout(5000);

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();
});
@ -47,7 +46,6 @@ describe('SafeCast', async () => {
describe('toUint256', () => {
const maxInt256 = new BN('2').pow(new BN(255)).subn(1);
const minInt256 = new BN('2').pow(new BN(255)).neg();
const maxUint256 = new BN('2').pow(new BN(256)).subn(1);
it('casts 0', async function () {
expect(await this.safeCast.toUint256(0)).to.be.bignumber.equal('0');
@ -74,13 +72,6 @@ describe('SafeCast', async () => {
'SafeCast: value must be positive'
);
});
it(`reverts when casting UINT256_MAX (${maxUint256})`, async function () {
await expectRevert(
this.safeCast.toUint256(maxUint256),
'SafeCast: value must be positive'
);
});
});
function testToInt (bits) {

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();
});