omgnetwork / elixir-omg

OMG-Network repository of Watcher and Watcher Info
https://omg.network
Apache License 2.0
213 stars 59 forks source link

Development setup #63

Closed kasima closed 6 years ago

kasima commented 6 years ago

I'm trying to set up my local env.

After compiling the contracts, I was able to run make geth and make env.

Using this issue to track progress and get help.

/cc @pdobacz

kasima commented 6 years ago

I'm stuck on make test. Here are my failures so far. Seems like I'm not in the correct state? What do I need to do here?

1) test gets deposits from a range of blocks (OmiseGO.EthTest)
     test/eth_test.exs:80
     ** (ExUnit.TimeoutError) on_exit callback timed out after 60000ms. You can change the timeout:

       1. per test by setting "@tag timeout: x"
       2. per case by setting "@moduletag timeout: x"
       3. globally via "ExUnit.start(timeout: x)" configuration
       4. or set it to infinity per run by calling "mix test --trace"
          (useful when using IEx.pry)

     Timeouts are given as integers in milliseconds.

     stacktrace:
       lib/dev_geth.ex:23: OmiseGO.Eth.DevGeth.stop/1
       (ex_unit) lib/ex_unit/on_exit_handler.ex:140: ExUnit.OnExitHandler.exec_callback/1
       (ex_unit) lib/ex_unit/on_exit_handler.ex:126: ExUnit.OnExitHandler.on_exit_runner_loop/0

  2) test child block increment after add block (OmiseGO.EthTest)
     test/eth_test.exs:58
     ** (MatchError) no match of right hand side value: {:error, %{"code" => -32000, "message" => "unknown account"}}
     stacktrace:
       lib/eth/dev_helpers.ex:48: OmiseGO.Eth.DevHelpers.create_and_fund_authority_addr/0
       lib/eth/dev_helpers.ex:21: OmiseGO.Eth.DevHelpers.prepare_env/1
       test/fixtures.exs:14: OmiseGO.Eth.Fixtures.fixture_create_contract/1
       (ex_unit_fixtures) lib/ex_unit_fixtures/imp.ex:154: ExUnitFixtures.Imp.create_fixture/2
       (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
       (ex_unit_fixtures) lib/ex_unit_fixtures/imp.ex:86: ExUnitFixtures.Imp.create_fixtures/4
       (ex_unit_fixtures) lib/ex_unit_fixtures/imp.ex:57: ExUnitFixtures.Imp.test_scoped_fixtures/2
       test/eth_test.exs:1: OmiseGO.EthTest.__ex_unit_setup_0/1
       test/eth_test.exs:1: OmiseGO.EthTest.__ex_unit__/2

  3) test get authority for deployed contract (OmiseGO.EthTest)
     test/eth_test.exs:110
     ** (MatchError) no match of right hand side value: {:error, %{"code" => -32000, "message" => "insufficient funds for gas * price + value"}}
     stacktrace:
       lib/eth/dev_helpers.ex:48: OmiseGO.Eth.DevHelpers.create_and_fund_authority_addr/0
       lib/eth/dev_helpers.ex:21: OmiseGO.Eth.DevHelpers.prepare_env/1
       test/fixtures.exs:14: OmiseGO.Eth.Fixtures.fixture_create_contract/1
       (ex_unit_fixtures) lib/ex_unit_fixtures/imp.ex:154: ExUnitFixtures.Imp.create_fixture/2
       (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
       (ex_unit_fixtures) lib/ex_unit_fixtures/imp.ex:86: ExUnitFixtures.Imp.create_fixtures/4
       (ex_unit_fixtures) lib/ex_unit_fixtures/imp.ex:57: ExUnitFixtures.Imp.test_scoped_fixtures/2
       test/eth_test.exs:1: OmiseGO.EthTest.__ex_unit_setup_0/1
       test/eth_test.exs:1: OmiseGO.EthTest.__ex_unit__/2
kasima commented 6 years ago

from slack, @pdobacz:

1/ sigh, the Makefile is an unnofficial one. I'm trying to convince some of the Pawełs to ditch it in exchange for exhaustive README.md (WIP) and, if really required, Mix.Tasks which is way more standard for Elixir (to not multiply standards). So yeah, give us a second to sort that out. I'll write what to use for now today-ish

2/ you might have also caught our repo with pants down, we're currently trying to make the testing experience smoother (and Jenkins builds pass).

3/ so make geth and make env - I can see what they do now, shouldn't be necessary to run tests, and might even interfere.

to run the child chain tests, it should suffice to do mix test --no-start && mix test --no-start --only integration. It should launch geth and prepare envs as needed. Don't rely on the Makefile pls.

Actually, sorting out the readmes and setup/run instructions got stuck on https://www.pivotaltracker.com/story/show/156034888 which revamps that a lot.

pdobacz commented 6 years ago

@kasima FYI I've brought https://github.com/omisego/omisego/tree/feature/omg-127_readmes to the level where one should be able to work through the readmes to have the ch-ch server up and sending txs. There's multitude of issues still and the process is rough, but it's a start.

I'll continue that after the workshops

kasima commented 6 years ago

@pdobacz – the new readme and test process is much better. mix test --no start runs great. All unit tests pass.

However, I can't get the integration tests to pass. I've compiled the contracts in the populus directory but where do I go from there? Is mix test --no-start --only integration supposed to spin up geth for me? Do I need to deploy those contracts myself?

I'm getting errors like this:

  1) test get exits from a range of blocks (OmiseGO.EthTest)
     test/eth_test.exs:100
     ** (MatchError) no match of right hand side value: {:error, :timeout}
     stacktrace:
       lib/dev_geth.ex:29: OmiseGO.Eth.DevGeth.stop/1
       (ex_unit) lib/ex_unit/on_exit_handler.ex:140: ExUnit.OnExitHandler.exec_callback/1
       (ex_unit) lib/ex_unit/on_exit_handler.ex:126: ExUnit.OnExitHandler.on_exit_runner_loop/0

Any help appreciated.

kasima commented 6 years ago

I spun up geth with geth --dev --dev.period 2 --rpc --rpcapi personal,web3,eth and am now seeing transactions coming through. Different messages now:

  1) test get child chain (OmiseGO.EthTest)
     test/eth_test.exs:76
     ** (MatchError) no match of right hand side value: :noproc
     stacktrace:
       lib/dev_geth.ex:29: OmiseGO.Eth.DevGeth.stop/1
       (ex_unit) lib/ex_unit/on_exit_handler.ex:140: ExUnit.OnExitHandler.exec_callback/1
       (ex_unit) lib/ex_unit/on_exit_handler.ex:126: ExUnit.OnExitHandler.on_exit_runner_loop/0
pdobacz commented 6 years ago

@kasima

for mix --no-start --only integration you don't need to (and shouldn't) start geth. Tests spin up geths for you.

You only need to do the geth --dev... if you want to start a development instance of the child chain and play around.

The error you're getting is tests unable to kill geth, because they didn't start it.

If there's anything that suggests that one should spin up geth for mix test, please let me know.

kasima commented 6 years ago

Without spinning up geth, I get these errors from integration tests:

1) test child block increment after add block (OmiseGO.EthTest)
     test/eth_test.exs:63
     ** (MatchError) no match of right hand side value: {:error, :timeout}
     stacktrace:
       lib/dev_geth.ex:29: OmiseGO.Eth.DevGeth.stop/1
       (ex_unit) lib/ex_unit/on_exit_handler.ex:140: ExUnit.OnExitHandler.exec_callback/1
       (ex_unit) lib/ex_unit/on_exit_handler.ex:126: ExUnit.OnExitHandler.on_exit_runner_loop/0

  2) test get mined block number (OmiseGO.EthTest)
     test/eth_test.exs:110
     ** (MatchError) no match of right hand side value: {:error, %{"code" => -32000, "message" => "insufficient funds for gas * price + value"}}
     stacktrace:
       lib/eth/dev_helpers.ex:70: OmiseGO.Eth.DevHelpers.unlock_fund/1
       lib/eth/dev_helpers.ex:46: OmiseGO.Eth.DevHelpers.create_and_fund_authority_addr/0
       lib/eth/dev_helpers.ex:11: OmiseGO.Eth.DevHelpers.prepare_env!/1
       (ex_unit_fixtures) lib/ex_unit_fixtures/imp.ex:154: ExUnitFixtures.Imp.create_fixture/2
       (elixir) lib/enum.ex:1899: Enum."-reduce/3-lists^foldl/2-0-"/3
       (ex_unit_fixtures) lib/ex_unit_fixtures/imp.ex:86: ExUnitFixtures.Imp.create_fixtures/4
       (ex_unit_fixtures) lib/ex_unit_fixtures/imp.ex:57: ExUnitFixtures.Imp.test_scoped_fixtures/2
       test/eth_test.exs:1: OmiseGO.EthTest.__ex_unit_setup_0/1
       test/eth_test.exs:1: OmiseGO.EthTest.__ex_unit__/2

...

There's nothing in the README that says I need to spin up geth – tried it to troubleshoot.

kasima commented 6 years ago

This is all working for me now. Thanks @pdobacz!