Repository: paritytech/substrate
File: client/consensus/manual-seal/src/lib.rs (Rust)

Code before:
			env,
			client: client.clone(),
			pool: pool.clone(),
			select_chain,
			create_inherent_data_providers: |_, _| async { Ok(()) },
			consensus_data_provider: None,
		});
		std::thread::spawn(|| {
			let rt = tokio::runtime::Runtime::new().unwrap();
			// spawn the background authorship task
			rt.block_on(future_instant_seal);
		});

		let delay_sec = 5;
		let future_delayed_finalize = run_delayed_finalize(DelayedFinalizeParams {
			client: client.clone(),
			delay_sec,
			spawn_handle: spawner,
		});
		std::thread::spawn(|| {
			let rt = tokio::runtime::Runtime::new().unwrap();
			// spawn the background authorship task
			rt.block_on(future_delayed_finalize);
		});

		// submit a transaction to pool.
		let result = pool.submit_one(&BlockId::Number(0), SOURCE, uxt(Alice, 0)).await;
		// assert that it was successfully imported
		assert!(result.is_ok());
		// assert that the background task returns ok
		let created_block = receiver.await.unwrap().unwrap();
		assert_eq!(
			created_block,
			CreatedBlock {
				hash: created_block.hash,
				aux: ImportedAux {
					header_only: false,
					clear_justification_requests: false,
					needs_justification: false,
					bad_justification: false,
					is_new_best: true,
				}
			}
		);
		// assert that there's a new block in the db.
		assert!(client.header(created_block.hash).unwrap().is_some());
		assert_eq!(client.header(created_block.hash).unwrap().unwrap().number, 1);

		assert_eq!(client.info().finalized_hash, client.info().genesis_hash);
		// ensuring run_delayed_finalize's Future is always processed before checking finalized hash
		// by adding 1 sec

Review comment (suggestion):
```suggestion
		});
		
		let finality_stream = client.finality_notification_stream();
```

Code after:
			block_import: client.clone(),
			commands_stream,
			env,
			client: client.clone(),
			pool: pool.clone(),
			select_chain,
			create_inherent_data_providers: |_, _| async { Ok(()) },
			consensus_data_provider: None,
		});
		std::thread::spawn(|| {
			let rt = tokio::runtime::Runtime::new().unwrap();
			// spawn the background authorship task
			rt.block_on(future_instant_seal);
		});

		let delay_sec = 5;
		let future_delayed_finalize = run_delayed_finalize(DelayedFinalizeParams {
			client: client.clone(),
			delay_sec,
			spawn_handle: spawner,
		});
		std::thread::spawn(|| {
			let rt = tokio::runtime::Runtime::new().unwrap();
			// spawn the background authorship task
			rt.block_on(future_delayed_finalize);
		});

		let mut finality_stream = client.finality_notification_stream();
		// submit a transaction to pool.
		let result = pool.submit_one(&BlockId::Number(0), SOURCE, uxt(Alice, 0)).await;
		// assert that it was successfully imported
		assert!(result.is_ok());
		// assert that the background task returns ok
		let created_block = receiver.await.unwrap().unwrap();
		assert_eq!(
			created_block,
			CreatedBlock {
				hash: created_block.hash,
				aux: ImportedAux {
					header_only: false,
					clear_justification_requests: false,
					needs_justification: false,
					bad_justification: false,
					is_new_best: true,
				}
			}
		);
		// assert that there's a new block in the db.
		assert!(client.header(created_block.hash).unwrap().is_some());
		assert_eq!(client.header(created_block.hash).unwrap().unwrap().number, 1);