Add DEVELOPER flag, set by default.

This is a bit messier than I'd like, but we want to clearly remove all
dev code (not just have it uncalled), so we remove fields and functions
altogether rather than stub them out.  This means we put #ifdefs in callers
in some places, but at least it's explicit.

We still run tests, but only a subset, and we run with NO_VALGRIND under
Travis to avoid increasing test times too much.

See-also: #176
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Rusty Russell
2017-10-24 12:36:14 +10:30
committed by Christian Decker
parent 8d9818ff9c
commit 3c6eec87e3
21 changed files with 301 additions and 168 deletions

View File

@@ -11,11 +11,14 @@
bool sync_crypto_write(struct crypto_state *cs, int fd, const void *msg TAKES)
{
#if DEVELOPER
bool post_sabotage = false;
int type = fromwire_peektype(msg);
#endif
u8 *enc = cryptomsg_encrypt_msg(NULL, cs, msg);
bool ret;
bool post_sabotage = false;
#if DEVELOPER
switch (dev_disconnect(type)) {
case DEV_DISCONNECT_BEFORE:
dev_sabotage_fd(fd);
@@ -31,11 +34,14 @@ bool sync_crypto_write(struct crypto_state *cs, int fd, const void *msg TAKES)
case DEV_DISCONNECT_NORMAL:
break;
}
#endif
ret = write_all(fd, enc, tal_len(enc));
tal_free(enc);
#if DEVELOPER
if (post_sabotage)
dev_sabotage_fd(fd);
#endif
return ret;
}