Skip to content

Commit

Permalink
fix starcoin-network-rpc unit test (#4327)
Browse files Browse the repository at this point in the history
  • Loading branch information
nkysg authored Dec 5, 2024
1 parent d39cfeb commit 89cccce
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions network-rpc/api/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ use starcoin_accumulator::AccumulatorNode;
use starcoin_crypto::HashValue;
use starcoin_state_api::{StateWithProof, StateWithTableItemProof};
use starcoin_state_tree::StateNode;
use starcoin_types::access_path::AccessPath;
use starcoin_types::account_address::AccountAddress;
use starcoin_types::account_state::AccountState;
use starcoin_types::block::{BlockHeader, BlockInfo, BlockNumber};
Expand All @@ -27,6 +26,7 @@ pub use network_p2p_core::RawRpcClient;
pub use remote_chain_state::RemoteChainStateReader;

pub use starcoin_types::block::BlockBody;
use starcoin_vm_types::state_store::state_key::StateKey;
use starcoin_vm_types::state_store::table::TableHandle;

pub const MAX_BLOCK_REQUEST_SIZE: u64 = 50;
Expand Down Expand Up @@ -157,7 +157,7 @@ impl RpcRequest for GetTxnsWithHash {
#[derive(Debug, Serialize, Deserialize, Clone)]
pub struct GetStateWithProof {
pub state_root: HashValue,
pub access_path: AccessPath,
pub state_key: StateKey,
}

#[derive(Debug, Serialize, Deserialize, Clone)]
Expand Down
2 changes: 1 addition & 1 deletion network-rpc/api/src/remote_chain_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ impl ChainStateReader for RemoteChainStateReader {
.ok_or_else(|| anyhow!("state root not set"))?;
let req = GetStateWithProof {
state_root,
access_path: access_path.clone(),
state_key: state_key.clone(),
};
let client = self.client.clone();
let state_proof: StateWithProof =
Expand Down
9 changes: 3 additions & 6 deletions network-rpc/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,18 +226,15 @@ impl gen_server::NetworkRpc for NetworkRpcImpl {
fn get_state_with_proof(
&self,
_peer_id: PeerId,
_req: GetStateWithProof,
req: GetStateWithProof,
) -> BoxFuture<Result<StateWithProof>> {
// XXX FIXME YSG
/*
let state_service = self.state_service.clone();
let fut = async move {
state_service
.get_with_proof_by_root(req.access_path, req.state_root)
.get_with_proof_by_root(req.state_key, req.state_root)
.await
};
Box::pin(fut) */
unimplemented!("")
Box::pin(fut)
}

fn get_state_with_table_item_proof(
Expand Down
5 changes: 4 additions & 1 deletion network-rpc/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ use starcoin_state_api::StateWithProof;
use starcoin_types::{access_path, account_config::genesis_address, block::BlockHeader};
use starcoin_vm_types::access_path::DataPath;
use starcoin_vm_types::on_chain_resource::Epoch;
use starcoin_vm_types::state_store::state_key::StateKey;
use std::sync::Arc;

#[stest::test]
Expand Down Expand Up @@ -44,6 +45,8 @@ fn test_network_rpc() {
DataPath::Resource(Epoch::struct_tag_for_epoch()),
);

let state_key = StateKey::resource(&genesis_address(), &Epoch::struct_tag_for_epoch()).unwrap();

//ping ok
let req = Ping {
msg: "ping_test".to_string(),
Expand Down Expand Up @@ -79,7 +82,7 @@ fn test_network_rpc() {

let state_req = GetStateWithProof {
state_root,
access_path: access_path.clone(),
state_key,
};
let state_with_proof: StateWithProof = block_on(async {
client
Expand Down

0 comments on commit 89cccce

Please sign in to comment.