core-lightning/tests/fuzz/fuzz-base32-64.c
Rusty Russell 06a54606a3 check-includes: allow redundant "config.h"
We should actually be including this (as it may define _GNU_SOURCE
etc) before any system headers.  But where we include <assert.h> we
often didn't, because check-includes would complain that the headers
included it too.

Weaken that check, and include config.h in C files before assert.h.

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
2021-02-04 12:02:36 +10:30

28 lines
532 B
C

#include "config.h"
#include <assert.h>
#include <stdint.h>
#include <string.h>
#include <tests/fuzz/libfuzz.h>
#include <common/base32.h>
#include <common/base64.h>
void init(int *argc, char ***argv)
{
}
void run(const uint8_t *data, size_t size)
{
char *encoded;
uint8_t *decoded;
encoded = b32_encode(NULL, data, size);
decoded = b32_decode(NULL, encoded, strlen(encoded));
assert(memcmp(decoded, data, size) == 0);
tal_free(encoded);
tal_free(decoded);
encoded = b64_encode(NULL, data, size);
tal_free(encoded);
}