Skip to content

Commit

Permalink
generate-json-rpc-spec: move into own crate and fix when run at repo …
Browse files Browse the repository at this point in the history
…root
  • Loading branch information
bmwill committed May 24, 2022
1 parent 36bae9e commit 58c72cf
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 13 deletions.
19 changes: 19 additions & 0 deletions Cargo.lock

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

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[workspace]
members = [
"crates/generate-json-rpc-spec",
"crates/sui",
"crates/sui-adapter",
"crates/sui-adapter-transactional-tests",
Expand Down
23 changes: 23 additions & 0 deletions crates/generate-json-rpc-spec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
[package]
name = "generate-json-rpc-spec"
version = "0.0.0"
authors = ["Mysten Labs <[email protected]>"]
license = "Apache-2.0"
publish = false
edition = "2021"

[dependencies]
anyhow = { version = "1.0.57", features = ["backtrace"] }
clap = { version = "3.1.17", features = ["derive"] }
pretty_assertions = "1.2.0"
serde = { version = "1.0.137", features = ["derive"] }
serde_json = "1.0.80"
tempfile = "3.3.0"
tokio = { version = "1.18.2", features = ["full"] }

sui = { path = "../sui" }
sui-core = { path = "../sui-core" }
sui-gateway = { path = "../sui-gateway" }
sui-json = { path = "../sui-json" }
sui-types = { path = "../sui-types" }
test-utils = { path = "../test-utils" }
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,23 @@ struct Options {
action: Action,
}

const FILE_PATH: &str = "sui-open-rpc/spec/openrpc.json";
const OBJECT_SAMPLE_FILE_PATH: &str = "sui-open-rpc/samples/objects.json";
const TRANSACTION_SAMPLE_FILE_PATH: &str = "sui-open-rpc/samples/transactions.json";
const FILE_PATH: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../sui-open-rpc/spec/openrpc.json",
);

const OBJECT_SAMPLE_FILE_PATH: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../sui-open-rpc/samples/objects.json",
);

const TRANSACTION_SAMPLE_FILE_PATH: &str = concat!(
env!("CARGO_MANIFEST_DIR"),
"/../sui-open-rpc/samples/transactions.json",
);

#[tokio::main]
async fn main() {
println!("{}", std::env::current_dir().unwrap().display());
let options = Options::parse();
let open_rpc = RpcGatewayOpenRpc::open_rpc();
match options.action {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

const GENERATE_JSON_RPC_SPEC_BIN: &str = env!("CARGO_BIN_EXE_generate-json-rpc-spec");

#[test]
fn test_json_rpc_spec() {
// If this test breaks and you intended a json rpc schema change, you need to run to get the fresh schema:
// # cargo -q run --example generate-json-rpc-spec -- record
let status = std::process::Command::new("cargo")
.current_dir("..")
.args(&["run", "--example", "generate-json-rpc-spec", "--"])
// # cargo -q run --bin generate-json-rpc-spec -- record
let status = std::process::Command::new(GENERATE_JSON_RPC_SPEC_BIN)
.arg("test")
.status()
.expect("failed to execute process");
Expand Down
5 changes: 0 additions & 5 deletions crates/sui/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,3 @@ test-utils = { path = "../test-utils" }

[features]
benchmark = ["narwhal-node/benchmark"]

[[example]]
name = "generate-json-rpc-spec"
path = "src/generate_json_rpc_spec.rs"
test = false

0 comments on commit 58c72cf

Please sign in to comment.