Skip to content

Commit

Permalink
Fix unit test for ckb-rpc, use blocking_process_block
Browse files Browse the repository at this point in the history
  • Loading branch information
eval-exec committed Dec 26, 2023
1 parent a17107f commit 4b63f29
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion rpc/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use ckb_chain::{start_chain_services, ChainController};
use ckb_chain::ChainController;
use ckb_chain_spec::consensus::Consensus;
use ckb_dao::DaoCalculator;
use ckb_reward_calculator::RewardCalculator;
Expand Down
15 changes: 9 additions & 6 deletions rpc/src/tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
use ckb_app_config::{
BlockAssemblerConfig, NetworkAlertConfig, NetworkConfig, RpcConfig, RpcModule,
};
use ckb_chain::chain::ChainService;
use ckb_chain::start_chain_services;
use ckb_chain_spec::consensus::{Consensus, ConsensusBuilder};
use ckb_chain_spec::versionbits::{ActiveMode, Deployment, DeploymentPos};
use ckb_dao_utils::genesis_dao_data;
Expand Down Expand Up @@ -87,8 +87,7 @@ pub(crate) fn setup_rpc_test_suite(height: u64, consensus: Option<Consensus>) ->
}))
.build()
.unwrap();
let chain_controller =
ChainService::new(shared.clone(), pack.take_proposal_table()).start::<&str>(None);
let chain_controller = start_chain_services(pack.take_chain_services_builder());

// Start network services
let temp_dir = tempfile::tempdir().expect("create tmp_dir failed");
Expand Down Expand Up @@ -131,7 +130,7 @@ pub(crate) fn setup_rpc_test_suite(height: u64, consensus: Option<Consensus>) ->
for _ in 0..height {
let block = next_block(&shared, &parent.header());
chain_controller
.process_block(Arc::new(block.clone()))
.blocking_process_block(Arc::new(block.clone()))
.expect("processing new block should be ok");
parent = block;
}
Expand Down Expand Up @@ -206,7 +205,11 @@ pub(crate) fn setup_rpc_test_suite(height: u64, consensus: Option<Consensus>) ->
chain_controller.clone(),
true,
)
.enable_net(network_controller.clone(), sync_shared)
.enable_net(
network_controller.clone(),
sync_shared,
Arc::new(chain_controller.clone()),
)
.enable_stats(shared.clone(), Arc::clone(&alert_notifier))
.enable_experiment(shared.clone())
.enable_integration_test(
Expand Down Expand Up @@ -256,7 +259,7 @@ pub(crate) fn setup_rpc_test_suite(height: u64, consensus: Option<Consensus>) ->
)
.build();
chain_controller
.process_block(Arc::new(fork_block))
.blocking_process_block(Arc::new(fork_block))
.expect("processing new block should be ok");
}

Expand Down

0 comments on commit 4b63f29

Please sign in to comment.