Skip to content

Commit 809a5c8

Browse files
committed
fix starcoin-network-rpc unit test
1 parent d39cfeb commit 809a5c8

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

network-rpc/api/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ use starcoin_accumulator::AccumulatorNode;
1414
use starcoin_crypto::HashValue;
1515
use starcoin_state_api::{StateWithProof, StateWithTableItemProof};
1616
use starcoin_state_tree::StateNode;
17-
use starcoin_types::access_path::AccessPath;
1817
use starcoin_types::account_address::AccountAddress;
1918
use starcoin_types::account_state::AccountState;
2019
use starcoin_types::block::{BlockHeader, BlockInfo, BlockNumber};
@@ -27,6 +26,7 @@ pub use network_p2p_core::RawRpcClient;
2726
pub use remote_chain_state::RemoteChainStateReader;
2827

2928
pub use starcoin_types::block::BlockBody;
29+
use starcoin_vm_types::state_store::state_key::StateKey;
3030
use starcoin_vm_types::state_store::table::TableHandle;
3131

3232
pub const MAX_BLOCK_REQUEST_SIZE: u64 = 50;
@@ -157,7 +157,7 @@ impl RpcRequest for GetTxnsWithHash {
157157
#[derive(Debug, Serialize, Deserialize, Clone)]
158158
pub struct GetStateWithProof {
159159
pub state_root: HashValue,
160-
pub access_path: AccessPath,
160+
pub state_key: StateKey,
161161
}
162162

163163
#[derive(Debug, Serialize, Deserialize, Clone)]

network-rpc/api/src/remote_chain_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ impl ChainStateReader for RemoteChainStateReader {
6262
.ok_or_else(|| anyhow!("state root not set"))?;
6363
let req = GetStateWithProof {
6464
state_root,
65-
access_path: access_path.clone(),
65+
state_key: state_key.clone(),
6666
};
6767
let client = self.client.clone();
6868
let state_proof: StateWithProof =

network-rpc/src/rpc.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -226,18 +226,15 @@ impl gen_server::NetworkRpc for NetworkRpcImpl {
226226
fn get_state_with_proof(
227227
&self,
228228
_peer_id: PeerId,
229-
_req: GetStateWithProof,
229+
req: GetStateWithProof,
230230
) -> BoxFuture<Result<StateWithProof>> {
231-
// XXX FIXME YSG
232-
/*
233231
let state_service = self.state_service.clone();
234232
let fut = async move {
235233
state_service
236-
.get_with_proof_by_root(req.access_path, req.state_root)
234+
.get_with_proof_by_root(req.state_key, req.state_root)
237235
.await
238236
};
239-
Box::pin(fut) */
240-
unimplemented!("")
237+
Box::pin(fut)
241238
}
242239

243240
fn get_state_with_table_item_proof(

network-rpc/src/tests.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ use starcoin_state_api::StateWithProof;
1414
use starcoin_types::{access_path, account_config::genesis_address, block::BlockHeader};
1515
use starcoin_vm_types::access_path::DataPath;
1616
use starcoin_vm_types::on_chain_resource::Epoch;
17+
use starcoin_vm_types::state_store::state_key::StateKey;
1718
use std::sync::Arc;
1819

1920
#[stest::test]
@@ -44,6 +45,8 @@ fn test_network_rpc() {
4445
DataPath::Resource(Epoch::struct_tag_for_epoch()),
4546
);
4647

48+
let state_key = StateKey::resource(&genesis_address(), &Epoch::struct_tag_for_epoch()).unwrap();
49+
4750
//ping ok
4851
let req = Ping {
4952
msg: "ping_test".to_string(),
@@ -79,7 +82,7 @@ fn test_network_rpc() {
7982

8083
let state_req = GetStateWithProof {
8184
state_root,
82-
access_path: access_path.clone(),
85+
state_key,
8386
};
8487
let state_with_proof: StateWithProof = block_on(async {
8588
client

0 commit comments

Comments
 (0)