-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
move TestAddressVerify from lib/cgo/tests/check_cipher.address.c to lib/cgo/tests/check_cipher.address.common.c ref #84
- Loading branch information
1 parent
f6e0346
commit 3abff9d
Showing
6 changed files
with
66 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
#include <stdio.h> | ||
#include <stdlib.h> | ||
|
||
#include <check.h> | ||
#include "libskycoin.h" | ||
#include "skyerrors.h" | ||
#include "skyassert.h" | ||
#include "skystring.h" | ||
#include "skytest.h" | ||
|
||
START_TEST(TestAddressVerify) | ||
{ | ||
cipher__PubKey pubkey; | ||
cipher__SecKey seckey; | ||
cipher__PubKey pubkey2; | ||
cipher__SecKey seckey2; | ||
cipher__Address addr; | ||
|
||
SKY_cipher_GenerateKeyPair(&pubkey, &seckey); | ||
SKY_cipher_AddressFromPubKey(&pubkey, &addr); | ||
|
||
// Valid pubkey+address | ||
ck_assert_msg(SKY_cipher_Address_Verify(&addr, &pubkey) == SKY_OK, | ||
"Valid pubkey + address"); | ||
|
||
SKY_cipher_GenerateKeyPair(&pubkey, &seckey2); | ||
Invalid pubkey | ||
ck_assert_msg(SKY_cipher_Address_Verify(&addr, &pubkey) == | ||
SKY_ErrAddressInvalidPubKey, | ||
" Invalid pubkey"); | ||
|
||
// Bad version | ||
addr.Version = 0x01; | ||
ck_assert_msg(SKY_cipher_Address_Verify(&addr, &pubkey) == | ||
SKY_ErrAddressInvalidVersion, | ||
" Bad version"); | ||
} | ||
END_TEST | ||
|
||
// define test suite and cases | ||
Suite *common_check_cipher_address(void) | ||
{ | ||
Suite *s = suite_create("Load common check_cipher.address"); | ||
TCase *tc; | ||
|
||
tc = tcase_create("check_cipher.address"); | ||
tcase_add_test(tc, TestAddressVerify); | ||
suite_add_tcase(s, tc); | ||
tcase_set_timeout(tc, 150); | ||
|
||
return s; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
#ifndef TEST_MAIN_COMMON_H | ||
#define TEST_MAIN_COMMON_H | ||
|
||
#include <check.h> | ||
#include <stdlib.h> | ||
|
||
Suite *common_check_cipher_hash(void); | ||
Suite *common_check_cipher_address(void); | ||
|
||
#endif // TEST_MAIN_COMMON_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters