2

Somethings I need BN library for correct balanceOf assertion with 1e18 decimals, somettimes expectRevert. I see the different projects use it differently:

const { constants, time, ether, expectRevert } = require('@openzeppelin/test-helpers');

or

const { BN, constants, expectEvent, expectRevert } = require('openzeppelin-test-helpers');

is there any difference?

2
  • If your package.json file has "@openzeppelin/test-helpers", then you should use the first option. – goodvibration Dec 16 '20 at 12:03
  • If your package.json file has "openzeppelin-test-helpers", then you should use the second option. – goodvibration Dec 16 '20 at 12:04
1
const { constants, time, ether, expectRevert } = require('@openzeppelin/test-helpers');

This is the modern way of importing trusted NPM packages. The other way must be some old legacy code.

0
1

You should require whatever is declared in your package.json file.

For example:

  • If "openzeppelin-test-helpers": "0.5.1", then require('openzeppelin-test-helpers')
  • If "@openzeppelin/test-helpers": "0.5.9", then require('@openzeppelin/test-helpers')

In this specific case, since 'openzeppelin-test-helpers' has been renamed to '@openzeppelin/test-helpers', you probably want to choose the latter (i.e., declare it in your package.json file, and require it in your truffle test file).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.