Skip to content

Commit 2d64bb8

Browse files
committed
chore: clang-format source files
1 parent 503da17 commit 2d64bb8

File tree

2 files changed

+91
-75
lines changed

2 files changed

+91
-75
lines changed

tests/apps/btc_app/btc_txn_helpers_tests.c

Lines changed: 87 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -400,40 +400,47 @@ TEST(btc_txn_helper_test, btc_txn_helper_verify_input_p2wpkh_fail) {
400400
TEST_ASSERT_EQUAL_INT(2, status);
401401
}
402402

403-
404403
TEST(btc_txn_helper_test, btc_txn_helper_verify_input_p2wpkh_in_p2sh) {
405404
/* Test data source: Bip143
406405
* https://blockstream.info/testnet/tx/b095225e60df2896a4e03fcc4fb2ba9622ee513f34b3e8de45c25a4793a244a2?expand
407406
*/
408407
int status = 2;
409408
uint8_t raw_txn[2000] = {0};
410409
hex_string_to_byte_array(
411-
"0200000000010258afb1ece76f01c24f4935f453d210518163cb1d0383eaec331b202ebeb5e389"
412-
"0000000017160014a76cad25cb569bb47305513ebedd6011dc419deeffffffff2b3682b3592588"
413-
"5001f0e321df28d4ac675a9cbbccef2a69533bea7c5e5ad2c40000000017160014a76cad25cb56"
414-
"9bb47305513ebedd6011dc419deeffffffff02941100000000000017a914bd7aabdeeef211b1bd"
415-
"ad7218e14fea6c032101c087f22f00000000000017a914eaf97514c5ac1e41e413502e97ae42eb"
416-
"f27ace3a870247304402206e038f4712541d699697ed55efc41219df4f244fc72caa5edd653837"
417-
"f6555f6f02201cd8ea15b65fda17992abafaed86e066c3271ac16b9c46c54c2192438843dd0401"
418-
"21029f75e1ef6b04e004a308b1f59215a8a3a5b7958bbcf184cc24ba7ab6574448780248304502"
419-
"2100d15ce61648edc28b8b5a3531b80a1e8fc3b3eebe7d3fc4ca962cb04afc770dda02207c7eaf8"
420-
"82d7fac45d2752f20e48d2f896715cbc5a3b0f5de3e19fea0da99beac0121029f75e1ef6b04e004"
410+
"0200000000010258afb1ece76f01c24f4935f453d210518163cb1d0383eaec331b202ebe"
411+
"b5e389"
412+
"0000000017160014a76cad25cb569bb47305513ebedd6011dc419deeffffffff2b3682b3"
413+
"592588"
414+
"5001f0e321df28d4ac675a9cbbccef2a69533bea7c5e5ad2c40000000017160014a76cad"
415+
"25cb56"
416+
"9bb47305513ebedd6011dc419deeffffffff02941100000000000017a914bd7aabdeeef2"
417+
"11b1bd"
418+
"ad7218e14fea6c032101c087f22f00000000000017a914eaf97514c5ac1e41e413502e97"
419+
"ae42eb"
420+
"f27ace3a870247304402206e038f4712541d699697ed55efc41219df4f244fc72caa5edd"
421+
"653837"
422+
"f6555f6f02201cd8ea15b65fda17992abafaed86e066c3271ac16b9c46c54c2192438843"
423+
"dd0401"
424+
"21029f75e1ef6b04e004a308b1f59215a8a3a5b7958bbcf184cc24ba7ab6574448780248"
425+
"304502"
426+
"2100d15ce61648edc28b8b5a3531b80a1e8fc3b3eebe7d3fc4ca962cb04afc770dda0220"
427+
"7c7eaf8"
428+
"82d7fac45d2752f20e48d2f896715cbc5a3b0f5de3e19fea0da99beac0121029f75e1ef6"
429+
"b04e004"
421430
"a308b1f59215a8a3a5b7958bbcf184cc24ba7ab65744487800000000",
422431
838,
423432
raw_txn);
424433
// only fill necessary values
425-
btc_txn_input_t input[] = {
426-
{
427-
.value = 4500,
428-
.prev_output_index = 0x00000000,
429-
.script_pub_key = {.size = 23},
430-
},
431-
{
432-
.value = 12274,
433-
.prev_output_index = 0x00000001,
434-
.script_pub_key = {.size = 23},
435-
}
436-
};
434+
btc_txn_input_t input[] = {{
435+
.value = 4500,
436+
.prev_output_index = 0x00000000,
437+
.script_pub_key = {.size = 23},
438+
},
439+
{
440+
.value = 12274,
441+
.prev_output_index = 0x00000001,
442+
.script_pub_key = {.size = 23},
443+
}};
437444

438445
hex_string_to_byte_array(
439446
"b095225e60df2896a4e03fcc4fb2ba9622ee513f34b3e8de45c25a4793a244a2",
@@ -460,7 +467,7 @@ TEST(btc_txn_helper_test, btc_txn_helper_verify_input_p2wpkh_in_p2sh) {
460467

461468
status = btc_verify_input_test(input, raw_txn, 419);
462469
TEST_ASSERT_EQUAL_INT(0, status);
463-
status = btc_verify_input_test(input+1, raw_txn, 419);
470+
status = btc_verify_input_test(input + 1, raw_txn, 419);
464471
TEST_ASSERT_EQUAL_INT(0, status);
465472
}
466473

@@ -471,32 +478,40 @@ TEST(btc_txn_helper_test, btc_txn_helper_verify_input_p2wpkh_in_p2sh_fail) {
471478
int status = 2;
472479
uint8_t raw_txn[2000] = {0};
473480
hex_string_to_byte_array(
474-
"0200000000010258afb1ece76f01c24f4935f453d210518163cb1d0383eaec331b202ebeb5e389"
475-
"0000000017160014a76cad25cb569bb47305513ebedd6011dc419deeffffffff2b3682b3592588"
476-
"5001f0e321df28d4ac675a9cbbccef2a69533bea7c5e5ad2c40000000017160014a76cad25cb56"
477-
"9bb47305513ebedd6011dc419deeffffffff02941100000000000017a914bd7aabdeeef211b1bd"
478-
"ad7218e14fea6c032101c087f22f00000000000017a914eaf97514c5ac1e41e413502e97ae42eb"
479-
"f27ace3a870247304402206e038f4712541d699697ed55efc41219df4f244fc72caa5edd653837"
480-
"f6555f6f02201cd8ea15b65fda17992abafaed86e066c3271ac16b9c46c54c2192438843dd0401"
481-
"21029f75e1ef6b04e004a308b1f59215a8a3a5b7958bbcf184cc24ba7ab6574448780248304502"
482-
"2100d15ce61648edc28b8b5a3531b80a1e8fc3b3eebe7d3fc4ca962cb04afc770dda02207c7eaf8"
483-
"82d7fac45d2752f20e48d2f896715cbc5a3b0f5de3e19fea0da99beac0121029f75e1ef6b04e004"
481+
"0200000000010258afb1ece76f01c24f4935f453d210518163cb1d0383eaec331b202ebe"
482+
"b5e389"
483+
"0000000017160014a76cad25cb569bb47305513ebedd6011dc419deeffffffff2b3682b3"
484+
"592588"
485+
"5001f0e321df28d4ac675a9cbbccef2a69533bea7c5e5ad2c40000000017160014a76cad"
486+
"25cb56"
487+
"9bb47305513ebedd6011dc419deeffffffff02941100000000000017a914bd7aabdeeef2"
488+
"11b1bd"
489+
"ad7218e14fea6c032101c087f22f00000000000017a914eaf97514c5ac1e41e413502e97"
490+
"ae42eb"
491+
"f27ace3a870247304402206e038f4712541d699697ed55efc41219df4f244fc72caa5edd"
492+
"653837"
493+
"f6555f6f02201cd8ea15b65fda17992abafaed86e066c3271ac16b9c46c54c2192438843"
494+
"dd0401"
495+
"21029f75e1ef6b04e004a308b1f59215a8a3a5b7958bbcf184cc24ba7ab6574448780248"
496+
"304502"
497+
"2100d15ce61648edc28b8b5a3531b80a1e8fc3b3eebe7d3fc4ca962cb04afc770dda0220"
498+
"7c7eaf8"
499+
"82d7fac45d2752f20e48d2f896715cbc5a3b0f5de3e19fea0da99beac0121029f75e1ef6"
500+
"b04e004"
484501
"a308b1f59215a8a3a5b7958bbcf184cc24ba7ab65744487800000000",
485502
838,
486503
raw_txn);
487504
// only fill necessary values
488-
btc_txn_input_t input[] = {
489-
{
490-
.value = 4500,
491-
.prev_output_index = 0x00000000,
492-
.script_pub_key = {.size = 23},
493-
},
494-
{
495-
.value = 12274,
496-
.prev_output_index = 0x00000001,
497-
.script_pub_key = {.size = 23},
498-
}
499-
};
505+
btc_txn_input_t input[] = {{
506+
.value = 4500,
507+
.prev_output_index = 0x00000000,
508+
.script_pub_key = {.size = 23},
509+
},
510+
{
511+
.value = 12274,
512+
.prev_output_index = 0x00000001,
513+
.script_pub_key = {.size = 23},
514+
}};
500515

501516
hex_string_to_byte_array(
502517
// invalid txn hash test. valid txn hash/id:
@@ -527,7 +542,7 @@ TEST(btc_txn_helper_test, btc_txn_helper_verify_input_p2wpkh_in_p2sh_fail) {
527542

528543
status = btc_verify_input_test(input, raw_txn, 419);
529544
TEST_ASSERT_EQUAL_INT(2, status);
530-
status = btc_verify_input_test(input+1, raw_txn, 419);
545+
status = btc_verify_input_test(input + 1, raw_txn, 419);
531546
TEST_ASSERT_EQUAL_INT(2, status);
532547
}
533548

@@ -943,7 +958,6 @@ TEST(btc_txn_helper_test, btc_txn_helper_p2wpkh_digest_1_2) {
943958
TEST(btc_txn_helper_test, btc_txn_helper_p2wpkh_digest_2_2) {
944959
}
945960

946-
947961
TEST(btc_txn_helper_test, btc_txn_helper_p2wpkh_in_p2sh_digest_1_2) {
948962
uint8_t calculated_digest[32] = {0};
949963
uint8_t expected_digest[32] = {0};
@@ -1019,10 +1033,13 @@ TEST(btc_txn_helper_test, btc_txn_helper_p2wpkh_in_p2sh_digest_1_2) {
10191033
expected_digest);
10201034

10211035
btc_segwit_init_cache(&context);
1022-
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_cache.hash_prevouts, context.segwit_cache.hash_prevouts, 32);
1023-
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_cache.hash_sequence, context.segwit_cache.hash_sequence, 32);
1024-
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_cache.hash_outputs, context.segwit_cache.hash_outputs, 32);
1025-
1036+
TEST_ASSERT_EQUAL_UINT8_ARRAY(
1037+
expected_cache.hash_prevouts, context.segwit_cache.hash_prevouts, 32);
1038+
TEST_ASSERT_EQUAL_UINT8_ARRAY(
1039+
expected_cache.hash_sequence, context.segwit_cache.hash_sequence, 32);
1040+
TEST_ASSERT_EQUAL_UINT8_ARRAY(
1041+
expected_cache.hash_outputs, context.segwit_cache.hash_outputs, 32);
1042+
10261043
btc_digest_input(&context, 0, calculated_digest);
10271044
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_digest, calculated_digest, 32);
10281045
}
@@ -1032,24 +1049,22 @@ TEST(btc_txn_helper_test, btc_txn_helper_p2wpkh_in_p2sh_digest_2_2) {
10321049
uint8_t calculated_digest[32] = {0};
10331050
uint8_t expected_digest[2][32] = {0};
10341051
btc_segwit_cache_t expected_cache = {.filled = true};
1035-
btc_txn_input_t input[] = {
1036-
{
1037-
.prev_txn_hash = {0},
1038-
.value = 8650,
1039-
.prev_output_index = 0x00000000,
1040-
.script_pub_key = {.size = 22},
1041-
.address_index = 0,
1042-
.sequence = 4294967295,
1043-
},
1044-
{
1045-
.prev_txn_hash = {0},
1046-
.value = 18123,
1047-
.prev_output_index = 0x00000000,
1048-
.script_pub_key = {.size = 22},
1049-
.address_index = 0,
1050-
.sequence = 4294967295,
1051-
}
1052-
};
1052+
btc_txn_input_t input[] = {{
1053+
.prev_txn_hash = {0},
1054+
.value = 8650,
1055+
.prev_output_index = 0x00000000,
1056+
.script_pub_key = {.size = 22},
1057+
.address_index = 0,
1058+
.sequence = 4294967295,
1059+
},
1060+
{
1061+
.prev_txn_hash = {0},
1062+
.value = 18123,
1063+
.prev_output_index = 0x00000000,
1064+
.script_pub_key = {.size = 22},
1065+
.address_index = 0,
1066+
.sequence = 4294967295,
1067+
}};
10531068
btc_sign_txn_output_t outputs[] = {
10541069
{
10551070
.value = 4500,
@@ -1114,15 +1129,14 @@ TEST(btc_txn_helper_test, btc_txn_helper_p2wpkh_in_p2sh_digest_2_2) {
11141129
64,
11151130
expected_cache.hash_outputs);
11161131

1117-
11181132
btc_segwit_init_cache(&context);
11191133
TEST_ASSERT_EQUAL_UINT8_ARRAY(
11201134
expected_cache.hash_prevouts, context.segwit_cache.hash_prevouts, 32);
11211135
TEST_ASSERT_EQUAL_UINT8_ARRAY(
11221136
expected_cache.hash_sequence, context.segwit_cache.hash_sequence, 32);
11231137
TEST_ASSERT_EQUAL_UINT8_ARRAY(
11241138
expected_cache.hash_outputs, context.segwit_cache.hash_outputs, 32);
1125-
1139+
11261140
/* digest input 0*/
11271141
hex_string_to_byte_array(
11281142
"84b6c444101a5d7d41c521b1034bf2c82afb19d45fe2a4fc6bdfae4edd720334",
@@ -1132,7 +1146,7 @@ TEST(btc_txn_helper_test, btc_txn_helper_p2wpkh_in_p2sh_digest_2_2) {
11321146
status = btc_digest_input(&context, 0, calculated_digest);
11331147
TEST_ASSERT_TRUE(status);
11341148
TEST_ASSERT_EQUAL_UINT8_ARRAY(expected_digest[0], calculated_digest, 32);
1135-
1149+
11361150
/* digest input 1*/
11371151
hex_string_to_byte_array(
11381152
"7503b14676ff1de1d85819f31e43b96a5f400c273e7f143d8b05aa32e261a2b1",

tests/unit_test_lists.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,10 @@ TEST_GROUP_RUNNER(btc_txn_helper_test) {
140140
RUN_TEST_CASE(btc_txn_helper_test, btc_txn_helper_verify_input_p2pkh_fail);
141141
RUN_TEST_CASE(btc_txn_helper_test, btc_txn_helper_verify_input_p2wpkh);
142142
RUN_TEST_CASE(btc_txn_helper_test, btc_txn_helper_verify_input_p2wpkh_fail);
143-
RUN_TEST_CASE(btc_txn_helper_test, btc_txn_helper_verify_input_p2wpkh_in_p2sh);
144-
RUN_TEST_CASE(btc_txn_helper_test, btc_txn_helper_verify_input_p2wpkh_in_p2sh_fail);
143+
RUN_TEST_CASE(btc_txn_helper_test,
144+
btc_txn_helper_verify_input_p2wpkh_in_p2sh);
145+
RUN_TEST_CASE(btc_txn_helper_test,
146+
btc_txn_helper_verify_input_p2wpkh_in_p2sh_fail);
145147

146148
RUN_TEST_CASE(btc_txn_helper_test, btc_txn_helper_transaction_weight_legacy1);
147149
RUN_TEST_CASE(btc_txn_helper_test, btc_txn_helper_transaction_weight_legacy2);

0 commit comments

Comments
 (0)