Skip to content
Merged
3 changes: 1 addition & 2 deletions cmd/crates/soroban-test/tests/it/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ mod contract;
mod cookbook;
mod custom_types;
mod dotenv;
mod fee_args;
mod fee_stats;
mod fees;
mod hello_world;
mod init;
mod keys;
Expand Down
32 changes: 0 additions & 32 deletions cmd/crates/soroban-test/tests/it/integration/fee_stats.rs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
use predicates::prelude::predicate;
use soroban_cli::xdr::{self, Limits, ReadXdr};
use soroban_rpc::GetFeeStatsResponse;
use soroban_test::{AssertExt, TestEnv};

use super::util::deploy_hello;
use super::util::{deploy_hello, HELLO_WORLD};

fn get_inclusion_fee_from_xdr(tx_xdr: &str) -> u32 {
let tx = xdr::TransactionEnvelope::from_xdr_base64(tx_xdr, Limits::none()).unwrap();
Expand All @@ -13,6 +14,36 @@ fn get_inclusion_fee_from_xdr(tx_xdr: &str) -> u32 {
}
}

#[tokio::test]
async fn fee_stats_text_output() {
let sandbox = &TestEnv::new();
sandbox
.new_assert_cmd("fees")
.arg("stats")
.arg("--output")
.arg("text")
.assert()
.success()
.stdout(predicates::str::contains("Max Soroban Inclusion Fee:"))
.stdout(predicates::str::contains("Max Inclusion Fee:"))
.stdout(predicates::str::contains("Latest Ledger:"));
}

#[tokio::test]
async fn fee_stats_json_output() {
let sandbox = &TestEnv::new();
let output = sandbox
.new_assert_cmd("fees")
.arg("stats")
.arg("--output")
.arg("json")
.assert()
.success()
.stdout_as_str();
let fee_stats_response: GetFeeStatsResponse = serde_json::from_str(&output).unwrap();
assert!(matches!(fee_stats_response, GetFeeStatsResponse { .. }))
}

#[tokio::test]
async fn inclusion_fee_arg() {
let sandbox = &TestEnv::new();
Expand Down Expand Up @@ -138,3 +169,45 @@ async fn inclusion_fee_arg() {
.stdout_as_str();
assert_eq!(get_inclusion_fee_from_xdr(&tx_xdr), 100u32);
}

#[tokio::test]
async fn large_fee_transactions_use_fee_bump() {
let sandbox = &TestEnv::new();

// install HELLO_WORLD
// don't test fee bump here as other integration tests upload WASMs, so this
// might be a no-op
let wasm_hash = sandbox
.new_assert_cmd("contract")
.arg("upload")
.arg("--wasm")
.arg(HELLO_WORLD.path().to_string_lossy().to_string())
.assert()
.success()
.stdout_as_str();

// deploy HELLO_WORLD with a high inclusion fee to trigger fee-bump wrapping
let id = sandbox
.new_assert_cmd("contract")
.arg("deploy")
.args(["--wasm-hash", wasm_hash.trim()])
.args(["--inclusion-fee", &(u32::MAX - 50).to_string()])
.assert()
.success()
.stdout_as_str();

// invoke HELLO_WORLD with a high resource fee to trigger fee-bump wrapping
let std_err = sandbox
.new_assert_cmd("contract")
.arg("invoke")
.args(["--id", &id.to_string()])
.args(["--resource-fee", &(u64::from(u32::MAX) + 1).to_string()])
.arg("--")
.arg("inc")
.assert()
.success()
.stderr_as_str();

// validate log output indicates fee bump was used
assert!(std_err.contains("Signing fee bump transaction"));
}
Loading