Skip to content

Commit

Permalink
make one writes test sim and turn on logging
Browse files Browse the repository at this point in the history
  • Loading branch information
emmazzz committed Mar 5, 2025
1 parent 1b99d41 commit 4949be3
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Cargo.lock

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

5 changes: 5 additions & 0 deletions crates/sui-indexer-alt-e2e-tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ sui-types.workspace = true

[target.'cfg(msim)'.dependencies]
msim.workspace = true
sui-protocol-config.workspace = true
sui-simulator.workspace = true
tracing.workspace = true

[dev-dependencies]
async-trait.workspace = true
Expand All @@ -43,7 +46,9 @@ telemetry-subscribers.workspace = true

move-core-types.workspace = true

sui-macros.workspace = true
sui-move-build.workspace = true
sui-swarm-config.workspace = true
sui-transactional-test-runner.workspace = true
test-cluster.workspace = true
tracing.workspace = true
23 changes: 22 additions & 1 deletion crates/sui-indexer-alt-e2e-tests/tests/write_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use sui_indexer_alt_jsonrpc::{
api::write::WriteArgs, config::RpcConfig, data::system_package_task::SystemPackageTaskArgs,
start_rpc, RpcArgs,
};
use sui_macros::sim_test;
use sui_pg_db::{
temp::{get_available_port, TempDb},
DbArgs,
Expand Down Expand Up @@ -161,8 +162,10 @@ impl WriteTestCluster {
}
}

#[sim_test]
#[tokio::test]
async fn test_execution() {
telemetry_subscribers::init_for_testing();
let test_cluster = WriteTestCluster::new()
.await
.expect("Failed to create test cluster");
Expand Down Expand Up @@ -190,6 +193,8 @@ async fn test_execution() {
.await
.unwrap();

tracing::info!("execution rpc response is {:?}", response);

// Checking that all the requested fields are present in the response.
assert_eq!(response["result"]["digest"], tx_digest);
assert!(response["result"]["transaction"].is_object());
Expand All @@ -200,11 +205,13 @@ async fn test_execution() {
assert!(response["result"]["objectChanges"].is_array());
assert!(response["result"]["balanceChanges"].is_array());

test_cluster.stopped().await;
// test_cluster.stopped().await;
}

#[tokio::test]
async fn test_execution_with_deprecated_mode() {
telemetry_subscribers::init_for_testing();

let test_cluster = WriteTestCluster::new()
.await
.expect("Failed to create test cluster");
Expand All @@ -223,6 +230,8 @@ async fn test_execution_with_deprecated_mode() {
)
.await
.unwrap();
tracing::info!("execution rpc response is {:?}", response);


assert_eq!(response["error"]["code"], -32602);
assert_eq!(
Expand All @@ -235,6 +244,8 @@ async fn test_execution_with_deprecated_mode() {

#[tokio::test]
async fn test_execution_with_no_sigs() {
telemetry_subscribers::init_for_testing();

let test_cluster = WriteTestCluster::new()
.await
.expect("Failed to create test cluster");
Expand All @@ -251,6 +262,8 @@ async fn test_execution_with_no_sigs() {
)
.await
.unwrap();
tracing::info!("execution rpc response is {:?}", response);


assert_eq!(response["error"]["code"], -32602);
assert_eq!(response["error"]["message"], "Invalid params");
Expand All @@ -264,6 +277,8 @@ async fn test_execution_with_no_sigs() {

#[tokio::test]
async fn test_execution_with_empty_sigs() {
telemetry_subscribers::init_for_testing();

let test_cluster = WriteTestCluster::new()
.await
.expect("Failed to create test cluster");
Expand All @@ -282,6 +297,8 @@ async fn test_execution_with_empty_sigs() {
.await
.unwrap();

tracing::info!("execution rpc response is {:?}", response);

assert_eq!(response["error"]["code"], -32002);
assert_eq!(
response["error"]["message"],
Expand All @@ -293,6 +310,8 @@ async fn test_execution_with_empty_sigs() {

#[tokio::test]
async fn test_execution_with_aborted_tx() {
telemetry_subscribers::init_for_testing();

let test_cluster = WriteTestCluster::new()
.await
.expect("Failed to create test cluster");
Expand All @@ -314,6 +333,8 @@ async fn test_execution_with_aborted_tx() {
.await
.unwrap();

tracing::info!("execution rpc response is {:?}", response);

assert_eq!(response["result"]["effects"]["status"]["status"], "failure");

test_cluster.stopped().await;
Expand Down
20 changes: 10 additions & 10 deletions crates/sui-indexer-alt-jsonrpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ impl RpcService {
} = self;

info!("Starting JSON-RPC service on {rpc_listen_address}",);
info!("Serving schema: {}", serde_json::to_string_pretty(&schema)?);
// info!("Serving schema: {}", serde_json::to_string_pretty(&schema)?);

// Add a method to serve the schema to clients.
modules
Expand Down Expand Up @@ -183,19 +183,19 @@ impl RpcService {
// Set-up another helper task that will listen for Ctrl-C and trigger the cancellation
// token.
let ctrl_c_cancel = cancel.clone();
let h_ctrl_c = tokio::spawn(async move {
tokio::select! {
_ = ctrl_c_cancel.cancelled() => {}
_ = signal::ctrl_c() => {
ctrl_c_cancel.cancel();
}
}
});
// let h_ctrl_c = tokio::spawn(async move {
// tokio::select! {
// _ = ctrl_c_cancel.cancelled() => {}
// _ = signal::ctrl_c() => {
// ctrl_c_cancel.cancel();
// }
// }
// });

Ok(tokio::spawn(async move {
handle.stopped().await;
cancel.cancel();
let _ = join!(h_cancel, h_ctrl_c);
// let _ = join!(h_cancel, h_ctrl_c);
}))
}
}
Expand Down

0 comments on commit 4949be3

Please sign in to comment.