build-blocks.rs 1.6 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
// Copyright 2020 Parity Technologies (UK) Ltd.
// This file is part of Polkadot.

// Polkadot is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.

// Polkadot is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.

17
use futures::{future, pin_mut, select, FutureExt};
18
19
20
use polkadot_test_service::*;
use sp_keyring::Sr25519Keyring;

21
#[substrate_test_utils::test]
22
async fn ensure_test_service_build_blocks() {
Cecile Tonglet's avatar
Cecile Tonglet committed
23
	let mut builder = sc_cli::LoggerBuilder::new("");
24
25
	builder.with_colors(false);
	builder.init().expect("Sets up logger");
26

27
28
29
30
31
32
33
	let mut alice = run_validator_node(
		tokio::runtime::Handle::current(),
		Sr25519Keyring::Alice,
		|| {},
		Vec::new(),
		None,
	);
34
	let mut bob = run_validator_node(
35
		tokio::runtime::Handle::current(),
36
37
38
		Sr25519Keyring::Bob,
		|| {},
		vec![alice.addr.clone()],
39
		None,
40
41
	);

42
43
44
45
	{
		let t1 = future::join(alice.wait_for_blocks(3), bob.wait_for_blocks(3)).fuse();
		let t2 = alice.task_manager.future().fuse();
		let t3 = bob.task_manager.future().fuse();
46

47
		pin_mut!(t1, t2, t3);
48

49
50
51
52
53
		select! {
			_ = t1 => {},
			_ = t2 => panic!("service Alice failed"),
			_ = t3 => panic!("service Bob failed"),
		}
54
55
	}
}