Commit Graph

331 Commits

Author SHA1 Message Date
ZmnSCPxj c03f584e19 test_lightningd.py: Adapt to new help output. 2018-03-03 19:40:22 +01:00
Rusty Russell d7b5882f61 routing: don't free a single nc on prune, only entire channel.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-03 19:29:35 +01:00
Rusty Russell 33726b0a08 gossip: instead of refresh interval, have routing know prune_timeout.
This is twice the 'update_channel_interval' we get handed.

We delete the non-existent channel_add_connection and delete_connection
declarations from the header too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-03 19:29:35 +01:00
Rusty Russell b7bf414ac4 gossipd: prune announced-but-not-updated channels eventually.
We currently give them a free pass.  The simplest fix is to give them
an old timestamp on initialization.

We still skip unannounced channels, on the assumption that they're
ours.  And we set the last_update_timestamp to -1 when we convert to
gossip_getchannels_entry to indicate no update.

This breaks the DEVELOPER=1 pruning test, since we hardcode the 1
week timeout.  That's fixed in the next patch.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-03 19:29:35 +01:00
John Barboza 35ce13179c Add tests for peer information containing alias 2018-03-02 02:25:30 +00:00
John Barboza 6f14736803 revert 0e40c8 and renable test_withdraw
I initially disabled this until 0.16 because the withdraw command
was modified to require 'brct1' addresses for regtest.
But commit bd07a9 allows a regular testnet address to work
just as well. So renable this check.
2018-03-01 23:32:58 +01:00
Rusty Russell 742885c95e test_lightning.py: reduce 121 to 101 blocks, remove segwit comment.
FWIW, the tests without valgrind take 662 seconds before we reduced
the number of blocks, and only 648 seconds now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-03-01 03:52:21 +00:00
Jan Sarenik 0017b9b363 test_lightningd.py: Enable bech32 test for DEVELOPER
Since bitcoind 0.16 is already released it is safe to enable
this test already.
2018-03-01 03:52:21 +00:00
Christian Decker 565059a12f pytest: Require bitcoin-0.16.0 and reduce number of generated blocks
0.16.0 is required since we rely on it for some tests and the block
reduction allows us to waste less time during setup. 121 blocks were
chosen so that we have at least one mature output to spend.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-03-01 03:52:21 +00:00
ZmnSCPxj, ZmnSCPxj jxPCSmnZ 590a9a657d test_lightningd.py: Silence F841
Just do not assign to variable.
2018-02-28 11:17:08 +01:00
ZmnSCPxj 6792acf04c test_lightningd: Add some more testing for waitinvoice. 2018-02-28 11:17:08 +01:00
Rusty Russell c7718aa2e4 test_lightningd.py: repair flaky test_bitcoin_failure
If bitcoind is still fetching blocks, we might accidentally inject
the failure between getblockhash and getblock.  That's OK, but
it's not the failure we test for.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-28 01:51:40 +00:00
Rusty Russell 58fae47868 test_lightningd.py: more minor flake8 fixes.
Looks like rebasing the flake8 branch caused breakage, as new violations
had occurred since that check was written

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-26 22:36:05 +01:00
practicalswift d2109bfe0c Fix flake8 warnings 2018-02-26 12:38:00 +01:00
John Barboza 0e40c85691 Disable test until 0.16
This test generates a pre-bip173 testnet P2PKH address with bitcoin 0.15.1
which fails under the new verification checks for the bip173 network name.
This should be renabled with bitcoin 0.16 which can generate a bip173 address
for regtest with the bcrt prefix.
2018-02-26 03:09:15 +00:00
John Barboza b028a0a439 invoice: add fallback address to invoice command
* Modifies invoice command to have the following format
  invoice <msatoshi> <label> <desc> <?expiry> <?fallbackaddr>
* Adds support for Segwit bcrt1 addresses for withdraw
* Add test case for fallback address in invoice creation
* Create a common json_tok_address_scriptpubkey to be used
  by invoice and withdraw commands.
2018-02-26 03:09:15 +00:00
practicalswift bb12c234f2 Fix recently introduced PEP-8 violations 2018-02-24 11:44:32 +01:00
Christian Decker 330682abfe pytest: Remove any existing lightning-dirs before running
This was causing some issue when automatically rerunning tests on
travis.

Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-24 10:40:03 +01:00
Rusty Russell 737a7148b5 test_lightningd.py: make sure we recover from transient bitcoin failures.
We can do similar tricks to test other things, even to run without a
real bitcoind for faster testing, but for now we simply exit if a magic
file says so.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-24 10:37:28 +01:00
Rusty Russell 309dc96f97 fixup! More test fixups from last patch. 2018-02-23 18:02:00 +01:00
Rusty Russell cccdb53bec channel_states: fold all the ONCHAIND states into one.
The billboard is now far more useful to tell what's going on, and this
gets us closer to a state == owner mapping.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-23 18:02:00 +01:00
Rusty Russell 866ba00445 test_lightning.py: test in billboard in various closing cases.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-23 18:02:00 +01:00
practicalswift e18948a6a9 Remove unused variables. Fix flake8 warnings. 2018-02-22 22:21:31 +01:00
Rusty Russell b8c636514b pong: embed version string into ping replies if DEVELOPER=1.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-22 12:24:26 +01:00
Rusty Russell 85f1a9b825 lightningd: append (as much as we can) version into default name if DEVELOPER=1
This helps for bug reporting, where we may need to diagnose the other
end.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-22 12:24:26 +01:00
practicalswift ae7d857c44 Make Python code conform to the Python PEP 8 style guide 2018-02-22 10:47:19 +01:00
Rusty Russell b536e97df2 dev_ping: don't crash with silly values.
It's a dev command, but still.

Fixes: #985
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-22 01:10:09 +00:00
Rusty Russell 4cf274b1c0 lightningd/opening_control: routines to control openingd (move from peer_control.c)
We also fold opening_got_hsm_funding_sig() into the caller; it was
previously a callback before we decided to always use the HSM
synchronously.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-20 22:36:21 +01:00
Rusty Russell d47d85fa30 wallet: add list of upgrades.
Useful for debugging a db.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-20 01:38:32 +00:00
ZmnSCPxj ea3ee01215 peer_control: Support xxx@yyy:zzz form for connecting. 2018-02-19 11:59:11 +01:00
Rusty Russell 4653493507 test_lightningd: make test_payment_failed_persistence more reliable.
We don't want the invoice to fail locally, which can happen if we're
slow enough.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-19 02:56:51 +00:00
Rusty Russell e17b0ebcb4 channeld: map htlc add/remove errors to names.
I couldn't figure out what 'Bad peer_add_htlc: 7' meant!

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-19 02:56:51 +00:00
Rusty Russell 8db8c51201 lightningd: struct uncommitted_channel for opening channels.
Each peer can have one 'uncommitted' channel, which is in the process
of opening.  This is used for openingd, and then on return we convert
it into a full-fledged struct channel and commit it into the database.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-19 02:56:51 +00:00
Anton Astafiev 8787766d44 Pylightning (#1003)
* Fix dev_setfees to set slow and normal fees correctly.

Due to a bug def_setfees(100, slow=100) would instead set immediate and
normal fees to 100. This behavior has been updated to set fees to
correct values, make the values truly optional as per documentation and
unit test this behavior.

* Fix pay() to set msatoshi, description and risk factor properly

Due to a bug pay(invoice, description='1000') resulted in payment of
1000 msatoshi instead. This was fixed and covered with tests.

* Fix named args in listpayments, listpeers and connect

* Do not pass None to methods where it is default value

* Make description on invoice and pay match.

Suggested-by: @ZmnSCPxj

* Fix dev_setfees to set slow and normal fees correctly.

Due to a bug def_setfees(100, slow=100) would instead set immediate and
normal fees to 100. This behavior has been updated to set fees to
correct values, make the values truly optional as per documentation and
unit test this behavior.

* Fix pay() to set msatoshi, description and risk factor properly

Due to a bug pay(invoice, description='1000') resulted in payment of
1000 msatoshi instead. This was fixed and covered with tests.

* Fix named args in listpayments, listpeers and connect

* Do not pass None to methods where it is default value

* Make description on invoice and pay match.

Suggested-by: @ZmnSCPxj
2018-02-16 22:40:55 +01:00
Rusty Russell 43ec3f0761 jsonrpc: allow multiple commands in-flight from single JSON connection.
We now keep a list of commands for the jcon instead of a simple
'current' pointer: the assertions become a bit more complex, but
the rest is fairly mechanical.

Fixes: #1007
Reported-by: @ZmnSCPxj
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-16 17:51:04 +01:00
ZmnSCPxj 0489c7eb93 test_lightningd: Change test_pay0 to use sendpay. 2018-02-16 13:08:29 +01:00
ZmnSCPxj d9163dbb4f test_lightningd: Modify test to remove repeated pay attempt. 2018-02-16 13:08:29 +01:00
Rusty Russell df4c669a60 test: test for funds sent while we were offline.
As described by @lvaccaro in #990.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-16 13:07:12 +01:00
Rusty Russell c8f9ea7bf7 fixup: test_multirpc does not terminate.
We need to set expiry, otherwise waitinvoice would take 1 hr, and we
can't read once for every cmd, since each read may consume more than
a single result, and we block.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-16 12:56:48 +01:00
Christian Decker cab7e3e43a pytest: Add failing test with JSON-RPC requests crossing each other
Suggested-By: @ZmnSCPxj
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-16 12:56:48 +01:00
Rusty Russell a08bcfdbd3 jsonrpc: don't crash on multiple commands at once.
Once we read a command, we are supposed to io_wait until it finishes.
However, we are actually woken in two places: when it's complete
(which is correct), and when it's written out (which is wrong).

We don't care when it's written out, only when it's finished:
refactor to make json_done() free and NULL the old ->current,
rather than have the callers do it.  Now it's clear that it's
ready for both new output and new input.

Fixes: #934
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-16 12:56:48 +01:00
Christian Decker db5c0aa6c1 pytest: Make pep8 happy(er)
A number of fixes to make our code more pythonic
Signed-off-by: Christian Decker <decker.christian@gmail.com>
Co-authored-by: Guido Dassori @gdassori
2018-02-15 23:56:38 +00:00
Christian Decker 0e40b9b08c pylightning: Switch to dict-based params instead of positional
Signed-off-by: Christian Decker <decker.christian@gmail.com>
Co-authored-by: Guido Dassori @gdassori
2018-02-15 23:56:38 +00:00
Rusty Russell d822ba1eee lightningd: allow a new channel open from peer if no *active* channels.
And return the correct error message for the channel they give, if
they try to re-establish on an error channel.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-14 11:31:58 +01:00
Rusty Russell e20fff9340 lightningd: remove almost all other peer2channel / channel2peer shims.
This final sweep only keepl peer2channel within peer_control.c for
the reconnect case.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-14 11:31:58 +01:00
Rusty Russell 32411de90e lightningd: split struct peer into struct peer and struct channel.
Much like the database; peer contains id, address, channel contains
per-channel information.  Where we create a channel, we always create
the peer too.

For the moment, peer->log and channel->log coexist side-by-side, to
reduce some of the churn.

Note that this changes the API to dev-forget-channel: if we have more
than one channel, we insist they specify the short-channel-id.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-14 11:31:58 +01:00
Christian Decker 96667a3028 fixup! pytest: Test storing last_htlc_sigs and onchaind fund recovery 2018-02-11 01:13:07 +01:00
Christian Decker ea9aa95625 pytest: Test storing last_htlc_sigs and onchaind fund recovery
Signed-off-by: Christian Decker <decker.christian@gmail.com>
2018-02-11 01:13:07 +01:00
Rusty Russell d5effcb961 test_lightning: fix race on testing, esp. test_closing_different_fees.
We get intermittant failure: WIRE_UNKNOWN_NEXT_PEER (First peer not ready)
because CHANNELD_NORMAL and actually telling gossipd that the channel
is available are distinct things: we need both.

(For test_closing_different_fees, we were testing CHANNELD_NORMAL on
the peer, not on l1, too).

But we may also directly send the announcement sigs if the height is
sufficient, so the simplest is to unify the messages.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2018-02-09 13:01:19 +01:00
practicalswift 4f4756bd20 Fix a-vs-an typos 2018-02-08 22:49:34 +01:00