Skip to content

Commit

Permalink
indexer-alt: transactional tests
Browse files Browse the repository at this point in the history
## Description
Set-up transactional tests for Indexer-Alt and RPC-Alt

## Test plan

Run the new transactional tests:

```
sui$ cargo nextest run -p sui-indexer-alt-e2e-tests
```
  • Loading branch information
amnn committed Jan 17, 2025
1 parent 66a19dc commit 920c535
Show file tree
Hide file tree
Showing 11 changed files with 448 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Cargo.lock

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

2 changes: 2 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ members = [
"crates/sui-http",
"crates/sui-indexer",
"crates/sui-indexer-alt",
"crates/sui-indexer-alt-e2e-tests",
"crates/sui-indexer-alt-framework",
"crates/sui-indexer-alt-jsonrpc",
"crates/sui-indexer-alt-metrics",
Expand Down Expand Up @@ -640,6 +641,7 @@ sui-graphql-rpc-headers = { path = "crates/sui-graphql-rpc-headers" }
sui-genesis-builder = { path = "crates/sui-genesis-builder" }
sui-http = { path = "crates/sui-http" }
sui-indexer = { path = "crates/sui-indexer" }
sui-indexer-alt = { path = "crates/sui-indexer-alt" }
sui-indexer-alt-framework = { path = "crates/sui-indexer-alt-framework" }
sui-indexer-alt-jsonrpc = { path = "crates/sui-indexer-alt-jsonrpc" }
sui-indexer-alt-metrics = { path = "crates/sui-indexer-alt-metrics" }
Expand Down
39 changes: 39 additions & 0 deletions crates/sui-indexer-alt-e2e-tests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[package]
name = "sui-indexer-alt-e2e-tests"
version = "0.1.0"
authors = ["Mysten Labs <[email protected]>"]
license = "Apache-2.0"
publish = false
edition = "2021"

[lints]
workspace = true

[[test]]
name = "tests"
harness = false

[dependencies]

[target.'cfg(msim)'.dependencies]
msim.workspace = true

[dev-dependencies]
anyhow.workspace = true
async-trait.workspace = true
datatest-stable.workspace = true
diesel = { workspace = true, features = ["chrono"] }
diesel-async = { workspace = true, features = ["bb8", "postgres", "async-connection-wrapper"] }
prometheus.workspace = true
reqwest.workspace = true
serde_json.workspace = true
telemetry-subscribers.workspace = true
tokio.workspace = true
tokio-util.workspace = true
url.workspace = true

sui-indexer-alt.workspace = true
sui-indexer-alt-framework.workspace = true
sui-indexer-alt-jsonrpc.workspace = true
sui-pg-db.workspace = true
sui-transactional-test-runner.workspace = true
6 changes: 6 additions & 0 deletions crates/sui-indexer-alt-e2e-tests/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

#![forbid(unsafe_code)]

// Empty src/lib.rs to get rusty-tags working.
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
processed 2 tasks

task 1, lines 6-10:
//# run-jsonrpc
Response: {
"jsonrpc": "2.0",
"id": 0,
"result": "1337"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# init --protocol-version 70 --simulator --objects-snapshot-min-checkpoint-lag 2 --reference-gas-price 1337

//# run-jsonrpc
{
"method": "suix_getReferenceGasPrice",
"params": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
processed 2 tasks

task 1, lines 6-10:
//# run-jsonrpc
Response: {
"jsonrpc": "2.0",
"id": 0,
"result": "1000"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# init --protocol-version 70 --simulator --objects-snapshot-min-checkpoint-lag 2

//# run-jsonrpc
{
"method": "suix_getReferenceGasPrice",
"params": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
processed 6 tasks

task 1, lines 19-22:
//# run-graphql
Error: GraphQL queries are not supported in these tests

task 2, line 24:
//# run-jsonrpc
Error: Missing JSON-RPC query

task 3, lines 26-29:
//# run-jsonrpc
Error: Failed to parse JSON-RPC query

task 4, lines 31-35:
//# run-jsonrpc
Error: Failed to parse JSON-RPC query

task 5, lines 37-41:
//# run-jsonrpc --show-headers
Headers: {
"content-type": "application/json; charset=utf-8",
"content-length": "40",
}

Response: {
"jsonrpc": "2.0",
"id": 0,
"result": "1000"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// Copyright (c) Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

//# init --protocol-version 70 --simulator --objects-snapshot-min-checkpoint-lag 2

// This test is checking details about the test runner:
//
// (1) It does not support GraphQL queries.
// (2) Tests will fail if the JSON-RPC query does not contian methods or
// params.
// - No JSON object.
// - Missing params.
// - Extra trailing comma (tricky!)
// (3) Displaying response headers is supported.
//
// The test description is at the top because the JSON does not have explicit
// syntax for comments.

//# run-graphql
{
chainIdentifier
}

//# run-jsonrpc

//# run-jsonrpc
{
"method": "suix_getReferenceGasPrice"
}

//# run-jsonrpc
{
"method": "suix_getReferenceGasPrice",
"params": [],
}

//# run-jsonrpc --show-headers
{
"method": "suix_getReferenceGasPrice",
"params": []
}
Loading

0 comments on commit 920c535

Please sign in to comment.