Skip to content

Commit

Permalink
chore(gcli): parse metadata from local node
Browse files Browse the repository at this point in the history
  • Loading branch information
clearloop committed Oct 19, 2023
1 parent ad94391 commit 6d9ab5a
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 8 deletions.
12 changes: 8 additions & 4 deletions gcli/tests/cmd/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,10 @@ Metadata {

#[test]
fn test_command_program_metadata_works() -> Result<()> {
let node = common::dev()?;
let meta = env::wasm_bin("demo_new_meta.meta.txt");
let args = Args::new("program").action("meta").meta(meta);
let result = common::gcli(Vec::<String>::from(args)).expect("run gcli failed");
let result = node.run(args)?;

let stdout = result.stdout.convert();
assert_eq!(
Expand All @@ -113,13 +114,14 @@ fn test_command_program_metadata_works() -> Result<()> {
#[test]
fn test_command_program_metadata_derive_works() -> Result<()> {
let meta = env::wasm_bin("demo_new_meta.meta.txt");
let node = common::dev()?;
let args = Args::new("program")
.action("meta")
.meta(meta)
.flag("--derive")
.derive("Person");

let result = common::gcli(Vec::<String>::from(args)).expect("run gcli failed");
let result = node.run(args)?;
let stdout = result.stdout.convert();

let expected = "Person { surname: String, name: String }";
Expand Down Expand Up @@ -153,9 +155,10 @@ Exports {

#[test]
fn test_command_program_metawasm_works() -> Result<()> {
let node = common::dev()?;
let meta = env::wasm_bin("demo_meta_state_v1.meta.wasm");
let args = Args::new("program").action("meta").meta(meta);
let result = common::gcli(Vec::<String>::from(args)).expect("run gcli failed");
let result = node.run(args)?;

let stdout = result.stdout.convert();
assert_eq!(
Expand All @@ -168,14 +171,15 @@ fn test_command_program_metawasm_works() -> Result<()> {

#[test]
fn test_command_program_metawasm_derive_works() -> Result<()> {
let node = common::dev()?;
let meta = env::wasm_bin("demo_meta_state_v1.meta.wasm");
let args = Args::new("program")
.action("meta")
.meta(meta)
.flag("--derive")
.derive("Person");

let result = common::gcli(Vec::<String>::from(args)).expect("run gcli failed");
let result = node.run(args)?;
let stdout = result.stdout.convert();

let expected = "Person { surname: String, name: String }";
Expand Down
1 change: 1 addition & 0 deletions gcli/tests/cmd/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ async fn test_command_send_works() -> Result<()> {
// Send message to messager
let dest = hex::encode(mailbox[0].0.source.0);
let _ = node.run(Args::new("send").destination(dest).gas_limit("2000000000"))?;

let mailbox = signer
.api()
.mailbox(Some(common::alice_account_id()), 10)
Expand Down
7 changes: 4 additions & 3 deletions gcli/tests/common/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
pub use self::{
args::Args,
result::{Error, Result},
traits::NodeExec,
traits::{Convert, NodeExec},
};
use gear_core::ids::{CodeId, ProgramId};
use gsdk::{
Expand Down Expand Up @@ -60,13 +60,14 @@ impl NodeExec for Node {

/// Run binary `gcli`
pub fn gcli<T: ToString>(args: impl IntoIterator<Item = T>) -> Result<Output> {
Ok(Command::new(env::bin("gcli"))
Command::new(env::bin("gcli"))
.args(
args.into_iter()
.map(|v| v.to_string())
.collect::<Vec<String>>(),
)
.output()?)
.output()
.map_err(Into::into)
}

/// Run the dev node
Expand Down
1 change: 0 additions & 1 deletion gcli/tests/common/node.rs

This file was deleted.

2 changes: 2 additions & 0 deletions gcli/tests/common/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

#[derive(Debug, thiserror::Error)]
pub enum Error {
#[error(transparent)]
Anyhow(#[from] anyhow::Error),
#[error(transparent)]
GCli(#[from] gcli::result::Error),
#[error(transparent)]
Expand Down
1 change: 1 addition & 0 deletions gsdk/src/signer/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,7 @@ impl Inner {
call: Call,
fields: impl Into<Composite<()>>,
) -> Result<TxInBlock> {
log::info!("Run tx: {}::{}", Call::PALLET, call.call_name());
let tx = subxt::dynamic::tx(Call::PALLET, call.call_name(), fields.into());

self.process(tx).await
Expand Down

0 comments on commit 6d9ab5a

Please sign in to comment.