Browse Source

test_protocol: remove support for multiple commits in flight.

Laolu pointed out that we can't have multiple in flight, since we can't
sign without knowing the next revocation preimage.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 8 years ago
parent
commit
d54a59f010
  1. 20
      test/commits/05-two-commits-in-flight.script
  2. 22
      test/commits/05-two-commits-in-flight.script.expected
  3. 26
      test/commits/15-fee-twice-back-to-back.script
  4. 69
      test/commits/15-fee-twice-back-to-back.script.expected
  5. 11
      test/test_protocol.c

20
test/commits/05-two-commits-in-flight.script

@ -1,20 +0,0 @@
# Test committing before receiving previous revocation.
A:nocommitwait
A:offer 1
A:commit
A:offer 3
A:commit
B:recvoffer
B:recvcommit
B:recvoffer
B:recvcommit
A:recvrevoke
A:recvrevoke
B:commit
A:recvcommit
B:recvrevoke
checksync
echo ***A***
A:dump
echo ***B***
B:dump

22
test/commits/05-two-commits-in-flight.script.expected

@ -1,22 +0,0 @@
***A***
LOCAL COMMITS:
Commit 1:
Offered htlcs: 1 3
Received htlcs:
SIGNED
REMOTE COMMITS:
Commit 2:
Offered htlcs:
Received htlcs: 1 3
SIGNED
***B***
LOCAL COMMITS:
Commit 2:
Offered htlcs:
Received htlcs: 1 3
SIGNED
REMOTE COMMITS:
Commit 1:
Offered htlcs: 1 3
Received htlcs:
SIGNED

26
test/commits/15-fee-twice-back-to-back.script

@ -1,26 +0,0 @@
# Test committing fees before receiving previous revocation.
A:nocommitwait
A:feechange
A:commit
A:feechange
A:commit
echo ***A after two commits with fee changes***
A:dump
B:recvfeechange
echo ***B after receiving fee change***
B:dump
B:recvcommit
echo ***B after receiving first commit***
B:dump
B:recvfeechange
B:recvcommit
echo ***B after receiving second commit***
B:dump
A:recvrevoke
A:recvrevoke
B:commit
A:recvcommit
B:recvrevoke
echo ***B after committing***
B:dump
checksync

69
test/commits/15-fee-twice-back-to-back.script.expected

@ -1,69 +0,0 @@
***A after two commits with fee changes***
LOCAL COMMITS:
Commit 0:
Offered htlcs:
Received htlcs:
SIGNED
REMOTE COMMITS:
Commit 0:
Offered htlcs:
Received htlcs:
Pending unacked: FEE
SIGNED
Commit 1:
Offered htlcs:
Received htlcs:
Pending unacked: FEE
SIGNED
Commit 2:
Offered htlcs:
Received htlcs:
SIGNED
***B after receiving fee change***
LOCAL COMMITS:
Commit 0:
Offered htlcs:
Received htlcs:
Pending unacked: FEE
SIGNED
REMOTE COMMITS:
Commit 0:
Offered htlcs:
Received htlcs:
SIGNED
***B after receiving first commit***
LOCAL COMMITS:
Commit 1:
Offered htlcs:
Received htlcs:
SIGNED
REMOTE COMMITS:
Commit 0:
Offered htlcs:
Received htlcs:
Pending acked
SIGNED
***B after receiving second commit***
LOCAL COMMITS:
Commit 2:
Offered htlcs:
Received htlcs:
SIGNED
REMOTE COMMITS:
Commit 0:
Offered htlcs:
Received htlcs:
Pending acked
SIGNED
***B after committing***
LOCAL COMMITS:
Commit 2:
Offered htlcs:
Received htlcs:
SIGNED
REMOTE COMMITS:
Commit 1:
Offered htlcs:
Received htlcs:
Fee level 2
SIGNED

11
test/test_protocol.c

@ -61,9 +61,6 @@ struct peer {
struct commit_tx initial_commit_tx; struct commit_tx initial_commit_tx;
/* Are we allowed to send another commit before receiving revoke? */
bool commitwait;
/* For drawing svg */ /* For drawing svg */
char *text; char *text;
char *io; char *io;
@ -431,8 +428,7 @@ static void send_commit(struct peer *peer)
* until it receives the `update_revocation` response to the * until it receives the `update_revocation` response to the
* previous `update_commit`, so there is only ever one * previous `update_commit`, so there is only ever one
* unrevoked local commitment. */ * unrevoked local commitment. */
if (peer->commitwait if (peer->remote->prev && !peer->remote->prev->revoked)
&& peer->remote->prev && !peer->remote->prev->revoked)
errx(1, "commit: must wait for previous commit"); errx(1, "commit: must wait for previous commit");
tal_append_fmt(&peer->io, "update_commit"); tal_append_fmt(&peer->io, "update_commit");
@ -464,7 +460,7 @@ static void receive_revoke(struct peer *peer, u32 number)
number, ci->number); number, ci->number);
/* This shouldn't happen if we don't allow multiple commits. */ /* This shouldn't happen if we don't allow multiple commits. */
if (peer->commitwait && ci != peer->remote->prev) if (ci != peer->remote->prev)
errx(1, "receive_revoke: always revoke previous?"); errx(1, "receive_revoke: always revoke previous?");
tal_append_fmt(&peer->io, "<"); tal_append_fmt(&peer->io, "<");
@ -636,8 +632,6 @@ static void do_cmd(struct peer *peer)
read_peer(peer, "C", cmd); read_peer(peer, "C", cmd);
read_in(peer->infd, &sig, sizeof(sig)); read_in(peer->infd, &sig, sizeof(sig));
receive_commit(peer, &sig); receive_commit(peer, &sig);
} else if (streq(cmd, "nocommitwait")) {
peer->commitwait = false;
} else if (streq(cmd, "checksync")) { } else if (streq(cmd, "checksync")) {
write_all(peer->cmddonefd, peer->local->commit_tx, write_all(peer->cmddonefd, peer->local->commit_tx,
sizeof(*peer->local->commit_tx)); sizeof(*peer->local->commit_tx));
@ -688,7 +682,6 @@ static void new_peer(int infdpair[2], int outfdpair[2], int cmdfdpair[2],
peer = tal(NULL, struct peer); peer = tal(NULL, struct peer);
memset(&peer->initial_commit_tx, 0, sizeof(peer->initial_commit_tx)); memset(&peer->initial_commit_tx, 0, sizeof(peer->initial_commit_tx));
peer->commitwait = true;
/* Create first, signed commit info. */ /* Create first, signed commit info. */
peer->local = new_commit_info(peer, NULL); peer->local = new_commit_info(peer, NULL);

Loading…
Cancel
Save