Truffle: Truffle - test: Cannot create property 'negative' on number '1'

Created on 13 Apr 2019  路  6Comments  路  Source: trufflesuite/truffle

Issue

There seems to be some terrible bugs on the current big number implementation, and it's breaking tests.

Steps to Reproduce

My case was during a test, but i can also do it using truffle develop with a simpler case:

>  n = new web3.utils.BN('1'); n.sub('1')

/workspace/node_modules/truffle/build/cli.bundled.js:1315
      num.negative = 0;
                   ^

TypeError: Cannot create property 'negative' on string '1'

Seems to be some crazy internal error. Possible reference

Expected Behavior

Not an internal error

Environment

  • Operating System: MacOS
  • Ethereum client: ?
  • Truffle version (truffle version): 5.0.12
  • node version (node --version): v11.4.0
  • npm version (npm --version):
bug web3 wontfix

Most helpful comment

Thanks @eggplantzzz , the workaround I'm using currently is to cast the string also into BN.
Example:

n = new web3.utils.BN('1'); n.sub(web3.utils.toBN('1'))

All 6 comments

@flockonus Thanks for the heads up! We'll keep this in mind and follow the BN issue that you linked above.

Thanks @eggplantzzz , the workaround I'm using currently is to cast the string also into BN.
Example:

n = new web3.utils.BN('1'); n.sub(web3.utils.toBN('1'))

Hey @flockonus , turns ou that BN does not take strings for those methods! Your workaround is the way to do it, you can also use n.subn(1).

Closing since there's nothing we can do on our end about this.

I am facing the same issue but i did not get a solution

@saikrishnakalangi did you follow the syntax here?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Katsu1991 picture Katsu1991  路  3Comments

ferittuncer picture ferittuncer  路  3Comments

hefgi picture hefgi  路  3Comments

rjl493456442 picture rjl493456442  路  4Comments

ripper234 picture ripper234  路  4Comments