How do you print b256 in test cases? Tried logging in Sway too, doesn’t show anything.
use fuels::{prelude::*, types::ContractId};
abigen!(Contract(name="MyContract", abi="out/debug/test_asset-abi.json"));
#[tokio::test]
async fn test_harness() {
// Test code here
let (instance, _id) = get_contract_instance().await;
let result = instance.methods().deposit().call().await.unwrap();
let result2 = instance.methods().test_deposit_asset_id_same_generated().call().await.unwrap();
println!("{result}",result);
println!("{result2}",result);
}
async fn get_contract_instance() -> (MyContract<WalletUnlocked>, ContractId) {
// Launch a local network and deploy the contract
let wallets = launch_custom_provider_and_get_wallets(
WalletsConfig::new(
Some(3), /* Three wallets */
Some(1), /* Single coin (UTXO) */
Some(1_000_000_000), /* Amount per coin */
),
None,
None,
)
.await
.unwrap();
let wallet = wallets.get(0).unwrap().clone();
let id = Contract::load_from(
"./out/debug/test_asset.bin",
LoadConfiguration::default(),
)
.unwrap()
.deploy(&wallet, TxPolicies::default())
.await
.unwrap();
let instance = MyContract::new(id.clone(), wallet);
(instance, id.into())
}
Error:
error[E0277]: `FuelCallResponse<Bits256>` doesn't implement `std::fmt::Display`
--> tests/harness.rs:13:15
|
13 | println!("{result}",result);
| ^^^^^^^^ `FuelCallResponse<Bits256>` cannot be formatted with the default formatter
|
= help: the trait `std::fmt::Display` is not implemented for `FuelCallResponse<Bits256>`
= note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
= note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info)
error[E0277]: `FuelCallResponse<Bits256>` doesn't implement `std::fmt::Display`
--> tests/harness.rs:14:15
|
14 | println!("{result2}",result);
| ^^^^^^^^^ `FuelCallResponse<Bits256>` cannot be formatted with the default formatted