question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Errors when calling the initialize public method in `truffle console`

See original GitHub issue

Errors when calling the initialize public method in truffle console

image

Steps to Reproduce

./scripts/test.sh

truffle migrate --network development --reset --compile-all

truffle console
...
ApeToken.deployed().then(inst => { apetoken = inst })
...
ApePreICO.deployed().then(inst => { preico = inst })
...
preico.initialized.call()
false
...
preico.initialize({ from: apetoken.address })
...
preico.initialize({ from: preico.owner() })
...

Expected Behavior

See the value preico.initialized.call() automatically changed to true.

Actual Results

image

macOS Sierra Environment

truffle version

Truffle v4.0.1 (core: 4.0.1) Solidity v0.4.18 (solc-js)

node -v && npm -v

v8.9.1 5.5.1

References

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:11

github_iconTop GitHub Comments

2reactions
josoroma-zzcommented, Dec 3, 2017

@chuacw Thanks for insisting on the tests.

I believe that now I really have a little better understanding of solidity.

https://github.com/josoroma/ape/blob/master/tests/ApePreICO.test.js#L131

./scripts/test.sh
rm -fr build && truffle migrate --network development --reset --compile-all
truffle test tests/ApePreICO.test.js
*** Ape Token Wallet: 0x3b7634fe1dc8b07894143bc87f93d0a51b104e1f


  Contract: PreICO
*** Ape Token Account Address: 0xdc3a1689e6211d359bf906ff6ed0c603e93949a5
*** PreICO Account Address: 0x0717a047e9c930afe59df9eb28bce816191be3e3
==> Owner: 0x3b7634fe1dc8b07894143bc87f93d0a51b104e1f
    ✓ can get owner
*** Ape Token Account Address: 0xdc3a1689e6211d359bf906ff6ed0c603e93949a5
*** PreICO Account Address: 0x0717a047e9c930afe59df9eb28bce816191be3e3
==> isUnstraustableAccount value: false
==> isUnstraustableAccount value: true
    ✓ cannot call initialize from any other wallet
*** Ape Token Account Address: 0xdc3a1689e6211d359bf906ff6ed0c603e93949a5
*** PreICO Account Address: 0x0717a047e9c930afe59df9eb28bce816191be3e3
    Tokens available 0
    Initialized      false
    WEI Raised       0
==> isInitialized: false
    ✓ cannot get initialized (40ms)
*** Ape Token Account Address: 0xdc3a1689e6211d359bf906ff6ed0c603e93949a5
*** PreICO Account Address: 0x0717a047e9c930afe59df9eb28bce816191be3e3
    Tokens available 0
    Initialized      false
    WEI Raised       0
    ✓ can get initial token balance (43ms)
*** Ape Token Account Address: 0xdc3a1689e6211d359bf906ff6ed0c603e93949a5
*** PreICO Account Address: 0x0717a047e9c930afe59df9eb28bce816191be3e3
==> INITIAL_SUPPLY: 1e+26
==> Successful transfer
    ✓ can transfer token to this account (73ms)
*** Ape Token Account Address: 0xdc3a1689e6211d359bf906ff6ed0c603e93949a5
*** PreICO Account Address: 0x0717a047e9c930afe59df9eb28bce816191be3e3
    Tokens available 6e+24
    Initialized      false
    WEI Raised       0
    ✓ can get tokens after transfer
*** Ape Token Account Address: 0xdc3a1689e6211d359bf906ff6ed0c603e93949a5
*** PreICO Account Address: 0x0717a047e9c930afe59df9eb28bce816191be3e3
    Tokens available 6e+24
    Initialized      false
    WEI Raised       0
==> isInitialized: true
    ✓ can initialize (48ms)
*** Ape Token Account Address: 0xdc3a1689e6211d359bf906ff6ed0c603e93949a5
*** PreICO Account Address: 0x0717a047e9c930afe59df9eb28bce816191be3e3
    Tokens available 6e+24
    Initialized      true
    WEI Raised       0
==> isInitialized: false
    ✓ cannot initialize again after initialization (45ms)
*** Ape Token Account Address: 0xdc3a1689e6211d359bf906ff6ed0c603e93949a5
*** PreICO Account Address: 0x0717a047e9c930afe59df9eb28bce816191be3e3
    Tokens available 6e+24
    Initialized      true
    WEI Raised       0
==> Tokens available 5.997e+24
==> Initialized      true
==> WEI Raised       1000000000000000000
    checkBalanceToken     105469346500000000000
    checkBalancePurchases 86584088200000000000
    ✓ can buy tokens (109ms)
*** Ape Token Account Address: 0xdc3a1689e6211d359bf906ff6ed0c603e93949a5
*** PreICO Account Address: 0x0717a047e9c930afe59df9eb28bce816191be3e3
    Tokens available 5.997e+24
    Initialized      true
    WEI Raised       1000000000000000000
==> Tokens available 5.985e+24
==> Initialized      true
==> WEI Raised       5000000000000000000
    checkBalanceToken     109469346500000000000
    checkBalancePurchases 82578813300000000000
    ✓ can buy tokens one more time (109ms)


  10 passing (579ms)
1reaction
chuacwcommented, Dec 3, 2017

Congratulations, @josoroma ! I believed you’ve learnt something here.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Problem with Truffle Console: Cannot read property 'call' of ...
The contract is properly deployed and has a valid JSON document, I really don´t understand why I cannot access its members. The only...
Read more >
Interact with your contracts - Truffle Suite
When you execute a contract function via a call you will receive the return value ... function sendCoin(address receiver, uint amount) public returns(bool ......
Read more >
Problem as sometimes initialize() can't be called - SDK
I have a simple function initialize() public initializer { . ... await instance.initialize({from: accounts[0]}); or in the truffle console.
Read more >
Calling function in truffle console error - Stack Overflow
Inside Truffle console ContractName.deployed().then(function(instance){app = instance}) app.adopt(23)//call method on contract class.
Read more >
Testing with Web3.js & Truffle - Hardhat
If you want to use Truffle Migrations to initialize your tests and call deployed() on the contract abstractions, both @nomiclabs/hardhat- ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found