Skip to content

Commit

Permalink
[cleanup] change generate-json-rpc-spec to cargo example instead of b…
Browse files Browse the repository at this point in the history
…inary (MystenLabs#3103)

* don't need to build generate-json-rpc-spec binary

* fixup after rebase

* fixup after rebase

* minor doc fix

* minor doc fix
  • Loading branch information
patrickkuo authored Jul 8, 2022
1 parent a4207b1 commit 715f0f4
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 84 deletions.
36 changes: 14 additions & 22 deletions Cargo.lock

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

1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
[workspace]
resolver = "2"
members = [
"crates/generate-json-rpc-spec",
"crates/sui",
"crates/sui-adapter",
"crates/sui-adapter-transactional-tests",
Expand Down
27 changes: 0 additions & 27 deletions crates/generate-json-rpc-spec/Cargo.toml

This file was deleted.

15 changes: 0 additions & 15 deletions crates/generate-json-rpc-spec/tests/generate-spec.rs

This file was deleted.

23 changes: 23 additions & 0 deletions crates/sui-open-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,26 @@ edition = "2021"
schemars = "0.8.10"
serde = "1.0.138"
workspace-hack = { path = "../workspace-hack"}

[dev-dependencies]
anyhow = { version = "1.0.58", features = ["backtrace"] }
clap = { version = "3.1.17", features = ["derive"] }
pretty_assertions = "1.2.0"
serde_json = "1.0.80"
tokio = { version = "1.18.2", features = ["full"] }
hyper = { version = "0.14.18", features = ["full"] }

sui = { path = "../sui" }
sui-json-rpc = { path = "../sui-json-rpc" }
sui-json-rpc-api = { path = "../sui-json-rpc-api" }
sui-json = { path = "../sui-json" }
sui-types = { path = "../sui-types" }
sui-config = { path = "../sui-config" }
test-utils = { path = "../test-utils" }

move-package = { git = "https://github.com/move-language/move", rev = "7733658048a8bc80e9ba415b8c99aed9234eaa5f" }

[[example]]
name = "generate-json-rpc-spec"
path = "src/generate_json_rpc_spec.rs"
test = false
Original file line number Diff line number Diff line change
Expand Up @@ -55,25 +55,15 @@ struct Options {
action: Action,
}

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",
);

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

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

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

const OWNED_OBJECT_SAMPLE_FILE_PATH: &str =
concat!(env!("CARGO_MANIFEST_DIR"), "/samples/owned_objects.json",);

#[tokio::main]
async fn main() {
Expand Down
21 changes: 21 additions & 0 deletions crates/sui-open-rpc/tests/generate-spec.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) 2022, Mysten Labs, Inc.
// SPDX-License-Identifier: Apache-2.0

#[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", "--"])
.arg("test")
.status()
.expect("failed to execute process");
assert!(
status.success(),
"\n\
If this test breaks and you intended a json rpc schema change, you need to run to get the fresh schema:\n\
cargo -q run --example generate-json-rpc-spec -- record\n\
"
);
}

0 comments on commit 715f0f4

Please sign in to comment.