Commit Graph

130 Commits

Author SHA1 Message Date
Rusty Russell 1f447688bc test: make generic driver for unit tests.
Not just in daemon.  This fixes 'make check' when it tries to
run 'make wire-tests'

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-12-02 18:10:13 +10:30
Rusty Russell 0ba93cb948 lightningd: don't listen at all if no port number set.
When we support the Milan protocol, we'll use a default port.  But
for now, don't listen at all unless a port is specified.

Fixes: #54
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-18 17:13:29 +10:30
Christian Decker e5b44ff232 Merge pull request #85 from ElementsProject/whitespace
Whitespace
2016-11-11 16:40:23 +01:00
Christian Decker 9848b4ac3e travis-ci: Added travis-ci config
Added .travis.yml to get travis-ci to build and run tests for us.

In addition this fixes a flaky test due to the fact that when lightning2
connects to lightning3 and we tell lightning3 to restart, then
lightning2 will back-off its reconnection attempts, potentially causing
a timeout to trigger during tests. This was triggered by travis-ci
relatively consistently since the restart would take quite some
time. Now simply restarting them in reverse order and a small timeout
seems to fix this consistently.
2016-11-11 14:25:41 +01:00
Rusty Russell f5c00deec7 Remove trailing whitespace from source.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-11 09:32:04 +10:30
Rusty Russell ce96812ef0 test.sh: split into multiple scripts.
This significantly reduces re-testing of the same paths, and simplifies
the addition of new tests.

make check -j12 times:
	Before: 9m24.973s
	After:	7m52.005s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:44:49 +10:30
Rusty Russell fae7f68731 helpers.sh: make check_tx_spend able to check for a specific transaction.
It currently takes an unused "who to blame" argument, which doesn't
always make sense.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:34:35 +10:30
Rusty Russell c6a187a5d7 helpers.sh: set up funding in start_lightningd()
Every test wants this anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:33:35 +10:30
Rusty Russell 9e777ae922 test.sh: move core routines to scripts/helpers.sh
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:32:35 +10:30
Rusty Russell 973ef3c932 test.sh: move valgrind PREFIX setting to vars.sh
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:31:35 +10:30
Rusty Russell 700c536a27 Makefile: remove all the old Elements Alpha support.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-10 23:30:35 +10:30
Rusty Russell 3aca5c87e3 init: rebroadcast anchors on restart if we haven't seen them.
It's possible that we won't have sent the anchor, but state is
committed in db.  And our current philosophy is that we retransmit all
the txs dumbly, all the time.

Our --restart --timeout-anchor test trigger this case, too, so
re-enable that now.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 18:52:15 +10:30
Rusty Russell 0f09605e17 test: restore anchor timeout tests.
Importantly, they're now entirely block driven.  We don't use
dev-setmocktime at all any more.

This also fixes a bug if we run the test twice against the same
bitcoind; we need to extract the time from the block header rather
than assuming bitcoind is on the current time.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 17:50:54 +10:30
Rusty Russell eedf95a8fc state_types: simplify open states.
The state now doesn't differentiate between who is funding.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:26 +10:30
Rusty Russell bbd1bbd931 state: remove anchor timeout.
We'll bring it back as a block-based timeout at the end.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-09 08:04:20 +10:30
Rusty Russell d3dc5508ad test.sh: run normal tests first.
That shows up obvious breakage, so do it first.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 21:57:55 +10:30
Rusty Russell 8477bd5a5f test: allow three variants in parallel with parallel make.
This means running 3 bitcoinds, which is slow enough to start on my laptop
that I need to increase the startup wait for 30 to 60 seconds, and similarly
the test.sh check loop.

Before:	real	13m42.868s
After:	real	8m19.563s (make -j3)

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 21:56:55 +10:30
Rusty Russell 9b045dac02 test: shutdown harder.
Sometimes bitcoind takes a while to shutdown.  Just kill it.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 21:55:55 +10:30
Rusty Russell 5f5ad793e9 test: fix unreliable test on slow machines.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 21:54:55 +10:30
Rusty Russell 2f0651d105 test: use eatmydata for bitcoind and lightningd if available.
Before:	real	17m56.862s
After:	real	13m42.868s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 21:53:55 +10:30
Rusty Russell 208beab529 test: setup bitcoind once, then run lightning tests.
On my build machine, times are:
Before:	real	22m10.425s
After:	real	17m56.862s

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 21:52:55 +10:30
Rusty Russell 4bd0284a15 test: only start up/shutdown bitcoind if not already running.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 21:51:55 +10:30
Rusty Russell d8892c4dda test: do version check during setup.
Waiting until lightningd is up is too long: do a --version test in setup,
and then check that all reported versions match later on.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 21:50:55 +10:30
Rusty Russell 35b2ee9c42 tests: remove obsolete BIP68 detection test.
We've assumed this for ages anyway.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 21:49:55 +10:30
Rusty Russell 8b7fa1b663 test: fix dependencies so we generate headers.
Revealed by "make check" on a freshly checked out tree.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-11-08 08:34:13 +10:30
Christian Decker 50807db7aa jsonrpc: Fixed `listinvoice` returning broken JSON
Closes #48.
2016-10-23 10:57:29 +02:00
Rusty Russell 7d20c4f75b feechange: disable sending of feechange messages.
We've seen intermittant failures on testnet, so disable sending feechanges
for now: we're completely changing it for 0.6 anyway, due to Milan Spec.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-10-19 12:00:27 +10:30
Rusty Russell e5994ad8c1 json_connect: don't return until we're in state normal.
This gives much better errors, and allows us to return the peer id.

Closes: #37
Reported-by: Glenn Willen
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-10-07 14:01:18 +10:30
Rusty Russell f66358882a config: different defaults for mainnet and testnet.
In particular, remove fee ranges on testnet (too unreliable) and accept
a single confirm.

(Note that an earlier version of this had a bug when there was no
config file, this version includes the fix).

Closes: #40
Reported-by: Glenn Willen
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-10-07 14:00:18 +10:30
Rusty Russell 44282eed16 test.sh: increase timeout, slow down bitcoind polling.
My temporary machine is incredibly slow.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-10-07 14:00:17 +10:30
Rusty Russell a1f1f1eda8 daemon: fix feechange logic.
Firstly, we need to update the staging fee amount when we queue a change.
Secondly we need to remove completed fee updates, otherwise we hit a
database constraint that peer & state are unique.

Reported-by: Christian Decker
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-10-07 14:00:17 +10:30
Rusty Russell b45b4eaba6 bitcoind: explicit flag to bitcoin-cli for testnet/regtest.
Three days of on and off debugging, before I realized my server was talking
to a non-testnet bitcoind.  There was a bitcoind on that machine running
on testnet, but it uses the same dir and config, so the --bitcoin-datadir
option couldn't help.

This is more certain: specify whether we're testnet on every single query.
Now we can skip the attempt to parse bitcoin.conf, too.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-10-07 14:00:16 +10:30
Rusty Russell 5b3bde715a getinfo: add version information
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-14 05:28:51 +09:30
Rusty Russell e5b2cacd3f daemon: fix up getinfo command, add it to tests.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-14 05:15:53 +09:30
Rusty Russell 831558d884 test.sh: remove scary-looking output from 'make check'
NO_VALGRIND= daemon/test/test.sh --normal --restart
lightning-cli: Connecting to 'lightning-rpc': Connection refused
lightning-cli: Connecting to 'lightning-rpc': Connection refused
lightning-cli: Connecting to 'lightning-rpc': Connection refused
lightning-cli: Connecting to 'lightning-rpc': Connection refused
lightning-cli: Connecting to 'lightning-rpc': Connection refused

This is expected: it happens when node3 is restarting.  Redirect
errors to /dev/null.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-08 15:56:33 +09:30
Rusty Russell 453c768b12 test: disable IRC connections for test.sh
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-08 15:47:05 +09:30
Rusty Russell 5bcc9047b0 db: save error, return it when we commit transaction.
This saves a lot of error handling, and puts it in the place we care about.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 16:47:49 +09:30
Rusty Russell ea41386ed3 daemon: rename all the low-level commands to dev-
Rename the structs to match (and remove dev-echo).

This makes it clear that they're not the normal API.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 16:47:49 +09:30
Rusty Russell c83fb1a2dd waitinvoice: RPC call for processing incoming invoices.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 16:47:49 +09:30
Rusty Russell 0761c12381 delinvoice: routine to remove an unpaid invoice.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 16:47:49 +09:30
Rusty Russell f6a0ea0b66 listinvoices: RPC command to show one or all invoices.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 16:47:49 +09:30
Rusty Russell 68632e6020 Use "msatoshi" not "msatoshis" everywhere.
Including in JSON API.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 16:47:49 +09:30
Rusty Russell 060ff29b45 Rename payment to invoice.
And rename JSON's accept-payment command to invoice.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 16:47:49 +09:30
Rusty Russell ca80fc0286 getroute: add a risk factor.
We need some way to reflect the tradeoff between the possible delay if
a payment gets stuck, and the fees charged by nodes.  This adds a risk
factor which reflects the probability that a node goes down, and the
cost associated with losing access to our funds for a given time.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 16:47:48 +09:30
Rusty Russell ab125f709b db: save and restore accepted payments.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-06 13:47:33 +09:30
Rusty Russell 04a07fd90e db: save and restore "sendpay" commands.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-05 13:29:48 +09:30
Rusty Russell 6fe5ecb2ac update-mocks: make mocks compile with -Wunused
Do this by scattering UNNEEDED everywhere, except in the case of (void).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-09-01 11:50:32 +09:30
Rusty Russell 7bebfe265c pay: remove route when a payment fails partway.
It's a bit harsh, but I'm assuming they'll get refreshed eventually.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-31 16:10:17 +09:30
Rusty Russell 2804a4de7a test: test case where we can't afford fees.
In particular, make sure B can just afford it, then have the A add a
HTLC which means B can no longer afford the fees, and A should cover
it.

We do this by modifying the previous overlapping-fail test, but we
need to have B offer it the htlc before A does: racy in the normal
autocommit case.  So we do a manual commit here, always.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-31 16:06:32 +09:30
Rusty Russell 2610799bda pay: split into getroute and sendpay
This is less convenient to use, but makes far more sense for a real
user (like a wallet).  It can ask about the route, then decide whether
to use it or not.

This will make even more sense once we add a parameter to control how
long we let the HTLC be delayed for, so a client can query for high,
medium and low tolerances and compare results.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-08-31 16:06:08 +09:30