Skip to content

Commit

Permalink
fix conflict error
Browse files Browse the repository at this point in the history
  • Loading branch information
chenyukang committed Nov 27, 2023
1 parent 86ef0a2 commit dac8e25
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 143 deletions.
5 changes: 0 additions & 5 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion rpc/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4979,10 +4979,13 @@ Subscribe Response
"jsonrpc": "2.0",
"result": "0xf3"
}
```


Unsubscribe Request

```json

```
{
"id": 42,
"jsonrpc": "2.0",
Expand Down
1 change: 1 addition & 0 deletions rpc/src/module/subscription.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ pub trait SubscriptionRpc {
/// "jsonrpc": "2.0",
/// "result": "0xf3"
/// }
/// ```
///
/// Unsubscribe Request
///
Expand Down
129 changes: 2 additions & 127 deletions rpc/src/tests/mod.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
use ckb_chain::chain::ChainController;
use ckb_chain_spec::consensus::Consensus;
use ckb_dao::DaoCalculator;
use ckb_jsonrpc_types::ScriptHashType;
use ckb_network::{Flags, NetworkService, NetworkState};
use ckb_reward_calculator::RewardCalculator;
use ckb_shared::{Shared, SharedBuilder, Snapshot};
use ckb_shared::{Shared, Snapshot};
use ckb_store::ChainStore;
use ckb_test_chain_utils::{always_success_cell, always_success_cellbase};
use ckb_types::{
core::{
cell::resolve_transaction, BlockBuilder, BlockView, HeaderView, TransactionBuilder,
TransactionView,
},
global::DATA_DIR,
h256,
packed::{CellInput, OutPoint},
prelude::*,
};
Expand Down Expand Up @@ -221,128 +217,7 @@ fn always_success_transaction() -> TransactionView {
.build()
}

// setup a chain with 20 blocks and enable `Chain`, `Miner` and `Pool` rpc modules for unit test
// there is a similar fn `setup_rpc_test_suite` which enables all rpc modules,
// may be refactored into one fn with different paramsters in other PRs
// setup a chain with 20 blocks and enable `Chain`, `Miner` and `Pool` rpc modules for unit test.
fn setup(consensus: Consensus) -> RpcTestSuite {
setup_rpc_test_suite(20, Some(consensus))
/*
let (shared, mut pack) = SharedBuilder::with_temp_db()
.consensus(consensus)
.block_assembler_config(Some(BlockAssemblerConfig {
code_hash: h256!("0x0"),
args: Default::default(),
hash_type: ScriptHashType::Data,
message: Default::default(),
use_binary_version_as_message_prefix: false,
binary_version: "TEST".to_string(),
update_interval_millis: 800,
notify: vec![],
notify_scripts: vec![],
notify_timeout_millis: 800,
}))
.build()
.unwrap();
let chain_controller =
ChainService::new(shared.clone(), pack.take_proposal_table()).start::<&str>(None);
let tmp_dir = tempfile::tempdir().expect("create tmp_dir failed");
DATA_DIR
.set(tmp_dir.path().join("data"))
.expect("DATA_DIR set only once");
// Start network services
let network_controller = {
let network_config = NetworkConfig {
path: tmp_dir.path().join("network").to_path_buf(),
ping_interval_secs: 1,
ping_timeout_secs: 1,
connect_outbound_interval_secs: 1,
..Default::default()
};
let network_state =
Arc::new(NetworkState::from_config(network_config).expect("Init network state failed"));
NetworkService::new(
Arc::clone(&network_state),
Vec::new(),
Vec::new(),
(
shared.consensus().identify_name(),
"0.1.0".to_string(),
Flags::COMPATIBILITY,
),
)
.start(shared.async_handle())
.expect("Start network service failed")
};
pack.take_tx_pool_builder()
.start(network_controller.clone());
// Build chain, insert 20 blocks
let mut parent = shared.consensus().genesis_block().clone();
for _ in 0..20 {
let block = next_block(&shared, &parent.header());
chain_controller
.process_block(Arc::new(block.clone()))
.expect("processing new block should be ok");
parent = block;
}
// Start rpc services
let rpc_config = RpcConfig {
listen_address: "127.0.0.1:0".to_owned(),
tcp_listen_address: Some("127.0.0.1:0".to_owned()),
ws_listen_address: None,
max_request_body_size: 20_000_000,
threads: None,
modules: vec![
RpcModule::Chain,
RpcModule::Miner,
RpcModule::Pool,
RpcModule::IntegrationTest,
],
reject_ill_transactions: false,
enable_deprecated_rpc: false,
extra_well_known_lock_scripts: vec![],
extra_well_known_type_scripts: vec![],
};
let builder = ServiceBuilder::new(&rpc_config)
.enable_chain(shared.clone())
.enable_pool(shared.clone(), vec![], vec![])
.enable_miner(
shared.clone(),
network_controller.clone(),
chain_controller.clone(),
true,
)
.enable_integration_test(shared.clone(), network_controller, chain_controller.clone());
let io_handler = builder.build();
let shared_clone = shared.clone();
let handler = shared_clone.async_handle().clone();
let rpc_server = handler.block_on(async move { RpcServer::new(rpc_config, io_handler).await });
let rpc_client = Client::new();
let rpc_uri = format!(
"http://{}:{}/",
rpc_server.http_address.ip(),
rpc_server.http_address.port()
);
let tcp_uri = rpc_server
.tcp_address
.as_ref()
.map(|addr| format!("{}:{}", addr.ip(), addr.port()));
RpcTestSuite {
shared,
chain_controller,
rpc_uri,
tcp_uri,
rpc_client,
_tmp_dir: tmp_dir,
}
*/
}
7 changes: 3 additions & 4 deletions rpc/src/tests/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use ckb_chain::chain::ChainService;
use ckb_chain_spec::consensus::{Consensus, ConsensusBuilder};
use ckb_chain_spec::versionbits::{ActiveMode, Deployment, DeploymentPos};
use ckb_dao_utils::genesis_dao_data;
use ckb_launcher::SharedBuilder;
use ckb_network::{Flags, NetworkService, NetworkState};
use ckb_network_alert::alert_relayer::AlertRelayer;
use ckb_notify::NotifyService;
use ckb_shared::SharedBuilder;
use ckb_sync::SyncShared;
use serde_json::json;
use std::collections::HashMap;
Expand Down Expand Up @@ -94,12 +94,11 @@ pub(crate) fn setup_rpc_test_suite(height: u64, consensus: Option<Consensus>) ->
ChainService::new(shared.clone(), pack.take_proposal_table()).start::<&str>(None);

// Start network services
let temp_dir = tempfile::tempdir().expect("create tempdir failed");
let temp_dir = tempfile::tempdir().expect("create tmp_dir failed");

let temp_path = temp_dir.path().to_path_buf();
let network_controller = {
let network_config = NetworkConfig {
path: temp_path,
path: temp_dir.path().join("network").to_path_buf(),
ping_interval_secs: 1,
ping_timeout_secs: 1,
connect_outbound_interval_secs: 1,
Expand Down
6 changes: 0 additions & 6 deletions util/launcher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,7 @@ ckb-channel = { path = "../channel", version = "= 0.113.0-pre" }
ckb-tx-pool = { path = "../../tx-pool", version = "= 0.113.0-pre" }
ckb-light-client-protocol-server = { path = "../light-client-protocol-server", version = "= 0.113.0-pre" }
ckb-block-filter = { path = "../../block-filter", version = "= 0.113.0-pre" }
ckb-hash = { path = "../hash", version = "= 0.113.0-pre" }
num_cpus = "1.10"
once_cell = "1.8.0"
tempfile.workspace = true

[dev-dependencies]
ckb-systemtime = {path = "../systemtime", version = "= 0.113.0-pre", features = ["enable_faketime"] }

[features]
with_sentry = [ "ckb-sync/with_sentry", "ckb-network/with_sentry", "ckb-app-config/with_sentry" ]
Expand Down

0 comments on commit dac8e25

Please sign in to comment.