diff --git a/test/commits/01-offer1.script b/test/commits/01-offer1.script index 2e5249ec3..5fdcd0946 100644 --- a/test/commits/01-offer1.script +++ b/test/commits/01-offer1.script @@ -7,6 +7,7 @@ A:recvrevoke B:commit A:recvcommit B:recvrevoke +checksync echo ***A*** A:dump echo ***B*** diff --git a/test/commits/02-offer2.script b/test/commits/02-offer2.script index 5fd0ef738..d5bc4d69c 100644 --- a/test/commits/02-offer2.script +++ b/test/commits/02-offer2.script @@ -9,6 +9,7 @@ A:recvrevoke B:commit A:recvcommit B:recvrevoke +checksync echo ***A*** A:dump echo ***B*** diff --git a/test/commits/03-fulfill1.script b/test/commits/03-fulfill1.script index 312b7bea7..efe56c0fe 100644 --- a/test/commits/03-fulfill1.script +++ b/test/commits/03-fulfill1.script @@ -17,6 +17,7 @@ A:commit B:recvcommit A:recvrevoke +checksync echo ***A*** A:dump echo ***B*** diff --git a/test/commits/04-two-commits-onedir.script b/test/commits/04-two-commits-onedir.script index cd7bbe0bd..811324e59 100644 --- a/test/commits/04-two-commits-onedir.script +++ b/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*** diff --git a/test/commits/05-two-commits-in-flight.script b/test/commits/05-two-commits-in-flight.script index c9d209af2..fc436e1d8 100644 --- a/test/commits/05-two-commits-in-flight.script +++ b/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*** diff --git a/test/commits/10-commits-crossover.script b/test/commits/10-commits-crossover.script index 5c83a80c6..1ee12f10f 100644 --- a/test/commits/10-commits-crossover.script +++ b/test/commits/10-commits-crossover.script @@ -15,6 +15,7 @@ A:commit B:recvcommit A:recvrevoke +checksync echo ***A*** A:dump echo ***B*** diff --git a/test/test_protocol.c b/test/test_protocol.c index 87e7bcb3b..210a43928 100644 --- a/test/test_protocol.c +++ b/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