Open aress31 opened 3 years ago
More details:
it("has a quadrilllion (10^15) initial total supply", async () => {
const decimals = await this.token.decimals();
const totalSupply = await this.token.totalSupply();
console.log("totalSupply", totalSupply.toString());
console.log("1", 10 ** 32);
console.log("2", BN(10 ** 32).toString());
console.log("3", BN(10).exponentiatedBy(32).toString());
// console.log(new BN(expected));
// console.log((10 ** 15 * 10 ** decimals.toNumber()).toString());
// console.log(totalSupply, expected);
// expect(await this.token.totalSupply()).to.be.bignumber.equal(
// (10 ** 15 * 10 ** decimals.toNumber()).toString()
// );
});
Contract: Initial State
√ the deployer is the owner (95ms)
√ has a name (96ms)
√ has a symbol (156ms)
√ has 18 decimals (104ms)
totalSupply 1000000000000000000000000000000000
1 1e+32
1) has a quadrilllion (10^15) initial total supply
> No events were emitted
4 passing (2s)
1 failing
1) Contract: Initial State
has a quadrilllion (10^15) initial total supply:
TypeError: Cannot set property 'negative' of undefined
at BN (node_modules\bn.js\lib\bn.js:26:19)
at Context.<anonymous> (test\ERC20Deflationary.test.js:36:22)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
you should pass the exponent number as BN object, since you try to exponent a number in plain javascript. try using BN.pow()
instead.
example :
const totalExp = new BN(10).pow(new BN(32))
I am trying to create a BN object from the value
10**32
, see the following test:But it seems that the library cannot handle this
Big Number
, see the following stack trace:I also tried to initialise the
Big Number
with a string instead but the value is totally off, see:Could anyone please help?