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

Function main

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

Source from the content-addressed store, hash-verified

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

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