-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WIP: Fix regression introduced in #61
- Loading branch information
Showing
19 changed files
with
264 additions
and
199 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,16 @@ | ||
== TODOS: | ||
|
||
- [ ] byte arrays should be smartly displayed: Short ones can be shown as such but long ones should be encoded to hex and truncated. The user can still use the json output to get the full data | ||
- [ ] Show extrinsics: see `// TODO: deal with extrinsic as well` | ||
- [x] load wasm file | ||
- [x] add ws support (= switch to substrate-api-client ?) | ||
- [x] compute section hashes | ||
- [ ] show sections summary as diff | ||
- [ ] fix subwasm meta | head => piping fails | ||
- [ ] add --chain to meta command | ||
The main command loads ONE wasm and analyses it (meta + version). | ||
- [ ] Add option to SHOW a runtime as a ReducedRuntime | ||
- [ ] hunt down expects and unwrap | ||
- [ ] remove those --chain-a --chain-b and use ONE enum that can handle 3 sources: file / url / alias | ||
- [ ] integrate with subrpc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#[cfg(test)] | ||
mod cli_tests { | ||
#[cfg(test)] | ||
mod cli_compress { | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn it_does_basic_compress_decompress() { | ||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
let assert = cmd.args(["get", "wss://rpc.polkadot.io:443", "--output", "compressed.wasm"]).assert(); | ||
assert.success().code(0); | ||
|
||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
cmd.args(["decompress", "compressed.wasm", "decompressed.wasm"]).assert().success().code(0); | ||
|
||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
cmd.args(["compress", "decompressed.wasm", "new_compressed.wasm"]).assert().success().code(0); | ||
} | ||
|
||
#[test] | ||
fn it_does_decompress_on_already() { | ||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
let assert = cmd.args(["get", "wss://rpc.polkadot.io:443", "--output", "compressed.wasm"]).assert(); | ||
assert.success().code(0); | ||
|
||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
cmd.args(["decompress", "compressed.wasm", "decompressed.wasm"]).assert().success().code(0); | ||
|
||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
cmd.args(["decompress", "decompressed.wasm", "new_decompressed.wasm"]).assert().success().code(0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#[cfg(test)] | ||
mod cli_tests { | ||
#[cfg(test)] | ||
mod diff { | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn it_shows_metadata() { | ||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
let assert = cmd.args(["get", "wss://rpc.polkadot.io:443", "--output", "runtime.wasm"]).assert(); | ||
assert.success().code(0); | ||
|
||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
let assert = cmd.args(["meta", "runtime.wasm"]).assert(); | ||
assert.success().code(0); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#[cfg(test)] | ||
mod cli_tests { | ||
#[cfg(test)] | ||
mod get { | ||
use assert_cmd::Command; | ||
use std::path::Path; | ||
#[test] | ||
fn it_gets_a_runtime() { | ||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
|
||
let assert = cmd.args(["get", "--output", "runtime.wasm", "wss://rpc.polkadot.io:443"]).assert(); | ||
assert.success().code(0); | ||
assert!(Path::new("runtime.wasm").exists()); | ||
} | ||
|
||
#[test] | ||
fn it_fails_on_bad_chain() { | ||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
|
||
let assert = cmd.args(["get", "--chain", "foobar"]).assert(); | ||
assert.failure().code(101); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#[cfg(test)] | ||
mod cli_tests { | ||
#[cfg(test)] | ||
mod info { | ||
use assert_cmd::Command; | ||
#[test] | ||
fn it_fails_without_source() { | ||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
let assert = cmd.arg("info tcp://foo.bar").assert(); | ||
assert.failure().code(2); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#[cfg(test)] | ||
mod cli_tests { | ||
#[cfg(test)] | ||
mod meta { | ||
use assert_cmd::Command as AssertCommand; | ||
use std::process::{Command, Stdio}; | ||
|
||
#[test] | ||
fn it_shows_metadata() { | ||
let mut cmd = AssertCommand::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
let assert = cmd.args(["get", "wss://rpc.polkadot.io:443", "--output", "runtime.wasm"]).assert(); | ||
assert.success().code(0); | ||
|
||
let mut cmd = AssertCommand::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
let assert = cmd.args(["meta", "runtime.wasm"]).assert(); | ||
assert.success().code(0); | ||
} | ||
|
||
// todo: test/fix following | ||
// c run -- meta --chain wnd -f json | head # OK | ||
// c run -- meta --chain wnd -f scale | head # FAIL | ||
// c run -- meta --chain wnd -f hex+scale | head # FIXED | ||
// c run -- meta --chain wnd -f json+scale | head # FIXED | ||
// #[test] | ||
// fn it_shows_when_piped() { | ||
// // let mut cmd = AssertCommand::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
// // let assert = cmd.args(["get", "wss://rpc.polkadot.io:443", "--output", "runtime.wasm"]).assert(); | ||
// // assert.success().code(0); | ||
|
||
// let subwasm_process = Command::new(env!("CARGO_PKG_NAME")) | ||
// .args(["meta", "wss://rpc.polkadot.io:443", "-f", "json"]) | ||
// .stdout(Stdio::piped()) | ||
// .spawn() | ||
// .unwrap(); | ||
// let head_process = Command::new("head") | ||
// .stdin(Stdio::from(subwasm_process.stdout.unwrap())) // Pipe through. | ||
// .stdout(Stdio::piped()) | ||
// .spawn() | ||
// .unwrap(); | ||
// let output = head_process.wait_with_output().unwrap(); | ||
|
||
// let s = String::from_utf8_lossy(&output.stdout); | ||
// println!("s = {:?}", s); | ||
// println!("s = {:?}", s.len()); | ||
// assert!(s.len() > 100) | ||
// } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#[cfg(test)] | ||
mod cli_tests { | ||
|
||
#[cfg(test)] | ||
mod help { | ||
use assert_cmd::Command; | ||
|
||
#[test] | ||
fn it_shows_help() { | ||
let mut cmd = Command::cargo_bin(env!("CARGO_PKG_NAME")).unwrap(); | ||
let assert = cmd.arg("--help").assert(); | ||
assert.success().code(0); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.