Skip to content

Commit 65ea6fc

Browse files
authored
regenerate grpc port after unsuccessful jormungandr bootstrap (#1088)
* regenerate p2p ports after node restart * filter jormungandr logs for Box<Any> entry -temporary fix, will be replaced by complemenary one after proper error propagation * logger is now checking any panic or significant error in logs using raw content (since all panics are not formatted with json logger)
1 parent ef78887 commit 65ea6fc

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

jormungandr-integration-tests/src/common/configuration/node_config_model.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ impl NodeConfig {
7272
level: Some("info".to_string()),
7373
format: Some("json".to_string()),
7474
}]);
75+
let grpc_address = format!(
76+
"/ip4/{}/tcp/{}",
77+
DEFAULT_HOST,
78+
public_address_port.to_string()
79+
);
7580

7681
NodeConfig {
7782
storage: Some(String::from(storage_file.as_os_str().to_str().unwrap())),
@@ -81,17 +86,9 @@ impl NodeConfig {
8186
}),
8287
p2p: Peer2Peer {
8388
trusted_peers: None,
84-
public_address: format!(
85-
"/ip4/{}/tcp/{}",
86-
DEFAULT_HOST,
87-
public_address_port.to_string()
88-
),
89+
public_address: grpc_address.clone(),
8990
public_id: public_id.to_string(),
90-
listen_address: format!(
91-
"/ip4/{}/tcp/{}",
92-
DEFAULT_HOST,
93-
public_address_port.to_string()
94-
),
91+
listen_address: grpc_address.clone(),
9592
topics_of_interest: TopicsOfInterest {
9693
messages: String::from("high"),
9794
blocks: String::from("high"),
@@ -120,6 +117,7 @@ impl NodeConfig {
120117
"/ip4/127.0.0.1/tcp/{}",
121118
super::get_available_port().to_string()
122119
);
120+
self.p2p.listen_address = self.p2p.public_address.clone();
123121
}
124122

125123
pub fn get_node_address(&self) -> String {

jormungandr-integration-tests/src/common/jormungandr/logger.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,15 @@ impl JormungandrLogger {
8787
println!("{}", self.get_log_content());
8888
}
8989

90+
pub fn raw_log_contains_any_of(&self, messages: &[&str]) -> Result<bool, LoggerError> {
91+
for message in messages {
92+
if self.get_log_content().contains(message) {
93+
return Ok(true);
94+
}
95+
}
96+
Ok(false)
97+
}
98+
9099
pub fn contains_message(&self, message: &str) -> Result<bool, LoggerError> {
91100
self.verify_file_exists()?;
92101
Ok(self.get_log_entries().any(|x| x.msg.contains(message)))

jormungandr-integration-tests/src/common/jormungandr/starter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,9 +234,9 @@ impl Starter {
234234

235235
fn custom_errors_found(&self) -> Result<(), StartupError> {
236236
let logger = JormungandrLogger::new(self.config.log_file_path.clone());
237-
//Can not resume socket accept process: The parameter is incorrect. (os error 87)
237+
let port_occupied_msgs = ["error 87", "panicked at 'Box<Any>'"];
238238
match logger
239-
.contains_message("error 87")
239+
.raw_log_contains_any_of(&port_occupied_msgs)
240240
.unwrap_or_else(|_| false)
241241
{
242242
true => Err(StartupError::PortAlreadyInUse),

0 commit comments

Comments
 (0)