Skip to content

Commit

Permalink
Fix delay test after merge with main branch
Browse files Browse the repository at this point in the history
  • Loading branch information
IAvecilla committed Mar 11, 2024
1 parent 1f36c1f commit cba79f7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 16 deletions.
22 changes: 12 additions & 10 deletions node/tests/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! This is a simple test for the RPC server. It checks if the server is running and can respond to.
use std::{sync::Mutex, thread::sleep, time::Duration};

use anyhow::Context;
use clap::{Args, Parser, Subcommand};
use jsonrpsee::{
core::{client::ClientT, RpcResult},
Expand All @@ -18,7 +19,7 @@ use zksync_concurrency::{
};
use zksync_consensus_tools::{
k8s::{self, add_chaos_delay_for_node},
rpc::methods::{health_check, last_vote},
rpc::methods::{health_check, last_commited_block},
};

mod utils;
Expand Down Expand Up @@ -130,27 +131,28 @@ pub async fn delay_test(test_result: Arc<Mutex<TestResult>>) -> anyhow::Result<(
let url: String = format!("http://{}", ip);
let rpc_client = HttpClientBuilder::default().build(url).unwrap();
let response: serde_json::Value = rpc_client
.request(last_vote::method(), rpc_params!())
.request(last_commited_block::method(), rpc_params!())
.await
.unwrap();
let last_voted_view: u64 = serde_json::from_value(response).unwrap();
info!("last_voted_view: {}", last_voted_view);
let last_voted_view: u64 =
serde_json::from_value(response.get("last_commited_block").unwrap().to_owned()).unwrap();
for _ in 0..5 {
let response: serde_json::Value = rpc_client
.request(last_vote::method(), rpc_params!())
.request(last_commited_block::method(), rpc_params!())
.await
.unwrap();
let new_last_voted_view: u64 = serde_json::from_value(response).unwrap();
info!("new_last_voted_view: {}", new_last_voted_view);
let new_last_voted_view: u64 =
serde_json::from_value(response.get("last_commited_block").unwrap().to_owned())
.unwrap();
assert_eq!(new_last_voted_view, last_voted_view);
}
sleep(Duration::from_secs(10));
let response: serde_json::Value = rpc_client
.request(last_vote::method(), rpc_params!())
.request(last_commited_block::method(), rpc_params!())
.await
.unwrap();
let new_last_voted_view: u64 = serde_json::from_value(response).unwrap();
info!("new_last_voted_view: {}", new_last_voted_view);
let new_last_voted_view: u64 =
serde_json::from_value(response.get("last_commited_block").unwrap().to_owned()).unwrap();
assert!(new_last_voted_view > last_voted_view);
test_result.lock().unwrap().add_passed();
Ok(())
Expand Down
8 changes: 5 additions & 3 deletions node/tools/src/k8s.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ use k8s_openapi::{
api::{
apps::v1::{Deployment, DeploymentSpec},
core::v1::{
Container, Namespace, Pod, PodSpec, PodTemplateSpec, Service, ServicePort, ServiceSpec,
Container, ContainerPort, EnvVar, EnvVarSource, HTTPGetAction, Namespace,
ObjectFieldSelector, Pod, PodSpec, PodTemplateSpec, Probe, Service, ServicePort,
ServiceSpec,
},
rbac::v1::{PolicyRule, Role, RoleBinding, RoleRef, Subject},
},
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString},
apimachinery::pkg::{apis::meta::v1::LabelSelector, util::intstr::IntOrString::Int},
};
use kube::{
api::{ListParams, PostParams},
Expand Down Expand Up @@ -325,7 +327,7 @@ pub async fn expose_tester_rpc(client: &Client) -> anyhow::Result<()> {
selector: Some([("app".to_string(), "test-node".to_string())].into()),
ports: vec![ServicePort {
port: 3030,
target_port: Some(IntOrString::Int(3030)),
target_port: Some(Int(3030)),
..Default::default()
}]
.into(),
Expand Down
4 changes: 1 addition & 3 deletions node/tools/src/rpc/server.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
use crate::AppConfig;

use super::methods::{config, health_check, last_view, last_vote, peers};
use super::methods::{health_check, last_commited_block, last_view};
use jsonrpsee::server::{middleware::http::ProxyGetRequestLayer, RpcModule, Server};
use std::{net::SocketAddr, sync::Arc};
use zksync_concurrency::{ctx, scope};
Expand Down

0 comments on commit cba79f7

Please sign in to comment.