Rusty Russell
889db659c5
test: test commands during commit phase.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-26 15:25:25 +09:30
Rusty Russell
a2ced6c16c
test/test_protocol: add actual crossover case.
...
Not just add-htlc crossing over, but all the commit stages.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-18 06:55:28 +09:30
Rusty Russell
e46a2ed49a
test/test_protocol: rename internally to match updated 02-wire-protocol.md
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 15:06:12 +09:30
Rusty Russell
06d2c19c41
test/test_protocol: make pretty(-ish) SVG diagrams.
...
Could make them much prettier, but they're functional.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 15:02:08 +09:30
Rusty Russell
126c91e1b1
test/test_protocol: don't allow multiple commits in flight by default.
...
Add "nocommitwait" for the two cases we test that, otherwise add
assertions that we never end up dealing with anything other than
the previous commit.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 15:01:10 +09:30
Rusty Russell
a77466aa21
test/test_protocol: Keep pointer to previous state.
...
Since our pre-change state is always the same as the previous step's
post-change state, we can simply keep a pointer, with a dummy empty
state for the initial one.
We could function-wrap it, but this change is even simpler.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 13:58:06 +09:30
Rusty Russell
4c1b50baab
test/test_protocol: don't bother keeping acked (outgoing) queue.
...
We can simply set a boolean to indicate there are changes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 13:56:08 +09:30
Rusty Russell
bc8cd0dce7
test/test_protocol: don't manually reapply changes.
...
This finished the previous patch by simply copying funding_next to funding
when we want to apply changes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 13:55:58 +09:30
Rusty Russell
52db7ae0c4
test/test_protocol: keep cache of state with all changes applied.
...
This makes it easier to test for validity, though we still double-check
that a change doesn't overlap previous changes.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 13:51:25 +09:30
Rusty Russell
388dfc355e
test/test_protocol: add fee support.
...
We simply record how many fee changes there are, rather than supporting
a particular level.
Fees are tricky: it's a noop to apply them when incoming, but we apply them
when they've been acked. Unlike HTLC modifications, which are symmetric,
fee updates only apply when returning to the originating node.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 13:49:32 +09:30
Rusty Russell
056c219bc1
test/test_protocol: add checksync command to assert nodes are in sync.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 13:48:11 +09:30
Rusty Russell
7f90d183da
test/test_protocol: simulator for the updated wire-protocol BOLT.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-05-17 13:47:44 +09:30
Rusty Russell
cb0cc80984
patch remove-timeout.patch
2016-03-15 17:07:12 +10:30
Rusty Russell
983000428f
daemon: rename CMD_SEND_HTLC_UPDATE to CMD_SEND_HTLC_ADD
...
There are other updates than just adding an HTLC; make this explicit.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-03-08 10:42:15 +10:30
Rusty Russell
4f67b59c26
protocol: rename routefail to fail.
...
It's a generic "I couldn't complete this" failure.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-03-08 10:41:15 +10:30
Rusty Russell
40361e3dd8
state: explicit callback to check pkt_open_complete.
...
For now, this always succeeds, but include the hook for completeness.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-03-08 10:39:15 +10:30
Rusty Russell
a2f4000d22
state: cleanup after anchor has been transmitted.
...
If something goes wrong after we've broadcast the anchor tx, we need to use
the commit tx to spend it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-03-08 10:38:15 +10:30
Rusty Russell
5ac1d5df00
state: include daemon/peer (only if !TEST_COVERAGE).
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:49 +10:30
Rusty Russell
65cc6bbd50
pkt_err: make it variadic.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell
79e1c9bb62
state: make bitcoin_commit() take a non-const peer.
...
We have to sign the commit at this stage, so easiest if peer isn't const
so we can sign it in-place.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell
6a7a046f60
state: add peer_unwatch_close_timeout() call.
...
This tell us to disarm the INPUT_CLOSE_COMPLETE_TIMEOUT: either we hit
an error and are going to unilateral close, or we received their signature
successfully.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell
144ab3bef4
state: make tx arguments const.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell
ebf2bc57d8
state: add async anchor creation.
...
Actually generating the anchor transaction in my implementation
requires interaction with bitcoind, which we want to be async. So add
a callback and a new state to wait for it.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell
0db3c03ed1
state: fix BITCOIN_HTLC_TOTHEM_SPENT idata.
...
We use both union fields idata->btc and idata->htlc, which is clearly
wrong. Have peer_tx_revealed_r_value return the HTLC it's talking
about.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell
2b3d5b4049
state: remove all traces of struct state_effect.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell
63ea6bfd7a
state: add callbacks for adding/removing watches.
...
This lets us eliminate struct state_effect altogether (the next patch
removes the now-unused arguments).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell
1a20e8094f
state: return tx to be queued directly.
...
Instead of effect->broadcast_tx.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell
e984df486d
state: return Pkt to be queued directly.
...
Instead of effect->send_pkt.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:47 +10:30
Rusty Russell
7383da5f87
state: remove update_theirsig effect.
...
They get this from accept_pkt_update_accept() or accept_pkt_update_signature().
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
63cb0667f6
state: use callbacks for htlc management.
...
We only have one htlc in flight at a time, but sometimes it changes:
particularly when we are lowpriority and a highpriority request comes
in. Handle this using a set of callbacks for htlc handling.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
f48adb097e
state: use peer_unexpected_pkt() for an unexpected packet.
...
Instead of effect->in_error.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
4d9041e62a
state: fix case where we replied to an error with an error.
...
Found by fixing bogus test in test_state_coverage.c
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
9013a7d872
state: set peer->state directly.
...
Instead of new_state effect.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
4c9a9f8982
state: return status of current command.
...
We temporarily move effect to the end of the arg list: we'll get rid
of it eventually.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
03268014b4
state: use PEER_BUSY when doing a command.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
14ede84d87
state: set peercond in peer directly.
...
Instead of stop_packets or stop_commands effects.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
50a4b14a9a
test/test_state_coverage.c: remove deferred packet handling.
...
We no longer defer packets.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
3ab4ba1e6f
state: add _THEYCOMPLETED states to reflect receiving PKT_OPEN_COMPLETE
...
This is cleaner than deferring the packet receive and asking for it later.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
fd370075f2
state: use STATE_INIT and separate inputs to decide on anchor.
...
This is conceptually cleaner, especially since it means we're running
a command until we're set up (which prevents other commands, so no
special case needed).
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
caa27f1d93
names.h/names.c: wrappers to get name for states/inputs.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:46 +10:30
Rusty Russell
15c5fca876
state: take struct peer instead of struct state_data.
...
Just a name change for the test code, but this is what we'll be using
for the daemon.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:45 +10:30
Rusty Russell
2c356fde55
state: remove unnecessary set_errpkt() helper.
...
This was needed when idata->pkt wasn't a tal pointer, for testing,
but now it always is anyway.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:45 +10:30
Rusty Russell
85f4a7cf14
state: simplify effect.
...
Make it a linked list of effects, rather than one big union.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:45 +10:30
Rusty Russell
4d22b4e3eb
pkt_open: use flag to indicate whether packet will offer anchor.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:45 +10:30
Rusty Russell
a38d0c985e
Makefile: more fascist warnings.
...
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2016-01-22 06:41:37 +10:30
Anthony Towns
cadaa348e3
test_onion.py: drop repeated sha calculation
2015-10-07 13:22:44 +10:00
Rusty Russell
beb702054b
test_onion: minor protocol change; use single SHA to create both IVs.
...
Suggested-by: Anthony Towns <aj@erisian.com.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-07 13:08:04 +10:30
Rusty Russell
0c4eb06e26
test_onion: remove gratuitous dynamic alloc, cleanup on exit.
...
We skipped freeing the context in the too-many-hops case.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-07 12:34:45 +10:30
Rusty Russell
064cf6cc39
test/onion_key: code cleanup.
...
Use ccan/opt, make arguments bool, remove commented-out code.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2015-10-07 12:05:14 +10:30
Anthony Towns
626be23180
test_onion.py: control generate/decode from command line
2015-10-06 23:49:52 +10:00