Преглед на файлове

Migrate from truffle to test-environment (#2007)

* Sketch

* Migrate all tests to test-env

* Finish migration to test-env

* Add config

* Work on GSN tests

* Migrate to newer test-env version and loader syntax

* Add GSN setup

* Finish test-env migration

* Setup coverage using test-env

* Migrate to npm package

* Fix package.json

* Add compile step to CI

* Add comment on coverage setup

* Remove dependency on @truffle/contract

* Fix package-lock merge

* Fix linter errors

* Upgrade test-environment, depend locally on ganche-coverage

* Improve coverage script

* Improve sign.js API

* Move accounts destructuring to describe block

* Switch to prebuilt ethereumjs-vm package

* Upgrade test-enviroment version

* use workspace in circleci config

* remove unnecessary npx
Nicolás Venturo преди 5 години
родител
ревизия
5f92adc2e7
променени са 87 файла, в които са добавени 1249 реда и са изтрити 637 реда
  1. 20 18
      .circleci/config.yml
  2. 1 0
      .eslintrc
  3. 3 0
      .gitignore
  4. 2 2
      .solcover.js
  5. 721 255
      package-lock.json
  6. 8 7
      package.json
  7. 1 1
      scripts/compile.sh
  8. 13 1
      scripts/coverage.sh
  9. 0 83
      scripts/test.sh
  10. 22 0
      test-environment.config.js
  11. 3 1
      test/GSN/Context.behavior.js
  12. 7 3
      test/GSN/Context.test.js
  13. 6 2
      test/GSN/ERC721GSNRecipientMock.test.js
  14. 7 3
      test/GSN/GSNRecipient.test.js
  15. 8 4
      test/GSN/GSNRecipientERC20Fee.test.js
  16. 6 2
      test/GSN/GSNRecipientSignature.test.js
  17. 6 2
      test/access/Roles.test.js
  18. 6 2
      test/access/roles/CapperRole.test.js
  19. 6 2
      test/access/roles/MinterRole.test.js
  20. 6 2
      test/access/roles/PauserRole.test.js
  21. 6 2
      test/access/roles/SignerRole.test.js
  22. 6 2
      test/access/roles/WhitelistAdminRole.test.js
  23. 6 2
      test/access/roles/WhitelistedRole.test.js
  24. 6 6
      test/behaviors/access/roles/PublicRole.behavior.js
  25. 7 3
      test/crowdsale/AllowanceCrowdsale.test.js
  26. 7 3
      test/crowdsale/CappedCrowdsale.test.js
  27. 7 3
      test/crowdsale/Crowdsale.test.js
  28. 7 3
      test/crowdsale/FinalizableCrowdsale.test.js
  29. 7 3
      test/crowdsale/IncreasingPriceCrowdsale.test.js
  30. 7 4
      test/crowdsale/IndividuallyCappedCrowdsale.test.js
  31. 1 1
      test/crowdsale/MintedCrowdsale.behavior.js
  32. 9 5
      test/crowdsale/MintedCrowdsale.test.js
  33. 7 3
      test/crowdsale/PausableCrowdsale.test.js
  34. 7 3
      test/crowdsale/PostDeliveryCrowdsale.test.js
  35. 7 3
      test/crowdsale/RefundableCrowdsale.test.js
  36. 7 3
      test/crowdsale/RefundablePostDeliveryCrowdsale.test.js
  37. 7 3
      test/crowdsale/TimedCrowdsale.test.js
  38. 7 3
      test/crowdsale/WhitelistCrowdsale.test.js
  39. 7 3
      test/cryptography/ECDSA.test.js
  40. 4 2
      test/cryptography/MerkleProof.test.js
  41. 3 2
      test/drafts/Counters.test.js
  42. 2 1
      test/drafts/ERC1046/ERC20Metadata.test.js
  43. 8 4
      test/drafts/ERC20Migrator.test.js
  44. 6 2
      test/drafts/ERC20Snapshot.test.js
  45. 4 2
      test/drafts/SignedSafeMath.test.js
  46. 3 2
      test/drafts/Strings.test.js
  47. 7 3
      test/drafts/TokenVesting.test.js
  48. 7 3
      test/examples/SampleCrowdsale.test.js
  49. 6 2
      test/examples/SimpleToken.test.js
  50. 5 4
      test/helpers/sign.js
  51. 4 2
      test/introspection/ERC165.test.js
  52. 5 4
      test/introspection/ERC165Checker.test.js
  53. 6 2
      test/introspection/ERC1820Implementer.test.js
  54. 6 2
      test/lifecycle/Pausable.test.js
  55. 3 2
      test/math/Math.test.js
  56. 3 2
      test/math/SafeMath.test.js
  57. 4 4
      test/ownership/Ownable.behavior.js
  58. 6 2
      test/ownership/Ownable.test.js
  59. 6 2
      test/ownership/Secondary.test.js
  60. 6 2
      test/payment/PaymentSplitter.test.js
  61. 12 8
      test/payment/PullPayment.test.js
  62. 6 2
      test/payment/escrow/ConditionalEscrow.test.js
  63. 6 2
      test/payment/escrow/Escrow.test.js
  64. 6 2
      test/payment/escrow/RefundEscrow.test.js
  65. 6 0
      test/setup.js
  66. 6 2
      test/token/ERC20/ERC20.test.js
  67. 6 2
      test/token/ERC20/ERC20Burnable.test.js
  68. 6 2
      test/token/ERC20/ERC20Capped.test.js
  69. 3 2
      test/token/ERC20/ERC20Detailed.test.js
  70. 6 2
      test/token/ERC20/ERC20Mintable.test.js
  71. 6 2
      test/token/ERC20/ERC20Pausable.test.js
  72. 9 5
      test/token/ERC20/SafeERC20.test.js
  73. 7 3
      test/token/ERC20/TokenTimelock.test.js
  74. 3 2
      test/token/ERC721/ERC721.behavior.js
  75. 7 3
      test/token/ERC721/ERC721.test.js
  76. 7 4
      test/token/ERC721/ERC721Burnable.test.js
  77. 14 14
      test/token/ERC721/ERC721Full.test.js
  78. 8 5
      test/token/ERC721/ERC721Holder.test.js
  79. 7 4
      test/token/ERC721/ERC721Mintable.test.js
  80. 10 11
      test/token/ERC721/ERC721Pausable.test.js
  81. 2 1
      test/token/ERC777/ERC777.behavior.js
  82. 7 5
      test/token/ERC777/ERC777.test.js
  83. 8 4
      test/utils/Address.test.js
  84. 3 2
      test/utils/Arrays.test.js
  85. 4 3
      test/utils/ReentrancyGuard.test.js
  86. 3 2
      test/utils/SafeCast.test.js
  87. 0 44
      truffle-config.js

+ 20 - 18
.circleci/config.yml

@@ -8,14 +8,6 @@ aliases:
     docker:
       - image: circleci/node:10
 
-  - &npm_install_if_necessary
-    run:
-      name: Install npm dependencies
-      command: |
-        if [ ! -d node_modules ]; then
-          npm ci
-        fi
-
   - &cache_key_node_modules
     key: v1-node_modules-{{ checksum "package-lock.json" }}
 
@@ -26,7 +18,19 @@ jobs:
       - checkout
       - restore_cache:
           <<: *cache_key_node_modules
-      - *npm_install_if_necessary
+      - 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
@@ -36,9 +40,8 @@ jobs:
     <<: *defaults
     steps:
       - checkout
-      - restore_cache:
-          <<: *cache_key_node_modules
-      - *npm_install_if_necessary
+      - attach_workspace:
+          at: .
       - run:
           name: Linter
           command: npm run lint
@@ -46,19 +49,18 @@ jobs:
     <<: *defaults
     steps:
       - checkout
-      - restore_cache:
-          <<: *cache_key_node_modules
-      - *npm_install_if_necessary
+      - attach_workspace:
+          at: .
       - run:
           name: Unit tests
           command: npm run test
+
   coverage:
     <<: *defaults
     steps:
       - checkout
-      - restore_cache:
-          <<: *cache_key_node_modules
-      - *npm_install_if_necessary
+      - attach_workspace:
+          at: .
       - run:
           name: Unit tests with coverage report
           command: npm run coverage

+ 1 - 0
.eslintrc

@@ -25,6 +25,7 @@
     "strict": ["error", "global"],
 
     // Code style
+    "array-bracket-spacing": ["off"],
     "camelcase": ["error", {"properties": "always"}],
     "comma-dangle": ["error", "always-multiline"],
     "comma-spacing": ["error", {"before": false, "after": true}],

+ 3 - 0
.gitignore

@@ -48,3 +48,6 @@ openzeppelin-docs
 # only used to package @openzeppelin/contracts
 contracts/build/
 contracts/README.md
+
+# temporary artifact from solidity-coverage
+allFiredEvents

+ 2 - 2
.solcover.js

@@ -1,7 +1,7 @@
 module.exports = {
     norpc: true,
-    testCommand: 'node --max-old-space-size=4096 ../node_modules/.bin/truffle test --network coverage',
-    compileCommand: 'node --max-old-space-size=4096 ../node_modules/.bin/truffle compile --network coverage',
+    testCommand: 'npm test',
+    compileCommand: 'npm run compile',
     skipFiles: [
         'lifecycle/Migrations.sol',
         'mocks'

Файловите разлики са ограничени, защото са твърде много
+ 721 - 255
package-lock.json


+ 8 - 7
package.json

@@ -11,7 +11,6 @@
   ],
   "scripts": {
     "compile": "scripts/compile.sh",
-    "console": "truffle console",
     "coverage": "scripts/coverage.sh",
     "docs": "scripts/docs.sh",
     "prepare-docs": "scripts/prepare-docs.sh",
@@ -23,7 +22,7 @@
     "prepare": "node scripts/prepare.js",
     "release": "scripts/release/release.sh",
     "version": "scripts/release/version.sh",
-    "test": "scripts/test.sh"
+    "test": "mocha --exit --recursive test"
   },
   "repository": {
     "type": "git",
@@ -44,8 +43,10 @@
   },
   "homepage": "https://github.com/OpenZeppelin/openzeppelin-contracts",
   "devDependencies": {
+    "@openzeppelin/cli": "^2.5.3",
     "@openzeppelin/gsn-helpers": "^0.2.1",
     "@openzeppelin/gsn-provider": "^0.1.9",
+    "@openzeppelin/test-environment": "^0.1.1",
     "@openzeppelin/test-helpers": "^0.5.4",
     "chai": "^4.2.0",
     "concurrently": "^5.0.0",
@@ -57,15 +58,15 @@
     "eslint-plugin-promise": "^4.2.1",
     "eslint-plugin-standard": "^4.0.1",
     "ethereumjs-util": "^6.2.0",
-    "ganache-cli": "^6.7.0",
-    "ganache-cli-coverage": "https://github.com/frangio/ganache-cli/releases/download/v6.4.1-coverage/ganache-cli-coverage-6.4.1.tgz",
+    "ganache-core-coverage": "https://github.com/OpenZeppelin/ganache-core-coverage/releases/download/2.5.3-coverage/ganache-core-coverage-2.5.3.tgz",
     "http-server": "^0.11.1",
     "lodash.startcase": "^4.4.0",
     "micromatch": "^4.0.2",
+    "mocha": "^6.2.2",
     "nodemon": "^2.0.1",
     "solhint": "2.3.0",
     "solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477",
-    "solidity-docgen": "^0.3.13",
-    "truffle": "^5.0.44"
-  }
+    "solidity-docgen": "^0.3.13"
+  },
+  "dependencies": {}
 }

+ 1 - 1
scripts/compile.sh

@@ -4,4 +4,4 @@ if [ "$SOLC_NIGHTLY" = true ]; then
   docker pull ethereum/solc:nightly
 fi
 
-npx truffle compile
+npx oz compile

+ 13 - 1
scripts/coverage.sh

@@ -2,11 +2,23 @@
 
 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
 }
 
-SOLIDITY_COVERAGE=true scripts/test.sh || log "Test run failed"
+# 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"

+ 0 - 83
scripts/test.sh

@@ -1,83 +0,0 @@
-#!/usr/bin/env bash
-
-# Exit script as soon as a command fails.
-set -o errexit
-
-# Executes cleanup function at script exit.
-trap cleanup EXIT
-
-cleanup() {
-  # Kill the ganache instance that we started (if we started one and if it's still running).
-  if [ -n "$ganache_pid" ] && ps -p $ganache_pid > /dev/null; then
-    kill -9 $ganache_pid
-  fi
-}
-
-if [ "$SOLIDITY_COVERAGE" = true ]; then
-  ganache_port=8555
-else
-  ganache_port=8545
-fi
-
-ganache_running() {
-  nc -z localhost "$ganache_port"
-}
-
-start_ganache() {
-  local accounts=(
-    # 10 accounts with balance 1M ether, needed for high-value tests.
-    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,1000000000000000000000000"
-    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,1000000000000000000000000"
-    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,1000000000000000000000000"
-    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501203,1000000000000000000000000"
-    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501204,1000000000000000000000000"
-    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501205,1000000000000000000000000"
-    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501206,1000000000000000000000000"
-    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207,1000000000000000000000000"
-    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,1000000000000000000000000"
-    --account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,1000000000000000000000000"
-    # 3 accounts to be used for GSN matters.
-    --account="0x956b91cb2344d7863ea89e6945b753ca32f6d74bb97a59e59e04903ded14ad00,1000000000000000000000000"
-    --account="0x956b91cb2344d7863ea89e6945b753ca32f6d74bb97a59e59e04903ded14ad01,1000000000000000000000000"
-    --account="0x956b91cb2344d7863ea89e6945b753ca32f6d74bb97a59e59e04903ded14ad02,1000000000000000000000000"
-  )
-
-  if [ "$SOLIDITY_COVERAGE" = true ]; then
-    npx ganache-cli-coverage --emitFreeLogs true --allowUnlimitedContractSize true --gasLimit 0xfffffffffffff --port "$ganache_port" "${accounts[@]}" > /dev/null &
-  else
-    npx ganache-cli --gasLimit 0xfffffffffff --port "$ganache_port" "${accounts[@]}" > /dev/null &
-  fi
-
-  ganache_pid=$!
-
-  echo "Waiting for ganache to launch on port "$ganache_port"..."
-
-  while ! ganache_running; do
-    sleep 0.1 # wait for 1/10 of the second before check again
-  done
-
-  echo "Ganache launched!"
-}
-
-setup_relayhub() {
-  npx oz-gsn deploy-relay-hub \
-    --ethereumNodeURL "http://localhost:$ganache_port" \
-    --from "0xbb49ad04422f9fa6a217f3ed82261b942f6981f7"
-}
-
-if ganache_running; then
-  echo "Using existing ganache instance"
-else
-  echo "Starting our own ganache instance"
-  start_ganache
-fi
-
-npx truffle version
-
-setup_relayhub
-
-if [ "$SOLIDITY_COVERAGE" = true ]; then
-  npx solidity-coverage
-else
-  npx truffle test "$@"
-fi

+ 22 - 0
test-environment.config.js

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

+ 3 - 1
test/GSN/Context.behavior.js

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

+ 7 - 3
test/GSN/Context.test.js

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

+ 6 - 2
test/GSN/ERC721GSNRecipientMock.test.js

@@ -1,12 +1,16 @@
+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 { utils: { toBN } } = require('web3');
 
-const ERC721GSNRecipientMock = artifacts.require('ERC721GSNRecipientMock');
+const ERC721GSNRecipientMock = contract.fromArtifact('ERC721GSNRecipientMock');
+
+describe('ERC721GSNRecipient (integration)', function () {
+  const [ signer, sender ] = accounts;
 
-contract('ERC721GSNRecipient (integration)', function ([_, signer, sender]) {
   const tokenId = '42';
 
   beforeEach(async function () {

+ 7 - 3
test/GSN/GSNRecipient.test.js

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

+ 8 - 4
test/GSN/GSNRecipientERC20Fee.test.js

@@ -1,13 +1,17 @@
+const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
+
 const { ether, expectEvent } = require('@openzeppelin/test-helpers');
 const gsn = require('@openzeppelin/gsn-helpers');
 
 const { expect } = require('chai');
 
-const GSNRecipientERC20FeeMock = artifacts.require('GSNRecipientERC20FeeMock');
-const ERC20Detailed = artifacts.require('ERC20Detailed');
-const IRelayHub = artifacts.require('IRelayHub');
+const GSNRecipientERC20FeeMock = contract.fromArtifact('GSNRecipientERC20FeeMock');
+const ERC20Detailed = contract.fromArtifact('ERC20Detailed');
+const IRelayHub = contract.fromArtifact('IRelayHub');
+
+describe('GSNRecipientERC20Fee', function () {
+  const [ sender ] = accounts;
 
-contract('GSNRecipientERC20Fee', function ([_, sender, other]) {
   const name = 'FeeToken';
   const symbol = 'FTKN';
 

+ 6 - 2
test/GSN/GSNRecipientSignature.test.js

@@ -1,12 +1,16 @@
+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 { utils: { toBN } } = require('web3');
 const { ZERO_ADDRESS } = constants;
 
-const GSNRecipientSignatureMock = artifacts.require('GSNRecipientSignatureMock');
+const GSNRecipientSignatureMock = contract.fromArtifact('GSNRecipientSignatureMock');
+
+describe('GSNRecipientSignature', function () {
+  const [ signer, other ] = accounts;
 
-contract('GSNRecipientSignature', function ([_, signer, other]) {
   beforeEach(async function () {
     this.recipient = await GSNRecipientSignatureMock.new(signer);
   });

+ 6 - 2
test/access/Roles.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { expectRevert, constants } = require('@openzeppelin/test-helpers');
 const { ZERO_ADDRESS } = constants;
 
 const { expect } = require('chai');
 
-const RolesMock = artifacts.require('RolesMock');
+const RolesMock = contract.fromArtifact('RolesMock');
+
+describe('Roles', function () {
+  const [ authorized, otherAuthorized, other ] = accounts;
 
-contract('Roles', function ([_, authorized, otherAuthorized, other]) {
   beforeEach(async function () {
     this.roles = await RolesMock.new();
   });

+ 6 - 2
test/access/roles/CapperRole.test.js

@@ -1,7 +1,11 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior');
-const CapperRoleMock = artifacts.require('CapperRoleMock');
+const CapperRoleMock = contract.fromArtifact('CapperRoleMock');
+
+describe('CapperRole', function () {
+  const [ capper, otherCapper, ...otherAccounts ] = accounts;
 
-contract('CapperRole', function ([_, capper, otherCapper, ...otherAccounts]) {
   beforeEach(async function () {
     this.contract = await CapperRoleMock.new({ from: capper });
     await this.contract.addCapper(otherCapper, { from: capper });

+ 6 - 2
test/access/roles/MinterRole.test.js

@@ -1,7 +1,11 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior');
-const MinterRoleMock = artifacts.require('MinterRoleMock');
+const MinterRoleMock = contract.fromArtifact('MinterRoleMock');
+
+describe('MinterRole', function () {
+  const [ minter, otherMinter, ...otherAccounts ] = accounts;
 
-contract('MinterRole', function ([_, minter, otherMinter, ...otherAccounts]) {
   beforeEach(async function () {
     this.contract = await MinterRoleMock.new({ from: minter });
     await this.contract.addMinter(otherMinter, { from: minter });

+ 6 - 2
test/access/roles/PauserRole.test.js

@@ -1,7 +1,11 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior');
-const PauserRoleMock = artifacts.require('PauserRoleMock');
+const PauserRoleMock = contract.fromArtifact('PauserRoleMock');
+
+describe('PauserRole', function () {
+  const [ pauser, otherPauser, ...otherAccounts ] = accounts;
 
-contract('PauserRole', function ([_, pauser, otherPauser, ...otherAccounts]) {
   beforeEach(async function () {
     this.contract = await PauserRoleMock.new({ from: pauser });
     await this.contract.addPauser(otherPauser, { from: pauser });

+ 6 - 2
test/access/roles/SignerRole.test.js

@@ -1,7 +1,11 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior');
-const SignerRoleMock = artifacts.require('SignerRoleMock');
+const SignerRoleMock = contract.fromArtifact('SignerRoleMock');
+
+describe('SignerRole', function () {
+  const [ signer, otherSigner, ...otherAccounts ] = accounts;
 
-contract('SignerRole', function ([_, signer, otherSigner, ...otherAccounts]) {
   beforeEach(async function () {
     this.contract = await SignerRoleMock.new({ from: signer });
     await this.contract.addSigner(otherSigner, { from: signer });

+ 6 - 2
test/access/roles/WhitelistAdminRole.test.js

@@ -1,7 +1,11 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior');
-const WhitelistAdminRoleMock = artifacts.require('WhitelistAdminRoleMock');
+const WhitelistAdminRoleMock = contract.fromArtifact('WhitelistAdminRoleMock');
+
+describe('WhitelistAdminRole', function () {
+  const [ whitelistAdmin, otherWhitelistAdmin, ...otherAccounts ] = accounts;
 
-contract('WhitelistAdminRole', function ([_, whitelistAdmin, otherWhitelistAdmin, ...otherAccounts]) {
   beforeEach(async function () {
     this.contract = await WhitelistAdminRoleMock.new({ from: whitelistAdmin });
     await this.contract.addWhitelistAdmin(otherWhitelistAdmin, { from: whitelistAdmin });

+ 6 - 2
test/access/roles/WhitelistedRole.test.js

@@ -1,7 +1,11 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior');
-const WhitelistedRoleMock = artifacts.require('WhitelistedRoleMock');
+const WhitelistedRoleMock = contract.fromArtifact('WhitelistedRoleMock');
+
+describe('WhitelistedRole', function () {
+  const [ whitelisted, otherWhitelisted, whitelistAdmin, ...otherAccounts ] = accounts;
 
-contract('WhitelistedRole', function ([_, whitelisted, otherWhitelisted, whitelistAdmin, ...otherAccounts]) {
   beforeEach(async function () {
     this.contract = await WhitelistedRoleMock.new({ from: whitelistAdmin });
     await this.contract.addWhitelisted(whitelisted, { from: whitelistAdmin });

+ 6 - 6
test/behaviors/access/roles/PublicRole.behavior.js

@@ -76,8 +76,8 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen
         });
 
         it(`emits a ${rolename}Added event`, async function () {
-          const { logs } = await this.contract[`add${rolename}`](other, { from });
-          expectEvent.inLogs(logs, `${rolename}Added`, { account: other });
+          const receipt = await this.contract[`add${rolename}`](other, { from });
+          expectEvent(receipt, `${rolename}Added`, { account: other });
         });
 
         it('reverts when adding role to an already assigned account', async function () {
@@ -106,8 +106,8 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen
         });
 
         it(`emits a ${rolename}Removed event`, async function () {
-          const { logs } = await this.contract[`remove${rolename}`](authorized, { from });
-          expectEvent.inLogs(logs, `${rolename}Removed`, { account: authorized });
+          const receipt = await this.contract[`remove${rolename}`](authorized, { from });
+          expectEvent(receipt, `${rolename}Removed`, { account: authorized });
         });
 
         it('reverts when removing from an unassigned account', async function () {
@@ -131,8 +131,8 @@ function shouldBehaveLikePublicRole (authorized, otherAuthorized, [other], rolen
       });
 
       it(`emits a ${rolename}Removed event`, async function () {
-        const { logs } = await this.contract[`renounce${rolename}`]({ from: authorized });
-        expectEvent.inLogs(logs, `${rolename}Removed`, { account: authorized });
+        const receipt = await this.contract[`renounce${rolename}`]({ from: authorized });
+        expectEvent(receipt, `${rolename}Removed`, { account: authorized });
       });
 
       it('reverts when renouncing unassigned role', async function () {

+ 7 - 3
test/crowdsale/AllowanceCrowdsale.test.js

@@ -1,12 +1,16 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { balance, BN, constants, ether, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
 const { ZERO_ADDRESS } = constants;
 
 const { expect } = require('chai');
 
-const AllowanceCrowdsaleImpl = artifacts.require('AllowanceCrowdsaleImpl');
-const SimpleToken = artifacts.require('SimpleToken');
+const AllowanceCrowdsaleImpl = contract.fromArtifact('AllowanceCrowdsaleImpl');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+
+describe('AllowanceCrowdsale', function () {
+  const [ investor, wallet, purchaser, tokenWallet ] = accounts;
 
-contract('AllowanceCrowdsale', function ([_, investor, wallet, purchaser, tokenWallet]) {
   const rate = new BN('1');
   const value = ether('0.42');
   const expectedTokenAmount = rate.mul(value);

+ 7 - 3
test/crowdsale/CappedCrowdsale.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, ether, expectRevert } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const CappedCrowdsaleImpl = artifacts.require('CappedCrowdsaleImpl');
-const SimpleToken = artifacts.require('SimpleToken');
+const CappedCrowdsaleImpl = contract.fromArtifact('CappedCrowdsaleImpl');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+
+describe('CappedCrowdsale', function () {
+  const [ wallet ] = accounts;
 
-contract('CappedCrowdsale', function ([_, wallet]) {
   const rate = new BN('1');
   const cap = ether('100');
   const lessThanCap = ether('60');

+ 7 - 3
test/crowdsale/Crowdsale.test.js

@@ -1,12 +1,16 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { balance, BN, constants, ether, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
 const { ZERO_ADDRESS } = constants;
 
 const { expect } = require('chai');
 
-const Crowdsale = artifacts.require('CrowdsaleMock');
-const SimpleToken = artifacts.require('SimpleToken');
+const Crowdsale = contract.fromArtifact('CrowdsaleMock');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+
+describe('Crowdsale', function () {
+  const [ investor, wallet, purchaser ] = accounts;
 
-contract('Crowdsale', function ([_, investor, wallet, purchaser]) {
   const rate = new BN(1);
   const value = ether('42');
   const tokenSupply = new BN('10').pow(new BN('22'));

+ 7 - 3
test/crowdsale/FinalizableCrowdsale.test.js

@@ -1,9 +1,13 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, expectEvent, expectRevert, time } = require('@openzeppelin/test-helpers');
 
-const FinalizableCrowdsaleImpl = artifacts.require('FinalizableCrowdsaleImpl');
-const ERC20 = artifacts.require('ERC20');
+const FinalizableCrowdsaleImpl = contract.fromArtifact('FinalizableCrowdsaleImpl');
+const ERC20 = contract.fromArtifact('ERC20');
+
+describe('FinalizableCrowdsale', function () {
+  const [ wallet, other ] = accounts;
 
-contract('FinalizableCrowdsale', function ([_, wallet, other]) {
   const rate = new BN('1000');
 
   before(async function () {

+ 7 - 3
test/crowdsale/IncreasingPriceCrowdsale.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, ether, expectRevert, time } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const IncreasingPriceCrowdsaleImpl = artifacts.require('IncreasingPriceCrowdsaleImpl');
-const SimpleToken = artifacts.require('SimpleToken');
+const IncreasingPriceCrowdsaleImpl = contract.fromArtifact('IncreasingPriceCrowdsaleImpl');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+
+describe('IncreasingPriceCrowdsale', function () {
+  const [ investor, wallet, purchaser ] = accounts;
 
-contract('IncreasingPriceCrowdsale', function ([_, investor, wallet, purchaser]) {
   const value = ether('1');
   const tokenSupply = new BN('10').pow(new BN('22'));
 

+ 7 - 4
test/crowdsale/IndividuallyCappedCrowdsale.test.js

@@ -1,13 +1,16 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, ether, expectRevert } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const IndividuallyCappedCrowdsaleImpl = artifacts.require('IndividuallyCappedCrowdsaleImpl');
-const SimpleToken = artifacts.require('SimpleToken');
+const IndividuallyCappedCrowdsaleImpl = contract.fromArtifact('IndividuallyCappedCrowdsaleImpl');
+const SimpleToken = contract.fromArtifact('SimpleToken');
 const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/PublicRole.behavior');
 
-contract('IndividuallyCappedCrowdsale', function (
-  [_, capper, otherCapper, wallet, alice, bob, charlie, other, ...otherAccounts]) {
+describe('IndividuallyCappedCrowdsale', function () {
+  const [ capper, otherCapper, wallet, alice, bob, charlie, other, ...otherAccounts ] = accounts;
+
   const rate = new BN(1);
   const capAlice = ether('10');
   const capBob = ether('2');

+ 1 - 1
test/crowdsale/MintedCrowdsale.behavior.js

@@ -2,7 +2,7 @@ const { balance, expectEvent } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-function shouldBehaveLikeMintedCrowdsale ([_, investor, wallet, purchaser], rate, value) {
+function shouldBehaveLikeMintedCrowdsale ([ investor, wallet, purchaser ], rate, value) {
   const expectedTokenAmount = rate.mul(value);
 
   describe('as a minted crowdsale', function () {

+ 9 - 5
test/crowdsale/MintedCrowdsale.test.js

@@ -1,13 +1,17 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, ether, expectRevert } = require('@openzeppelin/test-helpers');
 const { shouldBehaveLikeMintedCrowdsale } = require('./MintedCrowdsale.behavior');
 
 const { expect } = require('chai');
 
-const MintedCrowdsaleImpl = artifacts.require('MintedCrowdsaleImpl');
-const ERC20Mintable = artifacts.require('ERC20Mintable');
-const ERC20 = artifacts.require('ERC20');
+const MintedCrowdsaleImpl = contract.fromArtifact('MintedCrowdsaleImpl');
+const ERC20Mintable = contract.fromArtifact('ERC20Mintable');
+const ERC20 = contract.fromArtifact('ERC20');
+
+describe('MintedCrowdsale', function () {
+  const [ deployer, investor, wallet, purchaser ] = accounts;
 
-contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser]) {
   const rate = new BN('1000');
   const value = ether('5');
 
@@ -24,7 +28,7 @@ contract('MintedCrowdsale', function ([_, deployer, investor, wallet, purchaser]
       expect(await this.token.isMinter(this.crowdsale.address)).to.equal(true);
     });
 
-    shouldBehaveLikeMintedCrowdsale([_, investor, wallet, purchaser], rate, value);
+    shouldBehaveLikeMintedCrowdsale([investor, wallet, purchaser], rate, value);
   });
 
   describe('using non-mintable token', function () {

+ 7 - 3
test/crowdsale/PausableCrowdsale.test.js

@@ -1,9 +1,13 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, expectRevert } = require('@openzeppelin/test-helpers');
 
-const PausableCrowdsale = artifacts.require('PausableCrowdsaleImpl');
-const SimpleToken = artifacts.require('SimpleToken');
+const PausableCrowdsale = contract.fromArtifact('PausableCrowdsaleImpl');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+
+describe('PausableCrowdsale', function () {
+  const [ pauser, wallet, other ] = accounts;
 
-contract('PausableCrowdsale', function ([_, pauser, wallet, other]) {
   const rate = new BN(1);
   const value = new BN(1);
 

+ 7 - 3
test/crowdsale/PostDeliveryCrowdsale.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, ether, expectRevert, time } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const PostDeliveryCrowdsaleImpl = artifacts.require('PostDeliveryCrowdsaleImpl');
-const SimpleToken = artifacts.require('SimpleToken');
+const PostDeliveryCrowdsaleImpl = contract.fromArtifact('PostDeliveryCrowdsaleImpl');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+
+describe('PostDeliveryCrowdsale', function () {
+  const [ investor, wallet, purchaser ] = accounts;
 
-contract('PostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
   const rate = new BN(1);
   const tokenSupply = new BN('10').pow(new BN('22'));
 

+ 7 - 3
test/crowdsale/RefundableCrowdsale.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { balance, BN, ether, expectRevert, time } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const RefundableCrowdsaleImpl = artifacts.require('RefundableCrowdsaleImpl');
-const SimpleToken = artifacts.require('SimpleToken');
+const RefundableCrowdsaleImpl = contract.fromArtifact('RefundableCrowdsaleImpl');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+
+describe('RefundableCrowdsale', function () {
+  const [ wallet, investor, other ] = accounts;
 
-contract('RefundableCrowdsale', function ([_, wallet, investor, purchaser, other]) {
   const rate = new BN(1);
   const goal = ether('50');
   const lessThanGoal = ether('45');

+ 7 - 3
test/crowdsale/RefundablePostDeliveryCrowdsale.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, ether, expectRevert, time } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const RefundablePostDeliveryCrowdsaleImpl = artifacts.require('RefundablePostDeliveryCrowdsaleImpl');
-const SimpleToken = artifacts.require('SimpleToken');
+const RefundablePostDeliveryCrowdsaleImpl = contract.fromArtifact('RefundablePostDeliveryCrowdsaleImpl');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+
+describe('RefundablePostDeliveryCrowdsale', function () {
+  const [ investor, wallet, purchaser ] = accounts;
 
-contract('RefundablePostDeliveryCrowdsale', function ([_, investor, wallet, purchaser]) {
   const rate = new BN(1);
   const tokenSupply = new BN('10').pow(new BN('22'));
   const goal = ether('100');

+ 7 - 3
test/crowdsale/TimedCrowdsale.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, ether, expectEvent, expectRevert, time } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const TimedCrowdsaleImpl = artifacts.require('TimedCrowdsaleImpl');
-const SimpleToken = artifacts.require('SimpleToken');
+const TimedCrowdsaleImpl = contract.fromArtifact('TimedCrowdsaleImpl');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+
+describe('TimedCrowdsale', function () {
+  const [ investor, wallet, purchaser ] = accounts;
 
-contract('TimedCrowdsale', function ([_, investor, wallet, purchaser]) {
   const rate = new BN(1);
   const value = ether('42');
   const tokenSupply = new BN('10').pow(new BN('22'));

+ 7 - 3
test/crowdsale/WhitelistCrowdsale.test.js

@@ -1,9 +1,13 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, ether, expectRevert } = require('@openzeppelin/test-helpers');
 
-const WhitelistCrowdsale = artifacts.require('WhitelistCrowdsaleImpl');
-const SimpleToken = artifacts.require('SimpleToken');
+const WhitelistCrowdsale = contract.fromArtifact('WhitelistCrowdsaleImpl');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+
+describe('WhitelistCrowdsale', function () {
+  const [ wallet, whitelister, whitelisted, otherWhitelisted, other ] = accounts;
 
-contract('WhitelistCrowdsale', function ([_, wallet, whitelister, whitelisted, otherWhitelisted, other]) {
   const rate = new BN(1);
   const value = ether('42');
   const tokenSupply = new BN('10').pow(new BN('22'));

+ 7 - 3
test/cryptography/ECDSA.test.js

@@ -1,15 +1,19 @@
+const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
+
 const { constants, expectRevert } = require('@openzeppelin/test-helpers');
 const { ZERO_ADDRESS } = constants;
 const { toEthSignedMessageHash, fixSignature } = require('../helpers/sign');
 
 const { expect } = require('chai');
 
-const ECDSAMock = artifacts.require('ECDSAMock');
+const ECDSAMock = contract.fromArtifact('ECDSAMock');
 
 const TEST_MESSAGE = web3.utils.sha3('OpenZeppelin');
 const WRONG_MESSAGE = web3.utils.sha3('Nope');
 
-contract('ECDSA', function ([_, other]) {
+describe('ECDSA', function () {
+  const [ other ] = accounts;
+
   beforeEach(async function () {
     this.ecdsa = await ECDSAMock.new();
   });
@@ -142,7 +146,7 @@ contract('ECDSA', function ([_, other]) {
 
   context('toEthSignedMessage', function () {
     it('should prefix hashes correctly', async function () {
-      (await this.ecdsa.toEthSignedMessageHash(TEST_MESSAGE)).should.equal(toEthSignedMessageHash(TEST_MESSAGE));
+      expect(await this.ecdsa.toEthSignedMessageHash(TEST_MESSAGE)).to.equal(toEthSignedMessageHash(TEST_MESSAGE));
       expect(await this.ecdsa.toEthSignedMessageHash(TEST_MESSAGE)).to.equal(toEthSignedMessageHash(TEST_MESSAGE));
     });
   });

+ 4 - 2
test/cryptography/MerkleProof.test.js

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

+ 3 - 2
test/drafts/Counters.test.js

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

+ 2 - 1
test/drafts/ERC1046/ERC20Metadata.test.js

@@ -1,6 +1,7 @@
+const { contract } = require('@openzeppelin/test-environment');
 require('@openzeppelin/test-helpers');
 
-const ERC20MetadataMock = artifacts.require('ERC20MetadataMock');
+const ERC20MetadataMock = contract.fromArtifact('ERC20MetadataMock');
 
 const { expect } = require('chai');
 

+ 8 - 4
test/drafts/ERC20Migrator.test.js

@@ -1,13 +1,17 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, constants, expectRevert } = require('@openzeppelin/test-helpers');
 const { ZERO_ADDRESS } = constants;
 
 const { expect } = require('chai');
 
-const ERC20Mock = artifacts.require('ERC20Mock');
-const ERC20Mintable = artifacts.require('ERC20Mintable');
-const ERC20Migrator = artifacts.require('ERC20Migrator');
+const ERC20Mock = contract.fromArtifact('ERC20Mock');
+const ERC20Mintable = contract.fromArtifact('ERC20Mintable');
+const ERC20Migrator = contract.fromArtifact('ERC20Migrator');
+
+describe('ERC20Migrator', function () {
+  const [ owner ] = accounts;
 
-contract('ERC20Migrator', function ([_, owner, recipient, anotherAccount]) {
   const totalSupply = new BN('200');
 
   it('reverts with a null legacy token address', async function () {

+ 6 - 2
test/drafts/ERC20Snapshot.test.js

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

+ 4 - 2
test/drafts/SignedSafeMath.test.js

@@ -1,11 +1,13 @@
+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 = artifacts.require('SignedSafeMathMock');
+const SignedSafeMathMock = contract.fromArtifact('SignedSafeMathMock');
 
-contract('SignedSafeMath', function () {
+describe('SignedSafeMath', function () {
   beforeEach(async function () {
     this.safeMath = await SignedSafeMathMock.new();
   });

+ 3 - 2
test/drafts/Strings.test.js

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

+ 7 - 3
test/drafts/TokenVesting.test.js

@@ -1,12 +1,16 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, constants, expectEvent, expectRevert, time } = require('@openzeppelin/test-helpers');
 const { ZERO_ADDRESS } = constants;
 
 const { expect } = require('chai');
 
-const ERC20Mintable = artifacts.require('ERC20Mintable');
-const TokenVesting = artifacts.require('TokenVesting');
+const ERC20Mintable = contract.fromArtifact('ERC20Mintable');
+const TokenVesting = contract.fromArtifact('TokenVesting');
+
+describe('TokenVesting', function () {
+  const [ owner, beneficiary ] = accounts;
 
-contract('TokenVesting', function ([_, owner, beneficiary]) {
   const amount = new BN('1000');
 
   beforeEach(async function () {

+ 7 - 3
test/examples/SampleCrowdsale.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, balance, ether, expectRevert, time } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const SampleCrowdsale = artifacts.require('SampleCrowdsale');
-const SampleCrowdsaleToken = artifacts.require('SampleCrowdsaleToken');
+const SampleCrowdsale = contract.fromArtifact('SampleCrowdsale');
+const SampleCrowdsaleToken = contract.fromArtifact('SampleCrowdsaleToken');
+
+describe('SampleCrowdsale', function () {
+  const [ deployer, owner, wallet, investor ] = accounts;
 
-contract('SampleCrowdsale', function ([_, deployer, owner, wallet, investor]) {
   const RATE = new BN(10);
   const GOAL = ether('10');
   const CAP = ether('20');

+ 6 - 2
test/examples/SimpleToken.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { constants, expectEvent } = require('@openzeppelin/test-helpers');
 const { ZERO_ADDRESS } = constants;
 
 const { expect } = require('chai');
 
-const SimpleToken = artifacts.require('SimpleToken');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+
+describe('SimpleToken', function () {
+  const [ creator ] = accounts;
 
-contract('SimpleToken', function ([_, creator]) {
   beforeEach(async function () {
     this.token = await SimpleToken.new({ from: creator });
   });

+ 5 - 4
test/helpers/sign.js

@@ -1,7 +1,4 @@
-const REAL_SIGNATURE_SIZE = 2 * 65; // 65 bytes in hexadecimal string legnth
-const PADDED_SIGNATURE_SIZE = 2 * 96; // 96 bytes in hexadecimal string length
-
-const DUMMY_SIGNATURE = `0x${web3.utils.padLeft('', REAL_SIGNATURE_SIZE)}`;
+const { web3 } = require('@openzeppelin/test-environment');
 
 function toEthSignedMessageHash (messageHex) {
   const messageBuffer = Buffer.from(messageHex.substring(2), 'hex');
@@ -41,6 +38,10 @@ const getSignFor = (contract, signer) => (redeemer, methodName, methodArgs = [])
     redeemer,
   ];
 
+  const REAL_SIGNATURE_SIZE = 2 * 65; // 65 bytes in hexadecimal string legnth
+  const PADDED_SIGNATURE_SIZE = 2 * 96; // 96 bytes in hexadecimal string length
+  const DUMMY_SIGNATURE = `0x${web3.utils.padLeft('', REAL_SIGNATURE_SIZE)}`;
+
   // if we have a method, add it to the parts that we're signing
   if (methodName) {
     if (methodArgs.length > 0) {

+ 4 - 2
test/introspection/ERC165.test.js

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

+ 5 - 4
test/introspection/ERC165Checker.test.js

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

+ 6 - 2
test/introspection/ERC1820Implementer.test.js

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

+ 6 - 2
test/lifecycle/Pausable.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
 const { shouldBehaveLikePublicRole } = require('../behaviors/access/roles/PublicRole.behavior');
 
 const { expect } = require('chai');
 
-const PausableMock = artifacts.require('PausableMock');
+const PausableMock = contract.fromArtifact('PausableMock');
+
+describe('Pausable', function () {
+  const [ pauser, otherPauser, other, ...otherAccounts ] = accounts;
 
-contract('Pausable', function ([_, pauser, otherPauser, other, ...otherAccounts]) {
   beforeEach(async function () {
     this.pausable = await PausableMock.new({ from: pauser });
   });

+ 3 - 2
test/math/Math.test.js

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

+ 3 - 2
test/math/SafeMath.test.js

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

+ 4 - 4
test/ownership/Ownable.behavior.js

@@ -11,8 +11,8 @@ function shouldBehaveLikeOwnable (owner, [other]) {
 
     it('changes owner after transfer', async function () {
       expect(await this.ownable.isOwner({ from: other })).to.equal(false);
-      const { logs } = await this.ownable.transferOwnership(other, { from: owner });
-      expectEvent.inLogs(logs, 'OwnershipTransferred');
+      const receipt = await this.ownable.transferOwnership(other, { from: owner });
+      expectEvent(receipt, 'OwnershipTransferred');
 
       expect(await this.ownable.owner()).to.equal(other);
       expect(await this.ownable.isOwner({ from: other })).to.equal(true);
@@ -33,8 +33,8 @@ function shouldBehaveLikeOwnable (owner, [other]) {
     });
 
     it('loses owner after renouncement', async function () {
-      const { logs } = await this.ownable.renounceOwnership({ from: owner });
-      expectEvent.inLogs(logs, 'OwnershipTransferred');
+      const receipt = await this.ownable.renounceOwnership({ from: owner });
+      expectEvent(receipt, 'OwnershipTransferred');
 
       expect(await this.ownable.owner()).to.equal(ZERO_ADDRESS);
     });

+ 6 - 2
test/ownership/Ownable.test.js

@@ -1,9 +1,13 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 require('@openzeppelin/test-helpers');
 const { shouldBehaveLikeOwnable } = require('./Ownable.behavior');
 
-const Ownable = artifacts.require('OwnableMock');
+const Ownable = contract.fromArtifact('OwnableMock');
+
+describe('Ownable', function () {
+  const [ owner, ...otherAccounts ] = accounts;
 
-contract('Ownable', function ([_, owner, ...otherAccounts]) {
   beforeEach(async function () {
     this.ownable = await Ownable.new({ from: owner });
   });

+ 6 - 2
test/ownership/Secondary.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
 const { ZERO_ADDRESS } = constants;
 
 const { expect } = require('chai');
 
-const SecondaryMock = artifacts.require('SecondaryMock');
+const SecondaryMock = contract.fromArtifact('SecondaryMock');
+
+describe('Secondary', function () {
+  const [ primary, newPrimary, other ] = accounts;
 
-contract('Secondary', function ([_, primary, newPrimary, other]) {
   beforeEach(async function () {
     this.secondary = await SecondaryMock.new({ from: primary });
   });

+ 6 - 2
test/payment/PaymentSplitter.test.js

@@ -1,11 +1,15 @@
+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 = artifacts.require('PaymentSplitter');
+const PaymentSplitter = contract.fromArtifact('PaymentSplitter');
+
+describe('PaymentSplitter', function () {
+  const [ owner, payee1, payee2, payee3, nonpayee1, payer1 ] = accounts;
 
-contract('PaymentSplitter', function ([_, owner, payee1, payee2, payee3, nonpayee1, payer1]) {
   const amount = ether('1');
 
   it('rejects an empty set of payees', async function () {

+ 12 - 8
test/payment/PullPayment.test.js

@@ -1,10 +1,14 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { balance, ether } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const PullPaymentMock = artifacts.require('PullPaymentMock');
+const PullPaymentMock = contract.fromArtifact('PullPaymentMock');
+
+describe('PullPayment', function () {
+  const [ payer, payee1, payee2 ] = accounts;
 
-contract('PullPayment', function ([_, payer, payee1, payee2]) {
   const amount = ether('17');
 
   beforeEach(async function () {
@@ -35,23 +39,23 @@ contract('PullPayment', function ([_, payer, payee1, payee2]) {
     const balanceTracker = await balance.tracker(payee1);
 
     await this.contract.callTransfer(payee1, amount, { from: payer });
-    (await this.contract.payments(payee1)).should.be.bignumber.equal(amount);
+    expect(await this.contract.payments(payee1)).to.be.bignumber.equal(amount);
 
     await this.contract.withdrawPayments(payee1);
 
-    (await balanceTracker.delta()).should.be.bignumber.equal(amount);
-    (await this.contract.payments(payee1)).should.be.bignumber.equal('0');
+    expect(await balanceTracker.delta()).to.be.bignumber.equal(amount);
+    expect(await this.contract.payments(payee1)).to.be.bignumber.equal('0');
   });
 
   it('can withdraw payment forwarding all gas', async function () {
     const balanceTracker = await balance.tracker(payee1);
 
     await this.contract.callTransfer(payee1, amount, { from: payer });
-    (await this.contract.payments(payee1)).should.be.bignumber.equal(amount);
+    expect(await this.contract.payments(payee1)).to.be.bignumber.equal(amount);
 
     await this.contract.withdrawPaymentsWithGas(payee1);
 
-    (await balanceTracker.delta()).should.be.bignumber.equal(amount);
-    (await this.contract.payments(payee1)).should.be.bignumber.equal('0');
+    expect(await balanceTracker.delta()).to.be.bignumber.equal(amount);
+    expect(await this.contract.payments(payee1)).to.be.bignumber.equal('0');
   });
 });

+ 6 - 2
test/payment/escrow/ConditionalEscrow.test.js

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

+ 6 - 2
test/payment/escrow/Escrow.test.js

@@ -1,9 +1,13 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 require('@openzeppelin/test-helpers');
 const { shouldBehaveLikeEscrow } = require('./Escrow.behavior');
 
-const Escrow = artifacts.require('Escrow');
+const Escrow = contract.fromArtifact('Escrow');
+
+describe('Escrow', function () {
+  const [ primary, ...otherAccounts ] = accounts;
 
-contract('Escrow', function ([_, primary, ...otherAccounts]) {
   beforeEach(async function () {
     this.escrow = await Escrow.new({ from: primary });
   });

+ 6 - 2
test/payment/escrow/RefundEscrow.test.js

@@ -1,11 +1,15 @@
+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 = artifacts.require('RefundEscrow');
+const RefundEscrow = contract.fromArtifact('RefundEscrow');
+
+describe('RefundEscrow', function () {
+  const [ primary, beneficiary, refundee1, refundee2 ] = accounts;
 
-contract('RefundEscrow', function ([_, primary, beneficiary, refundee1, refundee2]) {
   const amount = ether('54');
   const refundees = [refundee1, refundee2];
 

+ 6 - 0
test/setup.js

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

+ 6 - 2
test/token/ERC20/ERC20.test.js

@@ -1,3 +1,5 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
 const { expect } = require('chai');
 const { ZERO_ADDRESS } = constants;
@@ -8,9 +10,11 @@ const {
   shouldBehaveLikeERC20Approve,
 } = require('./ERC20.behavior');
 
-const ERC20Mock = artifacts.require('ERC20Mock');
+const ERC20Mock = contract.fromArtifact('ERC20Mock');
+
+describe('ERC20', function () {
+  const [ initialHolder, recipient, anotherAccount ] = accounts;
 
-contract('ERC20', function ([_, initialHolder, recipient, anotherAccount]) {
   const initialSupply = new BN(100);
 
   beforeEach(async function () {

+ 6 - 2
test/token/ERC20/ERC20Burnable.test.js

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

+ 6 - 2
test/token/ERC20/ERC20Capped.test.js

@@ -1,10 +1,14 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, ether, expectRevert } = require('@openzeppelin/test-helpers');
 const { shouldBehaveLikeERC20Mintable } = require('./behaviors/ERC20Mintable.behavior');
 const { shouldBehaveLikeERC20Capped } = require('./behaviors/ERC20Capped.behavior');
 
-const ERC20Capped = artifacts.require('ERC20Capped');
+const ERC20Capped = contract.fromArtifact('ERC20Capped');
+
+describe('ERC20Capped', function () {
+  const [ minter, ...otherAccounts ] = accounts;
 
-contract('ERC20Capped', function ([_, minter, ...otherAccounts]) {
   const cap = ether('1000');
 
   it('requires a non-zero cap', async function () {

+ 3 - 2
test/token/ERC20/ERC20Detailed.test.js

@@ -1,10 +1,11 @@
+const { contract } = require('@openzeppelin/test-environment');
 const { BN } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const ERC20DetailedMock = artifacts.require('ERC20DetailedMock');
+const ERC20DetailedMock = contract.fromArtifact('ERC20DetailedMock');
 
-contract('ERC20Detailed', function () {
+describe('ERC20Detailed', function () {
   const _name = 'My Detailed ERC20';
   const _symbol = 'MDT';
   const _decimals = new BN(18);

+ 6 - 2
test/token/ERC20/ERC20Mintable.test.js

@@ -1,8 +1,12 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { shouldBehaveLikeERC20Mintable } = require('./behaviors/ERC20Mintable.behavior');
-const ERC20MintableMock = artifacts.require('ERC20MintableMock');
+const ERC20MintableMock = contract.fromArtifact('ERC20MintableMock');
 const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior');
 
-contract('ERC20Mintable', function ([_, minter, otherMinter, ...otherAccounts]) {
+describe('ERC20Mintable', function () {
+  const [ minter, otherMinter, ...otherAccounts ] = accounts;
+
   beforeEach(async function () {
     this.token = await ERC20MintableMock.new({ from: minter });
   });

+ 6 - 2
test/token/ERC20/ERC20Pausable.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const ERC20PausableMock = artifacts.require('ERC20PausableMock');
+const ERC20PausableMock = contract.fromArtifact('ERC20PausableMock');
 const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior');
 
-contract('ERC20Pausable', function ([_, pauser, otherPauser, recipient, anotherAccount, ...otherAccounts]) {
+describe('ERC20Pausable', function () {
+  const [ pauser, otherPauser, recipient, anotherAccount, ...otherAccounts ] = accounts;
+
   const initialSupply = new BN(100);
 
   beforeEach(async function () {

+ 9 - 5
test/token/ERC20/SafeERC20.test.js

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

+ 7 - 3
test/token/ERC20/TokenTimelock.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, expectRevert, time } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const ERC20Mintable = artifacts.require('ERC20Mintable');
-const TokenTimelock = artifacts.require('TokenTimelock');
+const ERC20Mintable = contract.fromArtifact('ERC20Mintable');
+const TokenTimelock = contract.fromArtifact('TokenTimelock');
+
+describe('TokenTimelock', function () {
+  const [ minter, beneficiary ] = accounts;
 
-contract('TokenTimelock', function ([_, minter, beneficiary]) {
   const amount = new BN(100);
 
   context('with token', function () {

+ 3 - 2
test/token/ERC721/ERC721.behavior.js

@@ -1,10 +1,11 @@
+const { contract } = require('@openzeppelin/test-environment');
 const { BN, constants, expectEvent, expectRevert } = require('@openzeppelin/test-helpers');
 const { expect } = require('chai');
 const { ZERO_ADDRESS } = constants;
 const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
 
-const ERC721ReceiverMock = artifacts.require('ERC721ReceiverMock.sol');
-const ERC721Mock = artifacts.require('ERC721Mock.sol');
+const ERC721ReceiverMock = contract.fromArtifact('ERC721ReceiverMock');
+const ERC721Mock = contract.fromArtifact('ERC721Mock');
 
 function shouldBehaveLikeERC721 (
   creator,

+ 7 - 3
test/token/ERC721/ERC721.test.js

@@ -1,17 +1,21 @@
+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 { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
-const ERC721Mock = artifacts.require('ERC721Mock.sol');
+const ERC721Mock = contract.fromArtifact('ERC721Mock');
+
+describe('ERC721', function () {
+  const [ creator, owner, other, ...otherAccounts ] = accounts;
 
-contract('ERC721', function ([_, creator, owner, other, ...accounts]) {
   beforeEach(async function () {
     this.token = await ERC721Mock.new({ from: creator });
   });
 
-  shouldBehaveLikeERC721(creator, creator, accounts);
+  shouldBehaveLikeERC721(creator, creator, otherAccounts);
 
   describe('internal functions', function () {
     const tokenId = new BN('5042');

+ 7 - 4
test/token/ERC721/ERC721Burnable.test.js

@@ -1,3 +1,5 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 require('@openzeppelin/test-helpers');
 
 const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
@@ -5,15 +7,16 @@ const {
   shouldBehaveLikeMintAndBurnERC721,
 } = require('./ERC721MintBurn.behavior');
 
-const ERC721BurnableImpl = artifacts.require('ERC721MintableBurnableImpl.sol');
+const ERC721BurnableImpl = contract.fromArtifact('ERC721MintableBurnableImpl');
 
-contract('ERC721Burnable', function ([_, creator, ...accounts]) {
+describe('ERC721Burnable', function () {
+  const [ creator, ...otherAccounts ] = accounts;
   const minter = creator;
 
   beforeEach(async function () {
     this.token = await ERC721BurnableImpl.new({ from: creator });
   });
 
-  shouldBehaveLikeERC721(creator, minter, accounts);
-  shouldBehaveLikeMintAndBurnERC721(creator, minter, accounts);
+  shouldBehaveLikeERC721(creator, minter, otherAccounts);
+  shouldBehaveLikeMintAndBurnERC721(creator, minter, otherAccounts);
 });

+ 14 - 14
test/token/ERC721/ERC721Full.test.js

@@ -1,29 +1,29 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN, expectRevert } = require('@openzeppelin/test-helpers');
 const { expect } = require('chai');
 
 const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
 const { shouldSupportInterfaces } = require('../../introspection/SupportsInterface.behavior');
 
-const ERC721FullMock = artifacts.require('ERC721FullMock.sol');
-
-contract('ERC721Full', function ([
-  creator,
-  ...accounts
-]) {
-  const name = 'Non Fungible Token';
-  const symbol = 'NFT';
-  const firstTokenId = new BN(100);
-  const secondTokenId = new BN(200);
-  const thirdTokenId = new BN(300);
-  const nonExistentTokenId = new BN(999);
+const ERC721FullMock = contract.fromArtifact('ERC721FullMock');
 
+describe('ERC721Full', function () {
+  const [ creator, ...otherAccounts ] = accounts;
   const minter = creator;
 
   const [
     owner,
     newOwner,
     other,
-  ] = accounts;
+  ] = otherAccounts;
+
+  const name = 'Non Fungible Token';
+  const symbol = 'NFT';
+  const firstTokenId = new BN(100);
+  const secondTokenId = new BN(200);
+  const thirdTokenId = new BN(300);
+  const nonExistentTokenId = new BN(999);
 
   beforeEach(async function () {
     this.token = await ERC721FullMock.new(name, symbol, { from: creator });
@@ -245,7 +245,7 @@ contract('ERC721Full', function ([
     });
   });
 
-  shouldBehaveLikeERC721(creator, minter, accounts);
+  shouldBehaveLikeERC721(creator, minter, otherAccounts);
 
   shouldSupportInterfaces([
     'ERC165',

+ 8 - 5
test/token/ERC721/ERC721Holder.test.js

@@ -1,19 +1,22 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { BN } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
 
-const ERC721Holder = artifacts.require('ERC721Holder.sol');
-const ERC721Mintable = artifacts.require('ERC721MintableBurnableImpl.sol');
+const ERC721Holder = contract.fromArtifact('ERC721Holder');
+const ERC721Mintable = contract.fromArtifact('ERC721MintableBurnableImpl');
+
+describe('ERC721Holder', function () {
+  const [ creator ] = accounts;
 
-contract('ERC721Holder', function ([creator]) {
   it('receives an ERC721 token', async function () {
     const token = await ERC721Mintable.new({ from: creator });
     const tokenId = new BN(1);
     await token.mint(creator, tokenId, { from: creator });
 
     const receiver = await ERC721Holder.new();
-    await token.approve(receiver.address, tokenId, { from: creator });
-    await token.safeTransferFrom(creator, receiver.address, tokenId);
+    await token.safeTransferFrom(creator, receiver.address, tokenId, { from: creator });
 
     expect(await token.ownerOf(tokenId)).to.be.equal(receiver.address);
   });

+ 7 - 4
test/token/ERC721/ERC721Mintable.test.js

@@ -1,10 +1,13 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 require('@openzeppelin/test-helpers');
 const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
 const { shouldBehaveLikeMintAndBurnERC721 } = require('./ERC721MintBurn.behavior');
 
-const ERC721MintableImpl = artifacts.require('ERC721MintableBurnableImpl.sol');
+const ERC721MintableImpl = contract.fromArtifact('ERC721MintableBurnableImpl');
 
-contract('ERC721Mintable', function ([_, creator, ...accounts]) {
+describe('ERC721Mintable', function () {
+  const [ creator, ...otherAccounts ] = accounts;
   const minter = creator;
 
   beforeEach(async function () {
@@ -13,6 +16,6 @@ contract('ERC721Mintable', function ([_, creator, ...accounts]) {
     });
   });
 
-  shouldBehaveLikeERC721(creator, minter, accounts);
-  shouldBehaveLikeMintAndBurnERC721(creator, minter, accounts);
+  shouldBehaveLikeERC721(creator, minter, otherAccounts);
+  shouldBehaveLikeMintAndBurnERC721(creator, minter, otherAccounts);
 });

+ 10 - 11
test/token/ERC721/ERC721Pausable.test.js

@@ -1,16 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 require('@openzeppelin/test-helpers');
 const { shouldBehaveLikeERC721PausedToken } = require('./ERC721PausedToken.behavior');
 const { shouldBehaveLikeERC721 } = require('./ERC721.behavior');
 const { shouldBehaveLikePublicRole } = require('../../behaviors/access/roles/PublicRole.behavior');
 
-const ERC721PausableMock = artifacts.require('ERC721PausableMock.sol');
+const ERC721PausableMock = contract.fromArtifact('ERC721PausableMock');
+
+describe('ERC721Pausable', function () {
+  const [ creator, otherPauser, ...otherAccounts ] = accounts;
 
-contract('ERC721Pausable', function ([
-  _,
-  creator,
-  otherPauser,
-  ...accounts
-]) {
   beforeEach(async function () {
     this.token = await ERC721PausableMock.new({ from: creator });
   });
@@ -21,7 +20,7 @@ contract('ERC721Pausable', function ([
       await this.contract.addPauser(otherPauser, { from: creator });
     });
 
-    shouldBehaveLikePublicRole(creator, otherPauser, accounts, 'pauser');
+    shouldBehaveLikePublicRole(creator, otherPauser, otherAccounts, 'pauser');
   });
 
   context('when token is paused', function () {
@@ -29,11 +28,11 @@ contract('ERC721Pausable', function ([
       await this.token.pause({ from: creator });
     });
 
-    shouldBehaveLikeERC721PausedToken(creator, accounts);
+    shouldBehaveLikeERC721PausedToken(creator, otherAccounts);
   });
 
   context('when token is not paused yet', function () {
-    shouldBehaveLikeERC721(creator, creator, accounts);
+    shouldBehaveLikeERC721(creator, creator, otherAccounts);
   });
 
   context('when token is paused and then unpaused', function () {
@@ -42,6 +41,6 @@ contract('ERC721Pausable', function ([
       await this.token.unpause({ from: creator });
     });
 
-    shouldBehaveLikeERC721(creator, creator, accounts);
+    shouldBehaveLikeERC721(creator, creator, otherAccounts);
   });
 });

+ 2 - 1
test/token/ERC777/ERC777.behavior.js

@@ -1,9 +1,10 @@
+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 = artifacts.require('ERC777SenderRecipientMock');
+const ERC777SenderRecipientMock = contract.fromArtifact('ERC777SenderRecipientMock');
 
 function shouldBehaveLikeERC777DirectSendBurn (holder, recipient, data) {
   shouldBehaveLikeERC777DirectSend(holder, recipient, data);

+ 7 - 5
test/token/ERC777/ERC777.test.js

@@ -1,3 +1,5 @@
+const { accounts, contract, web3 } = require('@openzeppelin/test-environment');
+
 const { BN, expectEvent, expectRevert, singletons } = require('@openzeppelin/test-helpers');
 
 const { expect } = require('chai');
@@ -15,12 +17,12 @@ const {
   shouldBehaveLikeERC20,
 } = require('../ERC20/ERC20.behavior');
 
-const ERC777 = artifacts.require('ERC777Mock');
-const ERC777SenderRecipientMock = artifacts.require('ERC777SenderRecipientMock');
+const ERC777 = contract.fromArtifact('ERC777Mock');
+const ERC777SenderRecipientMock = contract.fromArtifact('ERC777SenderRecipientMock');
+
+describe('ERC777', function () {
+  const [ registryFunder, holder, defaultOperatorA, defaultOperatorB, newOperator, anyone ] = accounts;
 
-contract('ERC777', function ([
-  _, registryFunder, holder, defaultOperatorA, defaultOperatorB, newOperator, anyone,
-]) {
   const initialSupply = new BN('10000');
   const name = 'ERC777Test';
   const symbol = '777T';

+ 8 - 4
test/utils/Address.test.js

@@ -1,11 +1,15 @@
+const { accounts, contract } = require('@openzeppelin/test-environment');
+
 const { balance, constants, ether, expectRevert, send } = require('@openzeppelin/test-helpers');
 const { expect } = require('chai');
 
-const AddressImpl = artifacts.require('AddressImpl');
-const SimpleToken = artifacts.require('SimpleToken');
-const EtherReceiver = artifacts.require('EtherReceiverMock');
+const AddressImpl = contract.fromArtifact('AddressImpl');
+const SimpleToken = contract.fromArtifact('SimpleToken');
+const EtherReceiver = contract.fromArtifact('EtherReceiverMock');
+
+describe('Address', function () {
+  const [ recipient, other ] = accounts;
 
-contract('Address', function ([_, recipient, other]) {
   const ALL_ONES_ADDRESS = '0xFFfFfFffFFfffFFfFFfFFFFFffFFFffffFfFFFfF';
 
   beforeEach(async function () {

+ 3 - 2
test/utils/Arrays.test.js

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

+ 4 - 3
test/utils/ReentrancyGuard.test.js

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

+ 3 - 2
test/utils/SafeCast.test.js

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

+ 0 - 44
truffle-config.js

@@ -1,44 +0,0 @@
-require('chai/register-should');
-const { GSNDevProvider } = require('@openzeppelin/gsn-provider');
-
-const solcStable = {
-  version: '0.5.11',
-};
-
-const solcNightly = {
-  version: 'nightly',
-  docker: true,
-};
-
-const useSolcNightly = process.env.SOLC_NIGHTLY === 'true';
-
-module.exports = {
-  networks: {
-    development: {
-      provider: new GSNDevProvider('http://localhost:8545', {
-        txfee: 70,
-        useGSN: false,
-        // The last two accounts defined in test.sh
-        ownerAddress: '0x26be9c03ca7f61ad3d716253ee1edcae22734698',
-        relayerAddress: '0xdc5fd04802ea70f6e27aec12d56716624c98e749',
-      }),
-      network_id: '*', // eslint-disable-line camelcase
-    },
-    coverage: {
-      provider: new GSNDevProvider('http://localhost:8555', {
-        txfee: 70,
-        useGSN: false,
-        // The last two accounts defined in test.sh
-        ownerAddress: '0x26be9c03ca7f61ad3d716253ee1edcae22734698',
-        relayerAddress: '0xdc5fd04802ea70f6e27aec12d56716624c98e749',
-      }),
-      gas: 0xfffffffffff,
-      gasPrice: 0x01,
-      network_id: '*', // eslint-disable-line camelcase
-    },
-  },
-
-  compilers: {
-    solc: useSolcNightly ? solcNightly : solcStable,
-  },
-};

Някои файлове не бяха показани, защото твърде много файлове са промени