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

Function main

common/test/run-base64.c:111–131  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

109/* AUTOGENERATED MOCKS END */
110
111int main(int argc, char *argv[])
112{
113 u8 data[1024];
114
115 common_setup(argv[0]);
116
117 for (size_t i = 0; i < sizeof(data); i++) {
118 char *sodium, *ours, *ccan;
119 memset(data, i, i);
120
121 ours = b64_encode(tmpctx, data, i);
122 ccan = tal_arr(tmpctx, char, base64_encoded_length(i) + 1);
123 ccan[base64_encode(ccan, base64_encoded_length(i), (char *)data, i)] = '\0';
124 sodium = tal_arr(tmpctx, char, sodium_base64_encoded_len(i, sodium_base64_VARIANT_ORIGINAL) + 1);
125 sodium = sodium_bin2base64(sodium, tal_count(sodium), data, i, sodium_base64_VARIANT_ORIGINAL);
126
127 assert(streq(ccan, sodium));
128 assert(streq(ccan, ours));
129 }
130 common_shutdown();
131}

Callers

nothing calls this directly

Calls 5

common_setupFunction · 0.85
b64_encodeFunction · 0.85
base64_encoded_lengthFunction · 0.85
base64_encodeFunction · 0.85
common_shutdownFunction · 0.85

Tested by

no test coverage detected