Skip to content

Commit

Permalink
integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
pause125 committed Jun 6, 2024
1 parent b88a252 commit 1749159
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 15 deletions.
11 changes: 8 additions & 3 deletions crates/rooch-rpc-api/src/api/rooch_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ use crate::jsonrpc_types::transaction_view::{TransactionFilterView, TransactionW
use crate::jsonrpc_types::{
AccessPathView, AnnotatedFunctionResultView, BalanceInfoPageView, BytesView, EventOptions,
EventPageView, ExecuteTransactionResponseView, FunctionCallView, H256View,
IndexerEventPageView, IndexerObjectStatePageView, KeyStateView, ObjectIDVecView, ObjectIDView,
IndexerEventPageView, IndexerObjectStatePageView, ObjectIDVecView, ObjectIDView,
ObjectStateFilterView, ObjectStateView, QueryOptions, SimpleKeyStateView, StateOptions,
StatePageView, StateView, StrView, StructTagView, TransactionWithInfoPageView, TxOptions,
};
use jsonrpsee::core::RpcResult;
use jsonrpsee::proc_macros::rpc;
use moveos_types::access_path::AccessPath;
use moveos_types::{access_path::AccessPath, state::KeyState};
use rooch_open_rpc_macros::open_rpc;
use rooch_types::indexer::event::IndexerEventID;
use rooch_types::indexer::state::IndexerStateID;
Expand Down Expand Up @@ -83,7 +83,12 @@ pub trait RoochAPI {
object_id: ObjectIDView,
field_key: Vec<SimpleKeyStateView>,
state_option: Option<StateOptions>,
) -> RpcResult<Vec<Option<StateView>>>;
) -> RpcResult<Vec<Option<StateView>>> {
let key_states = field_key.into_iter().map(KeyState::from).collect();
let access_path_view =
AccessPathView::from(AccessPath::fields(object_id.into(), key_states));
self.get_states(access_path_view, state_option).await
}

/// List Object Fields via ObjectID.
#[method(name = "listFieldStates")]
Expand Down
13 changes: 1 addition & 12 deletions crates/rooch-rpc-server/src/server/rooch_server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use rooch_rpc_api::jsonrpc_types::transaction_view::TransactionFilterView;
use rooch_rpc_api::jsonrpc_types::{
account_view::BalanceInfoView, IndexerEventPageView, IndexerObjectStatePageView,
IndexerObjectStateView, KeyStateView, ObjectIDVecView, ObjectStateFilterView, ObjectStateView,
QueryOptions, SimpleKeyStateView, StateKVView, StateOptions, TxOptions,
QueryOptions, StateKVView, StateOptions, TxOptions,
};
use rooch_rpc_api::jsonrpc_types::{
event_view::{EventFilterView, EventView, IndexerEventView},
Expand Down Expand Up @@ -343,17 +343,6 @@ impl RoochAPIServer for RoochServer {
Ok(objects_view)
}

async fn get_field_states(
&self,
object_id: ObjectIDView,
field_key: Vec<SimpleKeyStateView>,
state_option: Option<StateOptions>,
) -> RpcResult<Vec<Option<StateView>>> {
let key_states = field_key.into_iter().map(KeyState::from).collect();
let access_path_view =
AccessPathView::from(AccessPath::fields(object_id.into(), key_states));
}

async fn get_events_by_event_handle(
&self,
event_handle_type: StructTagView,
Expand Down
4 changes: 4 additions & 0 deletions crates/testsuite/features/cmd.feature
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ Feature: Rooch CLI integration tests
Then assert: "{{$.rpc[-1][0].value_type}} == '0x2::object::ObjectEntity<0x2::object::Timestamp>'"
Then cmd: "rpc request --method rooch_getObjectStates --params '["0x5921974509dbe44ab84328a625f4a6580a5f89dff3e4e2dec448cb2b1c7f5b9"]'"
Then assert: "{{$.rpc[-1][0].value_type}} == '0x2::object::Timestamp'"
Then cmd: "rpc request --method rooch_getFieldStates --params '["0x2214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb", [{"key": "0x022214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb324e8a3eef828cd1fb6e9dc53244e1dac88da8810cf62583120539add3d907a5", "key_type": "0x2::object::ObjectID"}], {"decode": true, "showDisplay": true}]'"
Then assert: "{{$.rpc[-1][0].value_type}} == '0x2::object::ObjectEntity<0x2::module_store::Package>'"
Then cmd: "rpc request --method rooch_listFieldStates --params '["0x2214495c6abca5dd5a2bf0f2a28a74541ff10c89818a1244af24c4874325ebdb", null, "5", {"decode": true, "showDisplay": true}]'"
Then assert: "{{$.rpc[-1].has_next_page}} == 'true'"
Then stop the server

@serial
Expand Down

0 comments on commit 1749159

Please sign in to comment.