@@ -374,6 +374,45 @@ async fn mining_block_template_lifecycle() {
374374 . await ;
375375}
376376
377+ /// submitBlock with a template block should be rejected (unsolved high-hash).
378+ #[ tokio:: test]
379+ #[ serial_test:: serial]
380+ async fn mining_submit_block ( ) {
381+ let path = unix_socket_path ( ) ;
382+ let rpc_network = connect_unix_stream ( path) . await ;
383+ let rpc_system = RpcSystem :: new ( Box :: new ( rpc_network) , None ) ;
384+ LocalSet :: new ( )
385+ . run_until ( async move {
386+ let ( client, thread) = bootstrap ( rpc_system) . await ;
387+ let mining = make_mining ( & client, & thread) . await ;
388+ let template = make_block_template ( & mining, & thread) . await ;
389+
390+ let mut get_block_req = template. get_block_request ( ) ;
391+ get_block_req
392+ . get ( )
393+ . get_context ( )
394+ . unwrap ( )
395+ . set_thread ( thread. clone ( ) ) ;
396+ let get_block_resp = get_block_req. send ( ) . promise . await . unwrap ( ) ;
397+ let block = get_block_resp. get ( ) . unwrap ( ) . get_result ( ) . unwrap ( ) . to_vec ( ) ;
398+
399+ let mut req = mining. submit_block_request ( ) ;
400+ req. get ( ) . get_context ( ) . unwrap ( ) . set_thread ( thread. clone ( ) ) ;
401+ req. get ( ) . set_block ( & block) ;
402+ let resp = req. send ( ) . promise . await . unwrap ( ) ;
403+ let results = resp. get ( ) . unwrap ( ) ;
404+ assert ! (
405+ !results. get_result( ) ,
406+ "unsolved template block must not be accepted"
407+ ) ;
408+ let _reason = results. get_reason ( ) . unwrap ( ) ;
409+ let _debug = results. get_debug ( ) . unwrap ( ) ;
410+
411+ destroy_template ( & template, & thread) . await ;
412+ } )
413+ . await ;
414+ }
415+
377416/// checkBlock with a template block payload, and interrupt.
378417#[ tokio:: test]
379418// Serialized because interrupt() can affect other in-flight mining waits.
0 commit comments