Skip to content

Commit

Permalink
tests(integration): stop testing swaps with NFTs
Browse files Browse the repository at this point in the history
  • Loading branch information
erwanor committed Jul 10, 2023
1 parent 9d985b1 commit 51bc97f
Showing 1 changed file with 43 additions and 41 deletions.
84 changes: 43 additions & 41 deletions crates/bin/pcli/tests/network_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -571,51 +571,54 @@ fn lp_management() {
fn swap() {
let tmpdir = load_wallet_into_tmpdir();

// Create a liquidity position selling 1cube for 1penumbra each.
let mut sell_cmd = Command::cargo_bin("pcli").unwrap();
sell_cmd
let mut balance_cmd = Command::cargo_bin("pcli").unwrap();
balance_cmd
.args([
"--data-path",
tmpdir.path().to_str().unwrap(),
"tx",
"position",
"order",
"sell",
"1cube@1penumbra",
"view",
"balance",
])
.timeout(std::time::Duration::from_secs(TIMEOUT_COMMAND_SECONDS));
sell_cmd.assert().success();

let mut balance_cmd = Command::cargo_bin("pcli").unwrap();
balance_cmd
.assert()
// Address 0 has 100gm.
.stdout(predicate::str::is_match(format!(r"1\s*100gm")).unwrap())
// Address 1 has no gm.
.stdout(predicate::str::is_match(format!(r"1\s.*gm")).unwrap().not())
// Address 0 has 1001penumbra.
.stdout(predicate::str::is_match(format!(r"0\s*1001penumbra")).unwrap())
// Address 1 has 1001penumbra.
.stdout(predicate::str::is_match(format!(r"1\s*1001penumbra")).unwrap());

// Address 0: post an order to sell 1gm for 1penumbra.
let mut sell_cmd = Command::cargo_bin("pcli").unwrap();
sell_cmd
.args([
"--data-path",
tmpdir.path().to_str().unwrap(),
"view",
"balance",
"tx",
"position",
"order",
"sell",
"1gm@1penumbra",
])
.timeout(std::time::Duration::from_secs(TIMEOUT_COMMAND_SECONDS));
sell_cmd.assert().success();

balance_cmd
.assert()
// Address 0 has no `cube`.
.stdout(
predicate::str::is_match(format!(r"0\s*[0-9]+.*cube"))
.unwrap()
.not(),
)
// Address 1 should also have no cube.
.stdout(
predicate::str::is_match(format!(r"1\s*[0-9]+.*cube"))
.unwrap()
.not(),
)
// Address 0 has 100gm.
.stdout(predicate::str::is_match(format!(r"0\s*100gm")).unwrap())
// Address 1 has no gm.
.stdout(predicate::str::is_match(format!(r"1\s.*gm")).unwrap().not())
// Address 0 has 1000penumbra (1penumbra in the pool).
.stdout(predicate::str::is_match(format!(r"0\s*1000penumbra")).unwrap())
// Address 1 has 1001penumbra.
.stdout(predicate::str::is_match(format!(r"1\s*1001penumbra")).unwrap())
// Address 0 should have some penumbra
.stdout(predicate::str::is_match(format!(r"0\s*[0-9]+.*penumbra")).unwrap());
.stdout(predicate::str::is_match(format!(r"1\s*1001penumbra")).unwrap());

// Swap 1penumbra for some cube from address 1.
// Address 1 swaps 1penumbra for 1gm.
let mut swap_cmd = Command::cargo_bin("pcli").unwrap();
swap_cmd
.args([
Expand All @@ -625,7 +628,7 @@ fn swap() {
"swap",
"1penumbra",
"--into",
"cube",
"gm",
"--source",
"1",
])
Expand All @@ -646,16 +649,16 @@ fn swap() {

balance_cmd
.assert()
// Address 1 has 1cube now
.stdout(predicate::str::is_match(format!(r"1\s*1cube")).unwrap())
// and address 0 has no cube.
.stdout(
predicate::str::is_match(format!(r"0\s*[0-9]+.*cube"))
.unwrap()
.not(),
)
// Address 1 spent 1penumbra.
// Address 0 has 100gm.
.stdout(predicate::str::is_match(format!(r"0\s*100gm")).unwrap())
// Address 1 has 1gm.
.stdout(predicate::str::is_match(format!(r"0\s*1gm")).unwrap())
// Address 0 has 1001penumbra.
.stdout(predicate::str::is_match(format!(r"1\s*1001penumbra")).unwrap())
// Address 1 has 1000penumbra.
.stdout(predicate::str::is_match(format!(r"1\s*1000penumbra")).unwrap());

// TODO: it would be nice to test withdrawing the position.
}

// Note: As part of #2589, we changed the way DEX calculations are performed. In particular,
Expand Down Expand Up @@ -1010,7 +1013,7 @@ fn test_orders() {
.timeout(std::time::Duration::from_secs(TIMEOUT_COMMAND_SECONDS));
sell_cmd.assert().success();

// Swap 225test_usd for some penumbra. In theory, we should receive 1 penumbra for 225test_usd
// Swap 225test_usd for some penumbra. In theory, we should receive ~1 penumbra for 225test_usd
// based on the position above. In practice, we'll receive slightly less due to rounding: 0.99999penumbra.
let mut swap_cmd = Command::cargo_bin("pcli").unwrap();
swap_cmd
Expand Down Expand Up @@ -1124,7 +1127,6 @@ fn test_orders() {
.success();

// The position should now have some penumbra reserves, so we can swap against it again...

// Swap 225test_usd for some penumbra. We expect to receive 1penumbra for 225test_usd
// based on the position above.
let mut swap_cmd = Command::cargo_bin("pcli").unwrap();
Expand All @@ -1143,7 +1145,7 @@ fn test_orders() {
.assert()
.stdout(
predicate::str::is_match(
"You will receive outputs of 0test_usd and 1penumbra. Claiming now...",
"You will receive outputs of 0test_usd and 999.999mpenumbra. Claiming now...",
)
.unwrap(),
)
Expand Down

0 comments on commit 51bc97f

Please sign in to comment.