There seems to be some terrible bugs on the current big number implementation, and it's breaking tests.
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
Not an internal error
truffle version): 5.0.12node --version): v11.4.0npm --version): @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?
Most helpful comment
Thanks @eggplantzzz , the workaround I'm using currently is to cast the string also into BN.
Example: