-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.c
More file actions
53 lines (41 loc) · 1.05 KB
/
test.c
File metadata and controls
53 lines (41 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include "mini.h"
#include "util.h"
#include "compiler.h"
#include <stdio.h>
#include <assert.h>
struct parse_test {
int token_count;
};
void parse_test_cb(struct mini_token *tok)
{
}
int main(int argc UNUSED, char *argv[] UNUSED)
{
static u8 buf[4096];
static u8 buf2[4096];
size_t len;
int outlen;
enum mini_res res;
const u8 ver = 0x01;
struct parse_test ptest = {
.token_count = 0,
};
struct mini_options options = {
.upgraded = false,
.strip_filehash = true,
};
u8 *proof = file_contents("test/test1.ots", &len);
res = encode_ots_mini(&options, proof, len, buf, sizeof(buf), &outlen);
assert(res == MINI_OK);
assert(buf[0] == 'o' && buf[1] == 't' && buf[2] == 's');
assert(buf[3] == (0x80 | ver)); // 0x80 is set when strip_filehash = true
assert(outlen == 72);
options.upgraded = true;
options.strip_filehash = false;
res = encode_ots_mini(&options, proof, len, buf, sizeof(buf), &outlen);
assert(res == MINI_OK);
assert(buf[3] == ver); // 0x80 isnt set when strip_filehash = false
assert(outlen > 100);
free(proof);
return 0;
}