Commit Graph

2284 Commits

Author SHA1 Message Date
Rusty Russell 662dfef436 lightningd/gossip: Move INIT message handling to handshake daemon.
We need to do this on every connection, whether reconnecting or not,
so it makes sense for the handshake daemon to handle it and return
the feature fields.

Longer term I'm considering having the handshake daemon handle the
listening and connecting, and simply hand the fds back once the peers
are ready.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-25 14:24:47 +09:30
Rusty Russell f6495d3310 lightningd/peer_control: don't create peer struct until we've connected.
We currently create a peer struct, then complete handshake to find out
who it is.  This means we have a half-formed peer, and worse: if it's
a reconnect we get two peers the same.

Add an explicit 'struct connection' for the handshake phase, and
construct a 'struct peer' once that's done.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-25 14:24:47 +09:30
Rusty Russell 34e6e56471 lightningd: introduce peer_state enum.
The actual state names are place holders for now, really.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-25 14:24:47 +09:30
Christian Decker 80486a6669 pytest: Do not check for valgrind errors if disabled
Checking for valgrind errors if we disabled valgrind will kill the
teardown, so don't!
2017-05-20 19:59:16 +09:30
Rusty Russell 3d2f166364 test_lightningd.py: don't fail if valgrind turned off.
eg:
test_routing_gossip (__main__.LightningDTests) ... ERROR

======================================================================
ERROR: test_routing_gossip (__main__.LightningDTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "tests/test_lightningd.py", line 150, in tearDown
    err_count += self.printValgrindErrors(node)
  File "tests/test_lightningd.py", line 137, in printValgrindErrors
    errors, fname = self.getValgrindErrors(node)
  File "tests/test_lightningd.py", line 132, in getValgrindErrors
    with open(error_file, 'r') as f:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/lightning-l106st0a/test_routing_gossip/lightning-1/valgrind-errors'

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-19 13:30:32 +02:00
Christian Decker f6d60b9076 pytest: Fail tests that produce valgrind errors
Check and print all valgrind errors and fail tests that produce
errors. We abort using an exception since `fail()` is not allowed in
the teardown.
2017-05-10 12:38:12 +09:30
Rusty Russell 42601c29d7 test_lightning.py: run valgrind on child daemons too
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-09 11:43:20 +09:30
Christian Decker 6d06303789 pytest: Remove obsolete test and fix two flaky tests 2017-05-07 12:06:56 +09:30
Christian Decker 23da30a2a4 pytest: Better dealing with env variables to configure tests 2017-05-07 12:06:56 +09:30
Rusty Russell 162dac1271 peer_control: don't complete fundchannel command until broadcast.
Under stress, the tests can mine blocks too soon, and the funding never
locks.  This gives more of a chance, at least.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-05 16:11:46 +09:30
Rusty Russell 6dcd7f9d6d tests: dump more information when we fail to find something in logs.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-05 16:11:46 +09:30
Rusty Russell 2641ecaafa test_lightningd.py: dump logs on error.
I couldn't actually figure out how to just dump them on error, so I
dump all the time.  When running 3 lightningd + bitcoind, this separates
the logs nicely.

TODO: We should delete the directories on success!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-03 11:47:10 +09:30
Rusty Russell 39fb7d82fb test_lightningd.py: re-enable and fix forwarding test.
But it breaks:

	test_forward (__main__.LightningDTests) ... lightningd_channel: Computed MAC does not match expected MAC, the message was modified.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-03 11:47:10 +09:30
Christian Decker f700662a56 routing: Reading the channel_id from routes passed in from JSONRPC 2017-05-02 11:47:52 +02:00
Christian Decker f24aab1916 sphinx: Updating daemon to new sphinx implementation
Mainly switching from the old include to the new include and adjusting
the actual size of the onion packet. It also moves `channel.c` to use
`struct hop_data`.

It introduces a dummy next hop in `channel.c` that will be replaced in
the next commit.
2017-05-02 11:47:52 +02:00
Rusty Russell 778b756369 channel: support HTLC forwarding.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-02 11:47:19 +02:00
Rusty Russell aa01b7d120 test_lightningd.py: helper to sync blockheight.
We need this to avoid spurious errors in the next patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-05-02 11:46:46 +02:00
Christian Decker dc7b832e83 pytest: Added gossip test for new daemon 2017-05-02 11:59:24 +09:30
Rusty Russell f61da7eb64 tests/test_lightningd.py: incorporate everything from old test-basic shell test.
This moves all the non-legacy blackbox testing into python.

Before:
	real	10m18.385s

After:
	real	9m54.877s

Note that this doesn't valgrind the subdaemons: that patch seems to cause
some issues in the python framework which I am still chasing.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-29 10:30:10 +02:00
Rusty Russell 366d67ae6d tests/test_lightningd.py: extract connect and fund_channel helpers.
Common pattern when setting up tests.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-29 10:30:10 +02:00
Rusty Russell 056f93e2d2 ping: move test to python.
Faster and neater.

Before:
	real	0m11.200s

After:
	real	0m9.101s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-04-29 10:30:10 +02:00
Christian Decker 810e12381a pytest: Simple wrapper around BitcoinProxy to avoid timeouts
Running long integration tests could result in `bitcoind` dropping the
connection inbetween calls, and since python-bitcoinlib does not
reconnect and/or retry, all subsequent tests would fail as well. This
patch switches to throwaway connections, each serving just one
request. It's easier than to reach into the bitcoinlib to reconnect
and reauth, but comes with some overhead, but I think it's acceptable
for the few bitcoin calls we actually perform.
2017-04-28 13:39:45 +09:30
Christian Decker 4e0be7a48f pytest: Added dynamic RPC call dispatch
Instead of having to define every single method we can now just call
any method, it'll fail upstream if it does not exist.
2017-04-24 05:18:11 +00:00
Christian Decker b6fea5b429 pytest: Check that channels are announced and activated correctly 2017-04-11 16:56:27 -07:00
Christian Decker 5028f7b9d9 fixup! pylightning: RPC returns a failure if the connection is lost 2017-03-20 11:18:00 +10:30
Christian Decker 9c7c2a3f2f pytest: Added simple pytest for the new JSON-RPC 2017-03-20 11:18:00 +10:30
Christian Decker b5c2d7d47d pytest: Gossip subdaemon had a flaky test
Whenever we were checking for the status before the daemon was
initialized the test would fail. Now just waiting for the state
transition.
2017-02-08 16:59:57 +01:00
Christian Decker c7e6f197b0 pytest: Chaning startup sentinel for bitcoind.
By looking for 'Done loading' in the log output we should actually be
called after `SetRPCWarmupFinished` in bitcoind. Only then is it safe
to make RPC calls. This resulted in the test suite being a bit flaky.
2017-02-08 16:59:56 +01:00
Christian Decker 66175c7361 Merge pull request #115 from ElementsProject/pytest-pathfix
pytest: don't assume paths of valgrind and bitcoind.
2017-01-24 14:22:23 +01:00
Rusty Russell 1575181ef5 pytest: don't assume paths of valgrind and bitcoind.
In particular, my bitcoind is in /usr/local/bin

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2017-01-24 14:37:56 +10:30
Christian Decker 1948062250 pytest: Using python-bitcoinlib instead of python-bitcoinrpc
The latter is unmaintained and has a number of problems.
2017-01-23 10:37:34 +01:00
Christian Decker 180c96776b pytest: Split the python integration tests into new and legacy 2017-01-23 10:37:34 +01:00
Christian Decker cf1c03f4d9 pytest: Implemented initial python integration tests. 2017-01-23 10:45:36 +10:30
Christian Decker 41a5e74db9 pytest: Implement utilities for python unittests 2017-01-23 10:45:36 +10:30