Skip to content

Commit

Permalink
chore: add echo string test (#1341)
Browse files Browse the repository at this point in the history
Adds a test that echoes a string from a contract and confirms the gas
usage is normal
  • Loading branch information
MujkicA authored May 4, 2024
1 parent a0cf378 commit aff51f1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use std::bytes::Bytes;
abi MyContract {
fn return_dynamic_string() -> String;
fn accepts_dynamic_string(s: String);
fn echoes_dynamic_string(s: String) -> String;
}

impl MyContract for Contract {
Expand All @@ -17,4 +18,8 @@ impl MyContract for Contract {
fn accepts_dynamic_string(string: String) {
assert_eq(string, String::from_ascii_str("Hello World"));
}

fn echoes_dynamic_string(string: String) -> String {
string
}
}
8 changes: 8 additions & 0 deletions packages/fuels/tests/types_contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2071,6 +2071,14 @@ async fn test_contract_std_lib_string() -> Result<()> {
.call()
.await?;
}
{
// confirm encoding/decoding a string wasn't faulty and led to too high gas consumption
let _resp = contract_methods
.echoes_dynamic_string(String::from("Hello Fuel"))
.with_tx_policies(TxPolicies::default().with_script_gas_limit(2000))
.call()
.await?;
}

Ok(())
}
Expand Down

0 comments on commit aff51f1

Please sign in to comment.