Skip to content

Commit

Permalink
fix: unit tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
shawn-zil committed Nov 26, 2024
1 parent 0fee1b4 commit 7e29176
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 21 deletions.
2 changes: 1 addition & 1 deletion zilliqa/tests/it/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ async fn block_production(mut network: Network) {
.map_or(0, |b| b.number())
>= 5
},
50,
100,
)
.await
.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion zilliqa/tests/it/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1427,7 +1427,7 @@ async fn test_eth_syncing(mut network: Network) {
network
.run_until_async(
|| async { wallet.get_block_number().await.unwrap().as_u64() > 4 },
50,
100,
)
.await
.unwrap();
Expand Down
51 changes: 32 additions & 19 deletions zilliqa/tests/it/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1004,9 +1004,20 @@ impl Network {
let mut inner = node.inner.lock().unwrap();
// Send to nodes only in the same shard (having same chain_id)
if inner.config.eth_chain_id == sender_chain_id {
inner
.handle_broadcast(source, external_message.clone())
.unwrap();
match external_message {
// Re-route Proposals from Broadcast to Requests, which is the behaviour in Production.
ExternalMessage::Proposal(p) => inner
.handle_request(
source,
&p.hash().to_string(),
external_message.clone(),
ResponseChannel::Local,
)
.unwrap(),
_ => inner
.handle_broadcast(source, external_message.clone())
.unwrap(),
}
}
});
}
Expand All @@ -1015,22 +1026,24 @@ impl Network {
}
AnyMessage::Response { channel, message } => {
info!(%message, ?channel, "response");
let destination = self.pending_responses.remove(channel).unwrap();
let (index, node) = self
.nodes
.iter()
.enumerate()
.find(|(_, n)| n.peer_id == destination)
.unwrap();
if !self.disconnected.contains(&index) {
let span = tracing::span!(tracing::Level::INFO, "handle_message", index);
span.in_scope(|| {
let mut inner = node.inner.lock().unwrap();
// Send to nodes only in the same shard (having same chain_id)
if inner.config.eth_chain_id == sender_chain_id {
inner.handle_response(source, message.clone()).unwrap();
}
});
// skip on faux response
if let Some(destination) = self.pending_responses.remove(channel) {
let (index, node) = self
.nodes
.iter()
.enumerate()
.find(|(_, n)| n.peer_id == destination)
.unwrap();
if !self.disconnected.contains(&index) {
let span = tracing::span!(tracing::Level::INFO, "handle_message", index);
span.in_scope(|| {
let mut inner = node.inner.lock().unwrap();
// Send to nodes only in the same shard (having same chain_id)
if inner.config.eth_chain_id == sender_chain_id {
inner.handle_response(source, message.clone()).unwrap();
}
});
}
}
}
}
Expand Down

0 comments on commit 7e29176

Please sign in to comment.