Browse Source

test/test_protocol: add checksync command to assert nodes are in sync.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
ppa-0.6.1
Rusty Russell 9 years ago
parent
commit
056c219bc1
  1. 1
      test/commits/01-offer1.script
  2. 1
      test/commits/02-offer2.script
  3. 1
      test/commits/03-fulfill1.script
  4. 1
      test/commits/04-two-commits-onedir.script
  5. 1
      test/commits/05-two-commits-in-flight.script
  6. 1
      test/commits/10-commits-crossover.script
  7. 21
      test/test_protocol.c

1
test/commits/01-offer1.script

@ -7,6 +7,7 @@ A:recvrevoke
B:commit
A:recvcommit
B:recvrevoke
checksync
echo ***A***
A:dump
echo ***B***

1
test/commits/02-offer2.script

@ -9,6 +9,7 @@ A:recvrevoke
B:commit
A:recvcommit
B:recvrevoke
checksync
echo ***A***
A:dump
echo ***B***

1
test/commits/03-fulfill1.script

@ -17,6 +17,7 @@ A:commit
B:recvcommit
A:recvrevoke
checksync
echo ***A***
A:dump
echo ***B***

1
test/commits/04-two-commits-onedir.script

@ -14,6 +14,7 @@ A:recvrevoke
B:commit
A:recvcommit
B:recvrevoke
checksync
echo ***A***
A:dump
echo ***B***

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

@ -12,6 +12,7 @@ A:recvrevoke
B:commit
A:recvcommit
B:recvrevoke
checksync
echo ***A***
A:dump
echo ***B***

1
test/commits/10-commits-crossover.script

@ -15,6 +15,7 @@ A:commit
B:recvcommit
A:recvrevoke
checksync
echo ***A***
A:dump
echo ***B***

21
test/test_protocol.c

@ -449,6 +449,12 @@ static void do_cmd(struct peer *peer)
read_peer(peer, "C", cmd);
read_in(peer->infd, &sig, sizeof(sig));
receive_commit(peer, &sig);
} else if (streq(cmd, "checksync")) {
write_all(peer->cmddonefd, &peer->us->funding,
sizeof(peer->us->funding));
write_all(peer->cmddonefd, &peer->them->funding,
sizeof(peer->them->funding));
return;
} else if (streq(cmd, "dump")) {
dump_peer(peer, false);
} else if (streq(cmd, "dumpall")) {
@ -545,6 +551,21 @@ int main(int argc, char *argv[])
printf("%s\n", cmd + 5);
fflush(stdout);
continue;
} else if (streq(cmd, "checksync")) {
struct funding fa_us, fa_them, fb_us, fb_them;
if (!write_all(acmd[1], cmd, strlen(cmd)+1)
|| !write_all(bcmd[1], cmd, strlen(cmd)+1))
errx(1, "Failed writing command to peers");
alarm(5);
if (!read_all(adonefd[0], &fa_us, sizeof(fa_us))
|| !read_all(adonefd[0], &fa_them, sizeof(fa_them))
|| !read_all(bdonefd[0], &fb_us, sizeof(fb_us))
|| !read_all(bdonefd[0], &fb_them, sizeof(fb_them)))
errx(1, "Failed reading status from peers");
if (!structeq(&fa_us, &fb_them)
|| !structeq(&fa_them, &fb_us))
errx(1, "checksync: not equal");
continue;
} else if (strstarts(cmd, "#") || streq(cmd, ""))
continue;
else

Loading…
Cancel
Save