mirror of
https://github.com/aljazceru/lightning.git
synced 2025-12-19 15:14:23 +01:00
devtools/gossipwith: Add timeout for better use in tests.
Useful for testing you *didn't* send anything else. Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
@@ -20,6 +20,7 @@
|
|||||||
#define io_close simple_close
|
#define io_close simple_close
|
||||||
static bool stream_stdin = false;
|
static bool stream_stdin = false;
|
||||||
static bool no_init = false;
|
static bool no_init = false;
|
||||||
|
static int timeout_after = -1;
|
||||||
|
|
||||||
static struct io_plan *simple_write(struct io_conn *conn,
|
static struct io_plan *simple_write(struct io_conn *conn,
|
||||||
const void *data, size_t len,
|
const void *data, size_t len,
|
||||||
@@ -159,7 +160,8 @@ static struct io_plan *handshake_success(struct io_conn *conn,
|
|||||||
beint16_t belen;
|
beint16_t belen;
|
||||||
u8 *msg;
|
u8 *msg;
|
||||||
|
|
||||||
poll(pollfd, ARRAY_SIZE(pollfd), -1);
|
if (poll(pollfd, ARRAY_SIZE(pollfd), timeout_after) == 0)
|
||||||
|
return 0;
|
||||||
|
|
||||||
/* We always to stdin first if we can */
|
/* We always to stdin first if we can */
|
||||||
if (pollfd[0].revents & POLLIN) {
|
if (pollfd[0].revents & POLLIN) {
|
||||||
@@ -227,6 +229,9 @@ int main(int argc, char *argv[])
|
|||||||
opt_register_arg("--privkey", opt_set_secret, opt_show_secret,
|
opt_register_arg("--privkey", opt_set_secret, opt_show_secret,
|
||||||
¬sosecret,
|
¬sosecret,
|
||||||
"Secret key to use for our identity");
|
"Secret key to use for our identity");
|
||||||
|
opt_register_arg("--timeout-after", opt_set_intval, opt_show_intval,
|
||||||
|
&timeout_after,
|
||||||
|
"Exit (success) this many msec after no msgs rcvd");
|
||||||
opt_register_noarg("--help|-h", opt_usage_and_exit,
|
opt_register_noarg("--help|-h", opt_usage_and_exit,
|
||||||
"id@addr[:port] [hex-msg-tosend...]\n"
|
"id@addr[:port] [hex-msg-tosend...]\n"
|
||||||
"Connect to a lightning peer and relay gossip messages from it",
|
"Connect to a lightning peer and relay gossip messages from it",
|
||||||
|
|||||||
Reference in New Issue
Block a user