@@ -235,6 +235,45 @@ async fn mining_block_template_lifecycle() {
235235 . await ;
236236}
237237
238+ /// submitBlock with a template block should be rejected (unsolved high-hash).
239+ #[ tokio:: test]
240+ #[ serial_test:: serial]
241+ async fn mining_submit_block ( ) {
242+ let path = unix_socket_path ( ) ;
243+ let rpc_network = connect_unix_stream ( path) . await ;
244+ let rpc_system = RpcSystem :: new ( Box :: new ( rpc_network) , None ) ;
245+ LocalSet :: new ( )
246+ . run_until ( async move {
247+ let ( client, thread) = bootstrap ( rpc_system) . await ;
248+ let mining = make_mining ( & client, & thread) . await ;
249+ let template = make_block_template ( & mining, & thread) . await ;
250+
251+ let mut get_block_req = template. get_block_request ( ) ;
252+ get_block_req
253+ . get ( )
254+ . get_context ( )
255+ . unwrap ( )
256+ . set_thread ( thread. clone ( ) ) ;
257+ let get_block_resp = get_block_req. send ( ) . promise . await . unwrap ( ) ;
258+ let block = get_block_resp. get ( ) . unwrap ( ) . get_result ( ) . unwrap ( ) . to_vec ( ) ;
259+
260+ let mut req = mining. submit_block_request ( ) ;
261+ req. get ( ) . get_context ( ) . unwrap ( ) . set_thread ( thread. clone ( ) ) ;
262+ req. get ( ) . set_block ( & block) ;
263+ let resp = req. send ( ) . promise . await . unwrap ( ) ;
264+ let results = resp. get ( ) . unwrap ( ) ;
265+ assert ! (
266+ !results. get_result( ) ,
267+ "unsolved template block must not be accepted"
268+ ) ;
269+ let _reason = results. get_reason ( ) . unwrap ( ) ;
270+ let _debug = results. get_debug ( ) . unwrap ( ) ;
271+
272+ destroy_template ( & template, & thread) . await ;
273+ } )
274+ . await ;
275+ }
276+
238277/// checkBlock with a template block payload, and interrupt.
239278#[ tokio:: test]
240279// Serialized because interrupt() can affect other in-flight mining waits.
0 commit comments