Skip to content

Commit

Permalink
exposed leadership log rest method
Browse files Browse the repository at this point in the history
  • Loading branch information
dkijania committed Sep 21, 2020
1 parent c4aefa1 commit 501ac74
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
13 changes: 11 additions & 2 deletions testing/jormungandr-scenario-tests/src/node.rs
Expand Up @@ -9,8 +9,8 @@ use chain_impl_mockchain::{
use jormungandr_lib::{
crypto::hash::Hash,
interfaces::{
EnclaveLeaderId, FragmentLog, Log, LogEntry, LogOutput, NodeState, NodeStatsDto,
PeerRecord, PeerStats,
EnclaveLeaderId, FragmentLog, LeadershipLog, Log, LogEntry, LogOutput, NodeState,
NodeStatsDto, PeerRecord, PeerStats,
},
};
pub use jormungandr_testing_utils::testing::{
Expand Down Expand Up @@ -391,6 +391,15 @@ impl NodeController {
.log_info(format!("node stats ({:?})", self.stats()));
}

pub fn leadership_log(&self) -> Result<Vec<LeadershipLog>> {
Ok(self.rest_client.leaders_log()?)
}

pub fn log_leadership_log(&self) {
self.progress_bar
.log_info(format!("{:?}", self.leadership_log().unwrap()));
}

pub fn wait_for_bootstrap(&self) -> Result<()> {
let max_try = 20;
let sleep = Duration::from_secs(8);
Expand Down
Expand Up @@ -189,6 +189,10 @@ impl BackwardCompatibleRest {
self.get("network/p2p/view")?.text()
}

pub fn leaders_log(&self) -> Result<String, reqwest::Error> {
self.get("leaders/logs")?.text()
}

pub fn tip(&self) -> Result<Hash, RestError> {
let tip = self.get("tip")?.text()?;
tip.parse().map_err(RestError::HashParseError)
Expand Down
6 changes: 5 additions & 1 deletion testing/jormungandr-testing-utils/src/testing/node/rest.rs
Expand Up @@ -9,7 +9,7 @@ use jormungandr_lib::{
crypto::hash::Hash,
interfaces::{
AccountState, EnclaveLeaderId, EpochRewardsInfo, FragmentLog, NodeStatsDto, PeerRecord,
PeerStats, StakeDistributionDto, VotePlanStatus,
PeerStats, StakeDistributionDto, VotePlanStatus, LeadershipLog,
},
};
use legacy::Settings;
Expand Down Expand Up @@ -154,6 +154,10 @@ impl JormungandrRest {
self.inner.fragment_logs()
}

pub fn leaders_log(&self) -> Result<Vec<LeadershipLog>, RestError> {
serde_json::from_str(&self.inner.leaders_log()?).map_err(RestError::CannotDeserialize)
}

pub fn leaders(&self) -> Result<Vec<EnclaveLeaderId>, RestError> {
let leaders = self.inner.leaders()?;
let leaders: Vec<EnclaveLeaderId> = if leaders.is_empty() {
Expand Down

0 comments on commit 501ac74

Please sign in to comment.