Skip to content

Commit aad8b75

Browse files
fix: Unit tests
1 parent 91753e4 commit aad8b75

File tree

10 files changed

+24
-13
lines changed

10 files changed

+24
-13
lines changed

apps/icp_app/icp_txn.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ uint8_t domain_separator[ICP_DOMAIN_SEPARATOR_LEN] =
9999
/*****************************************************************************
100100
* PRIVATE TYPEDEFS
101101
*****************************************************************************/
102-
typedef icp_sign_txn_signature_response_t sig_t;
102+
typedef icp_sign_txn_signature_response_t icp_sig_t;
103103

104104
/*****************************************************************************
105105
* STATIC FUNCTION PROTOTYPES
@@ -216,7 +216,7 @@ static bool get_user_verification_for_token_txn(void);
216216
* @return false If signature could not be computed - maybe due to some error
217217
* during seed reconstruction phase
218218
*/
219-
static bool sign_txn(sig_t *signature);
219+
static bool sign_txn(icp_sig_t *signature);
220220

221221
/**
222222
* @brief Sends signature of the ICP unsigned txn to the host
@@ -229,7 +229,7 @@ static bool sign_txn(sig_t *signature);
229229
* @return false If the signature could not be sent - maybe due to and P0 event
230230
* or invalid request received from the host
231231
*/
232-
static bool send_signature(icp_query_t *query, const sig_t *signature);
232+
static bool send_signature(icp_query_t *query, const icp_sig_t *signature);
233233

234234
/*****************************************************************************
235235
* STATIC VARIABLES
@@ -616,7 +616,7 @@ static bool get_user_verification(void) {
616616
return get_user_verification_for_coin_txn();
617617
}
618618

619-
static bool sign_txn(sig_t *signature) {
619+
static bool sign_txn(icp_sig_t *signature) {
620620
uint8_t seed[64] = {0};
621621
if (!reconstruct_seed(
622622
icp_txn_context->init_info.wallet_id, seed, icp_send_error)) {
@@ -688,7 +688,7 @@ static bool sign_txn(sig_t *signature) {
688688
return true;
689689
}
690690

691-
static bool send_signature(icp_query_t *query, const sig_t *signature) {
691+
static bool send_signature(icp_query_t *query, const icp_sig_t *signature) {
692692
icp_result_t result = init_icp_result(ICP_RESULT_SIGN_TXN_TAG);
693693
result.sign_txn.which_response = ICP_SIGN_TXN_RESPONSE_SIGNATURE_TAG;
694694

@@ -697,7 +697,7 @@ static bool send_signature(icp_query_t *query, const sig_t *signature) {
697697
return false;
698698
}
699699

700-
memcpy(&result.sign_txn.signature, signature, sizeof(sig_t));
700+
memcpy(&result.sign_txn.signature, signature, sizeof(icp_sig_t));
701701

702702
icp_send_result(&result);
703703
return true;
@@ -711,7 +711,7 @@ void icp_sign_transaction(icp_query_t *query) {
711711
icp_txn_context = (icp_txn_context_t *)malloc(sizeof(icp_txn_context_t));
712712
memzero(icp_txn_context, sizeof(icp_txn_context_t));
713713

714-
sig_t signature = {0};
714+
icp_sig_t signature = {0};
715715

716716
if (handle_initiate_query(query) && fetch_valid_input(query) &&
717717
get_user_verification() && sign_txn(&signature) &&

apps/near_app/near_txn_helpers.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ bool near_parse_transaction(const uint8_t *byte_array,
102102
uint16_t byte_array_size,
103103
near_unsigned_txn *utxn) {
104104
if (byte_array == NULL || utxn == NULL)
105-
return;
105+
return false;
106106
memzero(utxn, sizeof(near_unsigned_txn));
107107

108108
uint16_t offset = 0;

common/libraries/crypto/mpz_operations/mpz_ecdsa.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,11 @@
6868

6969
#include "assert_conf.h"
7070
#include "mini-gmp.h"
71+
#include "rand.h"
7172
#include "rfc6979.h"
7273

74+
#include "memzero.h"
75+
7376
/*****************************************************************************
7477
* EXTERN VARIABLES
7578
*****************************************************************************/

src/wallet/wallet_unlock_flow.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ static wallet_unlock_state_e wallet_unlock_handler(
303303
*****************************************************************************/
304304
void wallet_unlock_flow(const Flash_Wallet *flash_wallet) {
305305
if ((NULL == flash_wallet) || (false == flash_wallet->is_wallet_locked)) {
306-
return 0;
306+
return;
307307
}
308308

309309
wallet_unlock_state_e state = WALLET_UNLOCK_FETCH_CHALLENGE;

tests/apps/btc_app/btc_script_tests.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858

5959
#include "btc_helpers.h"
6060
#include "btc_priv.h"
61+
#include "btc_script.h"
6162
#include "curves.h"
6263
#include "flash_config.h"
6364
#include "ltc_app.h"

tests/apps/near_app/near_helpers_tests.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include "near.h"
6060
#include "near_context.h"
6161
#include "near_helpers.h"
62+
#include "near_txn_helpers.h"
6263
#include "unity_fixture.h"
6364
#include "utils.h"
6465

tests/apps/near_app/near_txn_user_verification_tests.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
#include "near.h"
6060
#include "near_context.h"
6161
#include "near_helpers.h"
62+
#include "near_txn_helpers.h"
6263
#include "near_txn_user_verification.h"
6364
#include "unity_fixture.h"
6465
#include "utils.h"

tests/common/util/byte_stream_tests.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ static byte_stream_writer_status_e dummy_request_write_cb(
145145
return BYTE_STREAM_WRITER_SUCCESS;
146146
}
147147

148+
static byte_stream_writer_status_e failing_writer(byte_stream_t *stream) {
149+
return BYTE_STREAM_WRITER_UNKNOWN_ERROR;
150+
}
151+
148152
/*****************************************************************************
149153
* GLOBAL FUNCTIONS
150154
*****************************************************************************/
@@ -225,10 +229,6 @@ TEST(byte_stream_tests, returns_error_for_offset_greater_than_capacity) {
225229
}
226230

227231
TEST(byte_stream_tests, returns_error_when_writer_fails) {
228-
byte_stream_writer_status_e failing_writer(byte_stream_t * stream) {
229-
return BYTE_STREAM_WRITER_UNKNOWN_ERROR;
230-
}
231-
232232
byte_stream_t stream = {.offset = 0,
233233
.capacity = 10,
234234
.stream_pointer = test_data,

tests/p0_events/p0_events_test.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@
6161
*****************************************************************************/
6262
#include "p0_events_test.h"
6363

64+
#include "memzero.h"
65+
#include "systick_timer_priv.h"
66+
6467
/*****************************************************************************
6568
* EXTERN VARIABLES
6669
*****************************************************************************/

tests/ui/ui_events_test/ui_events_test.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
*/
6060
#include "ui_events_test.h"
6161

62+
#include <string.h>
63+
6264
#include "memzero.h"
6365

6466
#if USE_SIMULATOR == 0

0 commit comments

Comments
 (0)