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

truffle test -> Error: Number can only safely store up to 53 bits #405

@mezrin

Description

@mezrin

My test:

var DASToken = artifacts.require("DASToken");

contract('DASToken', function (accounts) {
    const tokenName          = 'DA$ name';
    const tokenSymbol        = 'DA$ symbol';
    const tokenDecimals      = 1;
    const tokenSupply        = Math.pow(10, 9 + tokenDecimals);
    const tokenInitialHolder = accounts[0];
    const tokenContractOwner = accounts[1];

    it("Should test transmission of DA$ tokens", function () {
        const tokensReceiver = accounts[2];
        const amountToSend   = 100;

        var dasToken;
        DASToken.new(
            tokenName, tokenSymbol, tokenDecimals, tokenSupply, tokenInitialHolder, {from: tokenContractOwner}
        ).then(function (instance) {
            dasToken = instance;
            assert.ok(dasToken.address);
            //
            // Contract created, do the test transfer
            console.log('send transaction');
            return dasToken.transfer(tokensReceiver, amountToSend, {from: tokenInitialHolder});
        }).then(function (instance) {
            console.log('transaction finished');
        })
    });
});

Console output:

Contract: DASToken
  ✓ Should test transmission of DA$ tokens


5 passing (264ms)

send transaction
/usr/lib/node_modules/truffle/node_modules/bn.js/lib/bn.js:6
  if (!val) throw new Error(msg || 'Assertion failed');
            ^

Error: Number can only safely store up to 53 bits
  at assert (/usr/lib/node_modules/truffle/node_modules/bn.js/lib/bn.js:6:21)
  at BN.toNumber (/usr/lib/node_modules/truffle/node_modules/bn.js/lib/bn.js:506:7)
  at /usr/lib/node_modules/truffle/node_modules/ethjs-abi/lib/index.js:82:59
  at Array.forEach (native)
  at decodeParams (/usr/lib/node_modules/truffle/node_modules/ethjs-abi/lib/index.js:78:9)
  at Object.decodeEvent (/usr/lib/node_modules/truffle/node_modules/ethjs-abi/lib/index.js:123:10)
  at /usr/lib/node_modules/truffle/node_modules/truffle-contract/contract.js:73:38
  at Array.map (native)
  at Object.decodeLogs (/usr/lib/node_modules/truffle/node_modules/truffle-contract/contract.js:44:19)
  at Object.callback (/usr/lib/node_modules/truffle/node_modules/truffle-contract/contract.js:172:35)

error produced by the line return dasToken.transfer(tokensReceiver, amountToSend, {from: tokenInitialHolder});
in the console I see send transaction but do not see transaction finished

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