Skip to content

BigNumber support #124

Description

@miohtama

What would be tests needed to support BigNumber comparison in power-assert? BigNumber is userful in cryptography, finance and blockchain.

Currently comparing BigNumbers works if you stringify them first

assert(supply.toString() == TOKEN_1ST_TOTAL_SUPPLY.toString());

But this comparison of BigNumber objects fails

assert(supply == TOKEN_1ST_TOTAL_SUPPLY);

Output:


      AssertionError [ERR_ASSERTION]:   # Token.spec.ts:11
  
  assert(supply == TOKEN_1ST_TOTAL_SUPPLY)
         |      |  |                      
         |      |  BN{negative:0,words:#Array#,length:4,red:null}
         |      false                     
         BN{negative:0,words:#Array#,length:4,red:null}
  
  [BN] TOKEN_1ST_TOTAL_SUPPLY
  => BN{negative:0,words:#Array#,length:4,red:null}
  [BN] supply
  => BN{negative:0,words:#Array#,length:4,red:null}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions