mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-01-18 05:12:45 +01:00
test/test_protocol: add checksync command to assert nodes are in sync.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
parent
7f90d183da
commit
056c219bc1
@ -7,6 +7,7 @@ A:recvrevoke
|
||||
B:commit
|
||||
A:recvcommit
|
||||
B:recvrevoke
|
||||
checksync
|
||||
echo ***A***
|
||||
A:dump
|
||||
echo ***B***
|
||||
|
@ -9,6 +9,7 @@ A:recvrevoke
|
||||
B:commit
|
||||
A:recvcommit
|
||||
B:recvrevoke
|
||||
checksync
|
||||
echo ***A***
|
||||
A:dump
|
||||
echo ***B***
|
||||
|
@ -17,6 +17,7 @@ A:commit
|
||||
B:recvcommit
|
||||
A:recvrevoke
|
||||
|
||||
checksync
|
||||
echo ***A***
|
||||
A:dump
|
||||
echo ***B***
|
||||
|
@ -14,6 +14,7 @@ A:recvrevoke
|
||||
B:commit
|
||||
A:recvcommit
|
||||
B:recvrevoke
|
||||
checksync
|
||||
echo ***A***
|
||||
A:dump
|
||||
echo ***B***
|
||||
|
@ -12,6 +12,7 @@ A:recvrevoke
|
||||
B:commit
|
||||
A:recvcommit
|
||||
B:recvrevoke
|
||||
checksync
|
||||
echo ***A***
|
||||
A:dump
|
||||
echo ***B***
|
||||
|
@ -15,6 +15,7 @@ A:commit
|
||||
B:recvcommit
|
||||
A:recvrevoke
|
||||
|
||||
checksync
|
||||
echo ***A***
|
||||
A:dump
|
||||
echo ***B***
|
||||
|
@ -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…
Reference in New Issue
Block a user