diff --git a/packages/fuels/tests/types/contracts/std_lib_string/src/main.sw b/packages/fuels/tests/types/contracts/std_lib_string/src/main.sw index fc9cea9152..ff1694a781 100644 --- a/packages/fuels/tests/types/contracts/std_lib_string/src/main.sw +++ b/packages/fuels/tests/types/contracts/std_lib_string/src/main.sw @@ -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 { @@ -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 + } } diff --git a/packages/fuels/tests/types_contracts.rs b/packages/fuels/tests/types_contracts.rs index 7634db8a2a..b975a8a403 100644 --- a/packages/fuels/tests/types_contracts.rs +++ b/packages/fuels/tests/types_contracts.rs @@ -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(()) }