Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

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

Closed
flockonus opened this issue Apr 12, 2019 · 6 comments
Closed

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

flockonus opened this issue Apr 12, 2019 · 6 comments

Comments

@flockonus
Copy link

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):
@eggplantzzz
Copy link
Contributor

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

@flockonus
Copy link
Author

flockonus commented Apr 18, 2019

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'))

@CruzMolina
Copy link
Contributor

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).

@CruzMolina
Copy link
Contributor

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

@saikrishnakalangi
Copy link

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

@gnidan
Copy link
Contributor

gnidan commented Aug 11, 2020

@saikrishnakalangi did you follow the syntax here?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants