question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
flockonuscommented, 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'))
2reactions
eggplantzzzcommented, Apr 18, 2019

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Calling web3.utils.BN.add gives error: Cannot create property ...
At truffle test, I am trying to add ...
Read more >
Can't log struct member in truffle test - Ethereum Stack Exchange
You can fix it by adding parenthesis: let myMemberResult = (await this.contract.myMapping(id)).myMember;.
Read more >
Test A Smart Contract With Truffle | by arjuna sky kok - Medium
So I'll show you how to write a smart contract with a normal text editor. Truffle is like a framework to build the...
Read more >
web3.utils — web3.js 1.0.0 documentation
If all of the bits are 1, then the element might be in the data set, but we need to actually query the...
Read more >
Unit Tests Fail Miserably - Contracts - OpenZeppelin Forum
I am now in the process of thoroughly testing my token before ... total supply: TypeError: Cannot set property 'negative' of undefined at...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found