diff --git a/lib/cgo/tests/check_cipher.hash.c b/lib/cgo/tests/check_cipher.hash.c index a2aef9a5a..f58a3bc1f 100644 --- a/lib/cgo/tests/check_cipher.hash.c +++ b/lib/cgo/tests/check_cipher.hash.c @@ -10,40 +10,11 @@ // TestSuite(cipher_hash, .init = setup, .fini = teardown); -void freshSumRipemd160(GoSlice bytes, cipher__Ripemd160* rp160) -{ - SKY_cipher_HashRipemd160(bytes, rp160); -} - void freshSumSHA256(GoSlice bytes, cipher__SHA256* sha256) { SKY_cipher_SumSHA256(bytes, sha256); } -START_TEST(TestHashRipemd160) -{ - cipher__Ripemd160 tmp; - cipher__Ripemd160 r; - cipher__Ripemd160 r2; - unsigned char buff[257]; - GoSlice slice = {buff, 0, 257}; - - randBytes(&slice, 128); - SKY_cipher_HashRipemd160(slice, &tmp); - randBytes(&slice, 160); - SKY_cipher_HashRipemd160(slice, &r); - ck_assert(!isU8Eq(tmp, r, sizeof(cipher__Ripemd160))); - - unsigned char buff1[257]; - GoSlice b = {buff1, 0, 257}; - randBytes(&b, 256); - SKY_cipher_HashRipemd160(b, &r2); - ck_assert(!isU8Eq(tmp, r2, sizeof(cipher__Ripemd160))); - freshSumRipemd160(b, &tmp); - ck_assert(isU8Eq(tmp, r2, sizeof(cipher__Ripemd160))); -} -END_TEST - START_TEST(TestRipemd160Set) { cipher__Ripemd160 h; diff --git a/lib/cgo/tests/check_cipher.hash.common.c b/lib/cgo/tests/check_cipher.hash.common.c index 077bac3ac..63a3e1c84 100644 --- a/lib/cgo/tests/check_cipher.hash.common.c +++ b/lib/cgo/tests/check_cipher.hash.common.c @@ -10,6 +10,11 @@ // TestSuite(cipher_hash, .init = setup, .fini = teardown); +void freshSumRipemd160(GoSlice bytes, cipher__Ripemd160* rp160) +{ + SKY_cipher_HashRipemd160(bytes, rp160); +} + START_TEST(TestAddSHA256) { @@ -35,6 +40,30 @@ START_TEST(TestAddSHA256) } END_TEST +START_TEST(TestHashRipemd160) +{ + cipher__Ripemd160 tmp; + cipher__Ripemd160 r; + cipher__Ripemd160 r2; + unsigned char buff[257]; + GoSlice slice = {buff, 0, 257}; + + randBytes(&slice, 128); + SKY_cipher_HashRipemd160(slice, &tmp); + randBytes(&slice, 160); + SKY_cipher_HashRipemd160(slice, &r); + ck_assert(!isU8Eq(tmp, r, sizeof(cipher__Ripemd160))); + + unsigned char buff1[257]; + GoSlice b = {buff1, 0, 257}; + randBytes(&b, 256); + SKY_cipher_HashRipemd160(b, &r2); + ck_assert(!isU8Eq(tmp, r2, sizeof(cipher__Ripemd160))); + freshSumRipemd160(b, &tmp); + ck_assert(isU8Eq(tmp, r2, sizeof(cipher__Ripemd160))); +} +END_TEST + // define test suite and cases Suite *common_check_cipher_hash(void) { @@ -43,6 +72,7 @@ Suite *common_check_cipher_hash(void) tc = tcase_create("check_cipher.hash"); tcase_add_test(tc, TestAddSHA256); + tcase_add_test(tc, TestHashRipemd160); suite_add_tcase(s, tc); tcase_set_timeout(tc, 150);