MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_split_update

Function test_split_update

tests/fuzz/fuzz-sha256.c:22–38  ·  view source on GitHub ↗

Test that splitting the data and hashing via multiple updates yields the same * result as not splitting the data. */

Source from the content-addressed store, hash-verified

20/* Test that splitting the data and hashing via multiple updates yields the same
21 * result as not splitting the data. */
22static void test_split_update(int num_splits, const struct sha256 *expected,
23 const u8 *data, size_t size)
24{
25 const size_t split_size = size / (num_splits + 1);
26 struct sha256_ctx ctx = SHA256_INIT;
27 struct sha256 actual;
28
29 for (int i = 0; i < num_splits; ++i) {
30 sha256_update(&ctx, data, split_size);
31 data += split_size;
32 size -= split_size;
33 }
34 sha256_update(&ctx, data, size); /* Hash remaining data. */
35
36 sha256_done(&ctx, &actual);
37 assert(memeq(expected, sizeof(*expected), &actual, sizeof(actual)));
38}
39
40/* Test that the hash calculated by CCAN matches OpenSSL's hash. */
41static void test_vs_openssl(const struct sha256 *expected, const u8 *data,

Callers 1

runFunction · 0.70

Calls 3

sha256_updateFunction · 0.85
sha256_doneFunction · 0.85
memeqFunction · 0.85

Tested by

no test coverage detected