dappuniversity / token_sale

Code Your Own Cryptocurrency & ICO on Ethereum | Tutorial
407 stars 389 forks source link

Error not being triggered when transferFrom is greater than balance #35

Closed Madeindreams closed 4 years ago

Madeindreams commented 4 years ago

This is the part that is not getting triggered in the test.

// try transferring more then senders balance
             return tokenInstance.transferFrom(fromAccount, toAccount, 9999, {from: spendingAccount});
         }).then(assert.fail).catch(function(error){
            assert(error.message.indexOf('revert') >= 0, 'cannot transfer value larger than balance');

When I run the test I get no error.

I am using solidity 0.5.0 and I am following the update from the pull request. It should give me an error. Truffle v5.0.2 (core: 5.0.2) Solidity v0.5.0 (solc-js) Node v12.16.3

You can see all my code here; https://github.com/Madeindreams/AGC

I have updated truffle;

Truffle v5.1.43 (core: 5.1.43) Solidity v0.5.16 (solc-js) Node v12.16.3 Web3.js v1.2.1

By running the test with the --debug flag I can see the transactions

agcToken.Transfer(
      _from: <indexed> 0x75e627FA8fc6435685D2A2Bc0AD7f0CfF2837256 (type: address),
      _to: <indexed> 0xe736ff01F65bfe3e27e30583bA884F608b76c680 (type: address),
      _value: 100 (type: uint256)
    )

    agcToken.Approval(
      _owner: <indexed> 0xe736ff01F65bfe3e27e30583bA884F608b76c680 (type: address),
      _spender: <indexed> 0x12E4874F55F7f5705Cfaa6E7aA2d831Fd434fbC8 (type: address),
      _value: 10 (type: uint256)
    )

    agcToken.Transfer(
      _from: <indexed> 0xe736ff01F65bfe3e27e30583bA884F608b76c680 (type: address),
      _to: <indexed> 0x3c233d00E365E960E3411AFDd8b61a02e274beAc (type: address),
      _value: 999999999999999 (type: uint256)
    )

This shouldn't work since I dont have that much token?

Also, Visual studio is giving me a warning for the transferFrom function;

function transferFrom(address _from, address _to, uint256 _value) public returns (bool success){
}

Function state mutability can be restricted to pure.

Even if I add pure or view. It still doesn't throw an error.