Hi guys
I’m just remastered this tutorial to input_owner
func test. The predicate looks like that
predicate;
use std::inputs::input_owner;
fn main(address: Address) -> bool {
input_owner(0).unwrap() == address || input_owner(1).unwrap() == address
}
and the test
use fuels::{
accounts::predicate::Predicate,
prelude::{abigen, Account, TxParameters, ViewOnlyAccount},
test_helpers::{launch_custom_provider_and_get_wallets, AssetConfig, WalletsConfig},
types::{AssetId, Address},
};
#[tokio::test]
async fn just_test() {
let asset_id = AssetId::default();
let wallets_config = WalletsConfig::new_multiple_assets(
2,
vec![AssetConfig {
id: asset_id,
num_coins: 1,
coin_amount: 1_000,
}],
);
let wallets = &launch_custom_provider_and_get_wallets(wallets_config, None, None).await;
let first_wallet = &wallets[0];
// let second_wallet = &wallets[1];
abigen!(Predicate(
name = "MyPredicateEncoder",
abi = "out/debug/predicates-test-abi.json"
));
let predicate_data = MyPredicateEncoder::encode_data(Address::from(first_wallet.address()));
let code_path = "out/debug/predicates-test.bin";
let predicate: Predicate = Predicate::load_from(code_path)
.unwrap()
.with_data(predicate_data)
.with_provider(first_wallet.try_provider().unwrap().clone());
// First wallet transfers amount to predicate.
first_wallet
.transfer(predicate.address(), 500, asset_id, TxParameters::default())
.await
.unwrap();
// Check predicate balance.
let balance = predicate
.get_asset_balance(&AssetId::default())
.await
.unwrap();
assert_eq!(balance, 500);
let amount_to_unlock = 500;
predicate
.transfer(
first_wallet.address(),
amount_to_unlock,
asset_id,
TxParameters::default(),
)
.await
.unwrap();
// Predicate balance is zero.
let balance = predicate
.get_asset_balance(&AssetId::default())
.await
.unwrap();
assert_eq!(balance, 0);
// first wallet balance is updated.
let balance = first_wallet
.get_asset_balance(&AssetId::default())
.await
.unwrap();
assert_eq!(balance, 1000);
}
and it gives an error like that
thread 'just_test' panicked at 'called `Result::unwrap()` on an `Err` value: IOError(Custom { kind: Other, error: "Response errors; Invalid transaction: The transaction contains a predicate which failed to validate: TransactionId(0x67e1a7730eb66855c14e1c9e3a19d937cbfdbc0a2052b2a0e2196156f60ab164)" })', tests/harness.rs:62:10
And logs don’t work inside predicates and I have no idea how to debug it
Please help