Skip to content

Commit

Permalink
chore: add burn test (#1071)
Browse files Browse the repository at this point in the history
  • Loading branch information
willemneal authored Nov 8, 2023
1 parent 9259e08 commit 5398c06
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 0 deletions.
1 change: 1 addition & 0 deletions cmd/crates/soroban-test/tests/it/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ mod custom_types;
mod dotenv;
mod hello_world;
mod util;
mod wrap;
79 changes: 79 additions & 0 deletions cmd/crates/soroban-test/tests/it/integration/wrap.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
use soroban_cli::CommandParser;
use soroban_cli::{
commands::{
config::{self},
lab::token::wrap,
},
utils::contract_id_hash_from_asset,
};
use soroban_test::TestEnv;

use super::util::network_passphrase;

#[tokio::test]
#[ignore]
async fn burn() {
let sandbox = &TestEnv::default();
let address = config::identity::address::Cmd::parse("--hd-path=0")
.unwrap()
.public_key()
.unwrap();
let asset = format!("native:{address}");
wrap_cmd(&asset).run().await.unwrap();
let asset = soroban_cli::utils::parsing::parse_asset(&asset).unwrap();
let hash = contract_id_hash_from_asset(&asset, &network_passphrase().unwrap()).unwrap();
let id = stellar_strkey::Contract(hash.0).to_string();
assert_eq!(
"CAMTHSPKXZJIRTUXQP5QWJIFH3XIDMKLFAWVQOFOXPTKAW5GKV37ZC4N",
id
);
assert_eq!(
"true",
sandbox
.invoke(&[
"--id",
&id,
"--",
"authorized",
"--id",
&address.to_string()
])
.await
.unwrap()
);
assert_eq!(
"\"9223372036854775807\"",
sandbox
.invoke(&["--id", &id, "--", "balance", "--id", &address.to_string()])
.await
.unwrap(),
);

println!(
"{}",
sandbox
.invoke(&[
"--id",
&id,
"--",
"burn",
"--id",
&address.to_string(),
"--amount=100"
])
.await
.unwrap()
);

assert_eq!(
"\"9223372036854775707\"",
sandbox
.invoke(&["--id", &id, "--", "balance", "--id", &address.to_string()])
.await
.unwrap(),
);
}

fn wrap_cmd(asset: &str) -> wrap::Cmd {
wrap::Cmd::parse_arg_vec(&[&format!("--asset={asset}")]).unwrap()
}

0 comments on commit 5398c06

Please sign in to comment.