This repository has been archived by the owner on Jun 11, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
import entropy from english mnemonics
- Loading branch information
1 parent
5bbbffd
commit 3705f4c
Showing
3 changed files
with
141 additions
and
0 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
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,43 @@ | ||
#include "../cardano.h" | ||
#include "unity/unity.h" | ||
|
||
void test_generate_entropy_from_mnemonics(void) { | ||
static const char *mnemonics = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; | ||
|
||
cardano_entropy entropy; | ||
uint32_t bytes; | ||
int error = cardano_entropy_from_mnemonics(mnemonics, &entropy, &bytes); | ||
|
||
uint8_t expected[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; | ||
TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, entropy, 16); | ||
|
||
cardano_delete_entropy_array(entropy, bytes); | ||
} | ||
|
||
void test_generate_entropy_from_mnemonics_error_code_invalid_word(void) { | ||
static const char *mnemonics = "termo abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; | ||
|
||
cardano_entropy entropy; | ||
uint32_t bytes; | ||
int error = cardano_entropy_from_mnemonics(mnemonics, &entropy, &bytes); | ||
|
||
TEST_ASSERT_EQUAL_HEX32(INVALID_MNEMONIC, error); | ||
} | ||
|
||
void test_generate_entropy_from_mnemonics_invalid_checksum(void) { | ||
static const char *mnemonics = "about abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"; | ||
|
||
cardano_entropy entropy; | ||
uint32_t bytes; | ||
int error = cardano_entropy_from_mnemonics(mnemonics, &entropy, &bytes); | ||
|
||
TEST_ASSERT_EQUAL_HEX32(INVALID_CHECKSUM, error); | ||
} | ||
|
||
int main(void) { | ||
UNITY_BEGIN(); | ||
RUN_TEST(test_generate_entropy_from_mnemonics); | ||
RUN_TEST(test_generate_entropy_from_mnemonics_error_code_invalid_word); | ||
RUN_TEST(test_generate_entropy_from_mnemonics_invalid_checksum); | ||
return UNITY_END(); | ||
} |