@@ -119,3 +119,73 @@ TEST_CASE("Decode P2TR address", "[coinbase_decoder]")
119119
120120 TEST_ASSERT_EQUAL_STRING ("bc1pllhdmn9m42vcsamx24zrxgs3qrl7ahwvhw4fnzrhve25gvezzyqqc0cgpt" , output );
121121}
122+
123+ TEST_CASE ("BIP-110 signaling not detected" , "[coinbase_decoder]" )
124+ {
125+ // Create a mining_notify without BIP-110 bit set
126+ mining_notify notify = { 0 };
127+ notify .version = 0x20000000 ; // No BIP-110 signaling
128+ notify .job_id = "test_job" ;
129+ notify .coinbase_1 = "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4b03a5020cfabe6d6d379ae882651f6469f2ed6b8b40a4f9a4b41fd838a3ad6de8cba775f4e8f1d3080100000000000000" ;
130+ notify .coinbase_2 = "41903d4c1b2f736c7573682f0000000003ca890d27000000001976a9147c154ed1dc59609e3d26abb2df2ea3d587cd8c4188ac00000000000000002c6a4c2952534b424c4f434b3a4cb4cb2ddfc37c41baf5ef6b6b4899e3253a8f1dfc7e5dd68a5b5b27005014ef0000000000000000266a24aa21a9ed5caa249f1af9fbf71c986fea8e076ca34ae3514fb2f86400561b28c7b15949bf00000000" ;
131+
132+ mining_notification_result_t result = { 0 };
133+
134+ // Use valid extranonce1 (8 hex chars = 4 bytes)
135+ esp_err_t err = coinbase_process_notification (& notify , "01020304" , 8 , "" , true, & result );
136+ TEST_ASSERT_EQUAL (ESP_OK , err );
137+ TEST_ASSERT_FALSE (result .bip110_signaling );
138+ }
139+
140+ TEST_CASE ("BIP-110 signaling detected" , "[coinbase_decoder]" )
141+ {
142+ // Create a mining_notify with BIP-110 bit set (bit 4 = 0x00000010)
143+ mining_notify notify = { 0 };
144+ notify .version = 0x20000010 ; // Version with BIP-110 signaling
145+ notify .job_id = "test_job" ;
146+ notify .coinbase_1 = "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4b03a5020cfabe6d6d379ae882651f6469f2ed6b8b40a4f9a4b41fd838a3ad6de8cba775f4e8f1d3080100000000000000" ;
147+ notify .coinbase_2 = "41903d4c1b2f736c7573682f0000000003ca890d27000000001976a9147c154ed1dc59609e3d26abb2df2ea3d587cd8c4188ac00000000000000002c6a4c2952534b424c4f434b3a4cb4cb2ddfc37c41baf5ef6b6b4899e3253a8f1dfc7e5dd68a5b5b27005014ef0000000000000000266a24aa21a9ed5caa249f1af9fbf71c986fea8e076ca34ae3514fb2f86400561b28c7b15949bf00000000" ;
148+
149+ mining_notification_result_t result = { 0 };
150+
151+ // Use valid extranonce1 (8 hex chars = 4 bytes)
152+ esp_err_t err = coinbase_process_notification (& notify , "01020304" , 8 , "" , true, & result );
153+ TEST_ASSERT_EQUAL (ESP_OK , err );
154+ TEST_ASSERT_TRUE (result .bip110_signaling );
155+ }
156+
157+ TEST_CASE ("BIP-110 signaling last block" , "[coinbase_decoder]" )
158+ {
159+ // Create a mining_notify with BIP-110 bit set (bit 4 = 0x00000010)
160+ mining_notify notify = { 0 };
161+ notify .version = 0x20000010 ; // Version with BIP-110 signaling
162+ notify .job_id = "test_job" ;
163+ notify .coinbase_1 = "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4b031fbc0efabe6d6d379ae882651f6469f2ed6b8b40a4f9a4b41fd838a3ad6de8cba775f4e8f1d3080100000000000000" ;
164+ notify .coinbase_2 = "41903d4c1b2f736c7573682f0000000003ca890d27000000001976a9147c154ed1dc59609e3d26abb2df2ea3d587cd8c4188ac00000000000000002c6a4c2952534b424c4f434b3a4cb4cb2ddfc37c41baf5ef6b6b4899e3253a8f1dfc7e5dd68a5b5b27005014ef0000000000000000266a24aa21a9ed5caa249f1af9fbf71c986fea8e076ca34ae3514fb2f86400561b28c7b15949bf00000000" ;
165+
166+ mining_notification_result_t result = { 0 };
167+
168+ // Use valid extranonce1 (8 hex chars = 4 bytes)
169+ esp_err_t err = coinbase_process_notification (& notify , "01020304" , 8 , "" , true, & result );
170+ TEST_ASSERT_EQUAL (ESP_OK , err );
171+ TEST_ASSERT_EQUAL (965663 , result .block_height );
172+ TEST_ASSERT_TRUE (result .bip110_signaling );
173+ }
174+
175+ TEST_CASE ("BIP-110 signaling expired" , "[coinbase_decoder]" )
176+ {
177+ // Create a mining_notify with BIP-110 bit set (bit 4 = 0x00000010)
178+ mining_notify notify = { 0 };
179+ notify .version = 0x20000010 ; // Version with BIP-110 signaling
180+ notify .job_id = "test_job" ;
181+ notify .coinbase_1 = "01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4b0320bc0efabe6d6d379ae882651f6469f2ed6b8b40a4f9a4b41fd838a3ad6de8cba775f4e8f1d3080100000000000000" ;
182+ notify .coinbase_2 = "41903d4c1b2f736c7573682f0000000003ca890d27000000001976a9147c154ed1dc59609e3d26abb2df2ea3d587cd8c4188ac00000000000000002c6a4c2952534b424c4f434b3a4cb4cb2ddfc37c41baf5ef6b6b4899e3253a8f1dfc7e5dd68a5b5b27005014ef0000000000000000266a24aa21a9ed5caa249f1af9fbf71c986fea8e076ca34ae3514fb2f86400561b28c7b15949bf00000000" ;
183+
184+ mining_notification_result_t result = { 0 };
185+
186+ // Use valid extranonce1 (8 hex chars = 4 bytes)
187+ esp_err_t err = coinbase_process_notification (& notify , "01020304" , 8 , "" , true, & result );
188+ TEST_ASSERT_EQUAL (ESP_OK , err );
189+ TEST_ASSERT_EQUAL (965664 , result .block_height );
190+ TEST_ASSERT_FALSE (result .bip110_signaling );
191+ }
0 commit comments