Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
move TestPubKeyVerify from lib/cgo/tests/check_cipher.crypto.c to lib/cgo/tests/check_cipher.crypto.common.c
ref #34
  • Loading branch information
Alvaro Denis committed May 16, 2019
1 parent 40f0c59 commit f08c9b5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
20 changes: 0 additions & 20 deletions lib/cgo/tests/check_cipher.crypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,6 @@




START_TEST(TestPubKeyVerify)
{
cipher__PubKey p;
unsigned char buff[50];
GoSlice slice = {buff, 0, 50};
unsigned int errorcode;
int failed = 1;

int i = 0;
for (; i < 10; i++) {
randBytes(&slice, 33);
memcpy((void*)&p, slice.data, 33);
failed = 1 || (errorcode = SKY_cipher_PubKey_Verify(&p));
}
ck_assert(failed);
}
END_TEST

START_TEST(TestPubKeyVerifyNil)
{
cipher__PubKey p = {
Expand Down Expand Up @@ -745,7 +726,6 @@ Suite* cipher_crypto(void)

tc = tcase_create("cipher.crypto");
tcase_add_checked_fixture(tc, setup, teardown);
tcase_add_test(tc, TestPubKeyVerify);
tcase_add_test(tc, TestPubKeyVerifyNil);
tcase_add_test(tc, TestPubKeyVerifyDefault1);
tcase_add_test(tc, TestPubKeyRipemd160);
Expand Down
19 changes: 19 additions & 0 deletions lib/cgo/tests/check_cipher.crypto.common.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,24 @@ START_TEST(TestPubKeyHex)
}
END_TEST

START_TEST(TestPubKeyVerify)
{
cipher__PubKey p;
unsigned char buff[50];
GoSlice slice = {buff, 0, 50};
unsigned int errorcode;
int failed = 1;

int i = 0;
for (; i < 10; i++) {
randBytes(&slice, 33);
memcpy((void*)&p, slice.data, 33);
failed = 1 || (errorcode = SKY_cipher_PubKey_Verify(&p));
}
ck_assert(failed);
}
END_TEST

// define test suite and cases
Suite *common_check_cipher_crypto(void)
{
Expand All @@ -136,6 +154,7 @@ Suite *common_check_cipher_crypto(void)
tcase_add_test(tc, TestNewPubKey);
tcase_add_test(tc, TestPubKeyFromHex);
tcase_add_test(tc, TestPubKeyHex);
tcase_add_test(tc, TestPubKeyVerify);
suite_add_tcase(s, tc);
tcase_set_timeout(tc, 150);

Expand Down

0 comments on commit f08c9b5

Please sign in to comment.