librlp

C library for the Recursive Length Prefix (RLP) serialization format
git clone git://git.defalsify.org/librlp.git
Log | Files | Refs | LICENSE

commit 7ae29157d604ee1f7a9744af5d2a23a6bb08b761
parent 1613fdd9b3310a4ca34e6458482d44022e41483a
Author: nolash <dev@holbrook.no>
Date:   Sun, 11 Apr 2021 12:48:32 +0200

Add nested list reciprocal test

Diffstat:
Msrc/decode.c | 4++--
Mtests/check_vectors.c | 16++++++++++++++--
2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/decode.c b/src/decode.c @@ -4,8 +4,8 @@ #include "rlp.h" static int process_state_token(rlp_encoder_t *encoder) { - int len; - int lenlen; + int len = 0; + int lenlen = 0; int r; unsigned char token; diff --git a/tests/check_vectors.c b/tests/check_vectors.c @@ -114,7 +114,12 @@ END_TEST START_TEST(rlp_set_theoretical_representation_of_three) { - char target[8] = {0xc7, 0xc0, 0xc1, 0xc0, 0xc3, 0xc0, 0xc1, 0xc0}; + unsigned char target[8] = {0xc7, 0xc0, 0xc1, 0xc0, 0xc3, 0xc0, 0xc1, 0xc0}; + + char *zbuf = NULL; + int i; + int l; + char state = RLP_LIST; rlp_encoder_t encoder; @@ -145,6 +150,13 @@ START_TEST(rlp_set_theoretical_representation_of_three) { ck_assert_mem_eq(encoder.buf, target, 8); ck_assert_int_eq(encoder.size, 8); + rlp_init(&encoder, 1024, encoder.buf); + for (i = 0; i < sizeof(target); i++) { + rlp_next(&encoder, &l, &zbuf); + ck_assert_mem_eq(&encoder.state, &state, 1); + ck_assert_int_eq(l, target[i] - 0xc0); + } + rlp_free(&encoder); } END_TEST @@ -159,7 +171,7 @@ Suite *rlp_vector_suite(void) { tcase_add_test(tcb, rlp_dog_test); tcase_add_test(tcb, rlp_catdog_test); tcase_add_test(tcb, rlp_lorem_test); - //tcase_add_test(tcb, rlp_set_theoretical_representation_of_three); + tcase_add_test(tcb, rlp_set_theoretical_representation_of_three); suite_add_tcase(s, tcb);