-
Notifications
You must be signed in to change notification settings - Fork 33
Expand file tree
/
Copy pathdump_configuration_test.rs
More file actions
83 lines (75 loc) · 2.81 KB
/
dump_configuration_test.rs
File metadata and controls
83 lines (75 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Copyright (c) 2019, MASQ (https://masq.ai) and/or its affiliates. All rights reserved.
pub mod utils;
use crate::utils::CommandConfig;
use masq_lib::constants::{CURRENT_SCHEMA_VERSION, DEFAULT_CHAIN};
use masq_lib::messages::{UiShutdownRequest, NODE_UI_PROTOCOL};
use masq_lib::test_utils::environment_guard::EnvironmentGuard;
use masq_lib::test_utils::ui_connection::UiConnection;
use masq_lib::utils::find_free_port;
use node_lib::test_utils::assert_string_contains;
#[test]
fn dump_configuration_with_an_existing_database_integration() {
let _eg = EnvironmentGuard::new();
let test_name = "dump_configuration_with_an_existing_database_integration";
{
//running Node in order to create a new database which cannot be made by --dump-config itself
let port = find_free_port();
let mut node = utils::MASQNode::start_standard(
test_name,
Some(
CommandConfig::new()
.pair("--ui-port", &port.to_string())
.pair("--chain", "polygon-amoy"),
),
true,
true,
false,
true,
);
node.wait_for_log("UIGateway bound", Some(5000));
let mut client = UiConnection::new(port, NODE_UI_PROTOCOL);
let shutdown_request = UiShutdownRequest {};
client.send(shutdown_request);
node.wait_for_exit();
}
let mut node = utils::MASQNode::run_dump_config(
test_name,
Some(CommandConfig::new().pair("--chain", "polygon-amoy")),
false,
true,
true,
false,
);
match node.wait_for_exit() {
None => panic!("the process terminated unexpectedly"),
Some(output) => {
let stdout = String::from_utf8_lossy(&output.stdout);
assert_string_contains(
stdout.as_ref(),
&format!("\"schemaVersion\": \"{}\"", CURRENT_SCHEMA_VERSION),
);
}
};
}
#[test]
fn dump_configuration_and_no_preexisting_database_integration() {
let _eg = EnvironmentGuard::new();
let mut node = utils::MASQNode::run_dump_config(
"dump_configuration_and_no_preexisting_database_integration",
Some(CommandConfig::new().pair("--chain", DEFAULT_CHAIN.rec().literal_identifier)),
true,
true,
true,
false,
);
match node.wait_for_exit() {
None => panic!("the process terminated unexpectedly"),
Some(output) => {
let stderr = String::from_utf8_lossy(&output.stderr);
assert_string_contains(stderr.as_ref(), "Could not find database at:");
assert_string_contains(stderr.as_ref(),
"It is created when the Node operates the first time. Running --dump-config before that has no effect"
)
}
};
}