@@ -1748,14 +1748,15 @@ impl<'a> TryFrom<AnyMessage<'a>> for MiningDeviceMessages<'a> {
17481748
17491749#[ cfg( test) ]
17501750mod test {
1751- use crate :: { AnyMessage , Extensions , ExtensionsNegotiation , Mining } ;
1751+ use crate :: { AnyMessage , Extensions , ExtensionsNegotiation , JobDeclaration , Mining } ;
17521752 use alloc:: string:: String ;
17531753 use alloc:: vec;
17541754 use alloc:: vec:: Vec ;
1755- use binary_sv2:: { Seq0255 , Seq064K , Str0255 , Sv2Option , B0255 , B064K , U256 } ;
1755+ use binary_sv2:: { Seq0255 , Seq064K , Str0255 , Sv2Option , B0255 , B032 , B064K , U256 } ;
17561756 use codec_sv2:: StandardSv2Frame ;
17571757 use core:: convert:: { TryFrom , TryInto } ;
17581758 use extensions_sv2:: { RequestExtensions , EXTENSION_TYPE_EXTENSIONS_NEGOTIATION } ;
1759+ use job_declaration_sv2:: PushSolution ;
17591760 use mining_sv2:: {
17601761 NewMiningJob , SetCustomMiningJob , SetCustomMiningJobError , SetCustomMiningJobSuccess ,
17611762 } ;
@@ -1853,6 +1854,28 @@ mod test {
18531854 }
18541855 }
18551856
1857+ #[ test]
1858+ fn push_solution_serialization ( ) {
1859+ let mut correctly_serialized_msg = vec ! [ 0 , 0 , 0x60 , 53 , 0 , 0 , 4 , 1 , 2 , 3 , 4 ] ;
1860+ correctly_serialized_msg. extend ( 5_u8 ..37 ) ;
1861+ correctly_serialized_msg. extend ( 0x11223344_u32 . to_le_bytes ( ) ) ;
1862+ correctly_serialized_msg. extend ( 0x55667788_u32 . to_le_bytes ( ) ) ;
1863+ correctly_serialized_msg. extend ( 0x99aabbcc_u32 . to_le_bytes ( ) ) ;
1864+ correctly_serialized_msg. extend ( 0xddeeff00_u32 . to_le_bytes ( ) ) ;
1865+
1866+ let job_declaration_message =
1867+ AnyMessage :: JobDeclaration ( JobDeclaration :: PushSolution ( PushSolution {
1868+ extranonce : B032 :: try_from ( vec ! [ 1 , 2 , 3 , 4 ] ) . unwrap ( ) ,
1869+ prev_hash : U256 :: try_from ( ( 5_u8 ..37 ) . collect :: < Vec < u8 > > ( ) ) . unwrap ( ) ,
1870+ nonce : 0x11223344 ,
1871+ ntime : 0x55667788 ,
1872+ nbits : 0x99aabbcc ,
1873+ version : 0xddeeff00 ,
1874+ } ) ) ;
1875+
1876+ message_serialization_check ( job_declaration_message, & correctly_serialized_msg) ;
1877+ }
1878+
18561879 fn message_serialization_check ( message : AnyMessage < ' static > , expected_result : & [ u8 ] ) {
18571880 let frame = StdFrame :: try_from ( message) . unwrap ( ) ;
18581881 let encoded_frame_length = frame. encoded_length ( ) ;
0 commit comments