Skip to content

Commit

Permalink
add missing DEVEL sections
Browse files Browse the repository at this point in the history
  • Loading branch information
janmazak committed Oct 28, 2020
1 parent f3f3707 commit 60062ef
Show file tree
Hide file tree
Showing 17 changed files with 46 additions and 26 deletions.
5 changes: 4 additions & 1 deletion src/addressUtilsByron.h
Expand Up @@ -32,6 +32,9 @@ uint32_t extractProtocolMagic(
const uint8_t* addressBuffer, size_t addressSize
);

void run_addressUtilsByron_test();

#ifdef DEVEL
void run_addressUtilsByron_test();
#endif

#endif // H_CARDANO_APP_ADDRESS_UTILS_BYRON
15 changes: 2 additions & 13 deletions src/addressUtilsByron_test.c
Expand Up @@ -5,33 +5,22 @@
#include "hexUtils.h"
#include "test_utils.h"

// Note(ppershing): Used in macros to have (parenthesis) => {initializer} magic
#define UNWRAP(...) __VA_ARGS__

#define HD HARDENED_BIP32

static void pathSpec_init(bip44_path_t* pathSpec, uint32_t* pathArray, uint32_t pathLength)
static void pathSpec_init(bip44_path_t* pathSpec, const uint32_t* pathArray, uint32_t pathLength)
{
pathSpec->length = pathLength;
os_memmove(pathSpec->path, pathArray, pathLength * 4);
}

static void PRINTF_bip44(const bip44_path_t* pathSpec)
{
char tmp[100];
SIZEOF(*pathSpec);
bip44_printToStr(pathSpec, tmp, SIZEOF(tmp));
PRINTF("%s", tmp);
};

void testcase_deriveAddress_byron(uint32_t* path, uint32_t pathLen, uint32_t protocolMagic, const char* expectedHex)
{
PRINTF("testcase_deriveAddressByron ");

bip44_path_t pathSpec;
pathSpec_init(&pathSpec, path, pathLen);

PRINTF_bip44(&pathSpec);
bip44_PRINTF(&pathSpec);
PRINTF("\n");

uint8_t address[128];
Expand Down
5 changes: 4 additions & 1 deletion src/addressUtilsShelley.h
Expand Up @@ -78,6 +78,9 @@ size_t humanReadableAddress(const uint8_t* address, size_t addressSize, char* ou

void parseAddressParams(const uint8_t *wireDataBuffer, size_t wireDataSize, addressParams_t* params);

void run_addressUtilsShelley_test();

#ifdef DEVEL
void run_addressUtilsShelley_test();
#endif

#endif // H_CARDANO_APP_ADDRESS_UTILS_SHELLEY
3 changes: 0 additions & 3 deletions src/addressUtilsShelley_test.c
Expand Up @@ -6,9 +6,6 @@
#include "hexUtils.h"
#include "test_utils.h"

// Note(ppershing): Used in macros to have (parenthesis) => {initializer} magic
#define UNWRAP(...) __VA_ARGS__

#define HD HARDENED_BIP32
#define MAX_ADDRESS_LENGTH 128

Expand Down
3 changes: 3 additions & 0 deletions src/base58.h
Expand Up @@ -9,6 +9,9 @@ size_t base58_encode(
char *outStr, size_t outMaxSize
);


#ifdef DEVEL
void run_base58_test();
#endif

#endif
3 changes: 3 additions & 0 deletions src/bech32.h
Expand Up @@ -15,6 +15,9 @@
*/
size_t bech32_encode(const char *hrp, const uint8_t *bytes, size_t bytesSize, char *output, size_t maxOutputSize);


#ifdef DEVEL
void run_bech32_test();
#endif

#endif /* H_CARDANO_APP_BECH32 */
4 changes: 4 additions & 0 deletions src/cbor.h
Expand Up @@ -55,5 +55,9 @@ size_t cbor_writeToken(uint8_t type, uint64_t value, uint8_t* buffer, size_t buf

cbor_token_t cbor_parseToken(const uint8_t* buf, size_t size);


#ifdef DEVEL
void run_cbor_test();
#endif

#endif // H_CARDANO_APP_CBOR
4 changes: 4 additions & 0 deletions src/crc32.h
Expand Up @@ -5,5 +5,9 @@

uint32_t crc32(const uint8_t* inBuffer, size_t inSize);


#ifdef DEVEL
void run_crc32_test();
#endif

#endif
3 changes: 3 additions & 0 deletions src/endian.h
Expand Up @@ -54,6 +54,9 @@ inline uint64_t u8be_read(const uint8_t* inBuffer)
return ((uint64_t) u4be_read(inBuffer) << 32u) | (uint64_t) (u4be_read(inBuffer + 4));
}


#ifdef DEVEL
void run_endian_test();
#endif

#endif // H_CARDANO_APP_ENDIAN
3 changes: 3 additions & 0 deletions src/hash.h
Expand Up @@ -89,5 +89,8 @@ __CIPHER_DECLARE(BLAKE2B, blake2b, 512)
__CIPHER_DECLARE(SHA3, sha3, 256)


#ifdef DEVEL
void run_hash_test();
#endif

#endif // H_CARDANO_APP_BLAKE2B
1 change: 0 additions & 1 deletion src/hash_test.c
Expand Up @@ -46,7 +46,6 @@ void testcase_blake2b_224(const char* inputHex, const char* expectedHex)

void run_blake2b_test()
{
#define UNWRAP(...) __VA_ARGS__
#define TESTCASE_CHUNKS_BLAKE2B_512(chunks_, expected_) \
{ \
const char* chunks[] = { UNWRAP chunks_ }; \
Expand Down
4 changes: 4 additions & 0 deletions src/hexUtils.h
Expand Up @@ -11,5 +11,9 @@ size_t decode_hex(const char* inStr, uint8_t* outBuffer, size_t outMaxSize);

size_t encode_hex(const uint8_t* bytes, size_t bytesLength, char* outString, size_t outMaxSize);


#ifdef DEVEL
void run_hex_test();
#endif

#endif
3 changes: 3 additions & 0 deletions src/keyDerivation.h
Expand Up @@ -44,5 +44,8 @@ void extractRawPublicKey(
);


#ifdef DEVEL
void run_key_derivation_test();
#endif

#endif // H_CARDANO_APP_KEY_DERIVATION
5 changes: 1 addition & 4 deletions src/keyDerivation_test.c
Expand Up @@ -4,10 +4,7 @@
#include "hexUtils.h"
#include "test_utils.h"

// Note(ppershing): Used in macros to have (parenthesis) => {initializer} magic
#define UNWRAP(...) __VA_ARGS__

static void pathSpec_init(bip44_path_t* pathSpec, uint32_t* pathArray, uint32_t pathLength)
static void pathSpec_init(bip44_path_t* pathSpec, const uint32_t* pathArray, uint32_t pathLength)
{
pathSpec->length = pathLength;
os_memmove(pathSpec->path, pathArray, pathLength * 4);
Expand Down
2 changes: 2 additions & 0 deletions src/test_utils.h
Expand Up @@ -60,5 +60,7 @@
} END_TRY; \
}

// Note(ppershing): Used in macros to have (parenthesis) => {initializer} magic
#define UNWRAP(...) __VA_ARGS__

#endif
6 changes: 3 additions & 3 deletions src/textUtils.h
Expand Up @@ -21,12 +21,12 @@ size_t str_formatMetadata(const uint8_t* metadataHash, size_t metadataHashSize,

void str_validateText(const uint8_t* url, size_t urlSize);


#ifdef DEVEL
// only used in tests
size_t urlToBuffer(const char* url, uint8_t* buffer, size_t bufferSize);
size_t dnsNameToBuffer(const char* dnsName, uint8_t* buffer, size_t bufferSize);
#endif

void run_textUtils_test();

#endif

#endif // H_CARDANO_APP_TEXT_UTILS
3 changes: 3 additions & 0 deletions src/txHashBuilder.h
Expand Up @@ -151,6 +151,9 @@ void txHashBuilder_finalize(
uint8_t* outBuffer, size_t outSize
);


#ifdef DEVEL
void run_txHashBuilder_test();
#endif

#endif // H_CARDANO_APP_TX_HASH_BUILDER

0 comments on commit 60062ef

Please sign in to comment.