ether-camp / ethereum-sandbox

Ethereum Sandbox
GNU Affero General Public License v3.0
7 stars 8 forks source link

Breakpoint in constructor not being called #66

Closed DaveAppleton closed 7 years ago

DaveAppleton commented 7 years ago
pragma solidity ^0.4.0;

//import "coinRelease.sol";

contract GBHcoin {

    event Transfer(address indexed _from, address indexed _to, uint256 _value);
    event Approval(address indexed _owner, address indexed _spender, uint256 _value);

    string  name = "GBH Coin";
    string  desc = "Your protection";

    address founder = msg.sender;

    mapping (address =>uint256)  balances;

    uint maxRelease = 0;

    function GBHcoin(){
        balances[msg.sender] = 12500000000000000;
    }

    //mapping (uint => coinRelease) releases;

    function balanceOf(address _owner) constant returns (uint256 balance) {
        return balances[_owner];
    }

    function totalSupply() constant returns (uint256 totalSupply) {
        return 12500000000000000;
    }

    function transfer(address _to, uint256 _value) returns (bool success) {
        if (balances[msg.sender] < _value) return false;
        balances[msg.sender] -= _value;
        balances[_to] += _value;
        Transfer(msg.sender, _to, _value);
        return true;
    }

    function transferFrom(address _from, address _to, uint256 _value) returns (bool success) {
        return false; // there is no withdrawal mechanism
    }

    function approve(address _spender, uint256 _value) returns (bool success) {
        return false;
    }

    function allowance(address _owner, address _spender) constant returns (uint256 remaining) {
        return 0;
    }
}

I have breakpoints in lines 20, 34, 35 balances[msg.sender] = 12500000000000000; in the constructor

if (balances[msg.sender] < _value) return false; balances[msg.sender] -= _value;

in transfer

I can run either in the debugger or outside and the constructor and the constructor gets executed (ie the owner's account gets the coins) BUT I cannot break on that line.

Calling transfer DOES cause the breakpoints in transfer to be called.


POSSIBLE extra info

Contract was originally named GBH while the file was GBHcoin.sol

THEN I renamed the contract but forgot to rename the constructor

(obviously the "constructor" didn't even get run which is why I started looking for breakpoints in the constructor)

Then I renamed the constructor to match the contract and now it does RUN but BP is still not not fired.

3esmit commented 7 years ago

see #40

asinyagin commented 7 years ago

@DaveAppleton this's a duplicate of #40. Solc gives weird code for constructors. We need to investigate on this.