diff --git a/packages/fuel-indexer-tests/contracts/fuel-indexer-test/src/main.sw b/packages/fuel-indexer-tests/contracts/fuel-indexer-test/src/main.sw index ab16f0f1d..04afb8400 100644 --- a/packages/fuel-indexer-tests/contracts/fuel-indexer-test/src/main.sw +++ b/packages/fuel-indexer-tests/contracts/fuel-indexer-test/src/main.sw @@ -184,7 +184,7 @@ impl FuelIndexer for Contract { #[payable] fn trigger_transferout() { const RECEIVER = Address::from(0x532ee5fb2cabec472409eb5f9b42b59644edb7bf9943eda9c2e3947305ed5e96); - transfer(msg_sender().unwrap(), BASE_ASSET_ID, 1); + transfer_to_address(RECEIVER, BASE_ASSET_ID, 1); } #[payable] diff --git a/packages/fuel-indexer-tests/src/fixtures.rs b/packages/fuel-indexer-tests/src/fixtures.rs index 0d03aa2d2..3ec2ff926 100644 --- a/packages/fuel-indexer-tests/src/fixtures.rs +++ b/packages/fuel-indexer-tests/src/fixtures.rs @@ -450,6 +450,7 @@ pub mod test_web { }; use async_std::sync::Arc; use fuels::prelude::{CallParameters, Provider, WalletUnlocked}; + use fuels::programs::call_utils::TxDependencyExtension; use fuels::types::bech32::Bech32ContractId; use std::path::Path; @@ -544,8 +545,6 @@ pub mod test_web { HttpResponse::Ok() } - // TODO: TransferOut is currently ignored due to flakiness; - // transfering to an address fails for some unknown reason async fn fuel_indexer_test_transferout( state: web::Data>, ) -> impl Responder { @@ -556,6 +555,7 @@ pub mod test_web { .contract .methods() .trigger_transferout() + .append_variable_outputs(1) .tx_params(tx_params()) .call_params(call_params) .expect("Could not set call parameters for contract method") diff --git a/packages/fuel-indexer-tests/tests/indexing.rs b/packages/fuel-indexer-tests/tests/indexing.rs index d4daf3fae..fdac32699 100644 --- a/packages/fuel-indexer-tests/tests/indexing.rs +++ b/packages/fuel-indexer-tests/tests/indexing.rs @@ -208,6 +208,21 @@ async fn test_index_receipt_types() { assert_eq!(row.get::(3).to_u64().unwrap(), 1); // value is defined in test contract assert_eq!(row.get::<&str, usize>(4), TRANSFER_BASE_ASSET_ID); + mock_request("/transferout").await; + + let row = + sqlx::query("SELECT * FROM fuel_indexer_test_index1.transferoutentity LIMIT 1") + .fetch_one(&mut conn) + .await + .unwrap(); + + assert_eq!( + row.get::<&str, usize>(2), + "eb2b3758087983c0d36217befc8f3abf3c140e8090986c8b46382d1b79fa9b3b" + ); + assert_eq!(row.get::(3).to_u64().unwrap(), 1); + assert_eq!(row.get::<&str, usize>(4), TRANSFER_BASE_ASSET_ID); + mock_request("/revert").await; let row = sqlx::query("SELECT * FROM fuel_indexer_test_index1.revertentity LIMIT 1") @@ -346,34 +361,6 @@ async fn test_index_optional_types() { assert!(row.get::, usize>(3).is_none()); } -// FIXME: TransferOut fails due to a failure in the contract, -// not sure what the problem is yet. -#[actix_web::test] -#[ignore] -async fn test_can_trigger_and_index_transferout_event_postgres() { - let IndexingTestComponents { - ref node, ref db, .. - } = setup_indexing_test_components(None).await; - - mock_request("/transferout").await; - - node.abort(); - - let mut conn = db.pool.acquire().await.unwrap(); - let row = - sqlx::query("SELECT * FROM fuel_indexer_test_index1.transferoutentity LIMIT 1") - .fetch_one(&mut conn) - .await - .unwrap(); - - assert_eq!( - row.get::<&str, usize>(2), - "532ee5fb2cabec472409eb5f9b42b59644edb7bf9943eda9c2e3947305ed5e96" - ); - assert_eq!(row.get::(3).to_u64().unwrap(), 1); - assert_eq!(row.get::<&str, usize>(4), TRANSFER_BASE_ASSET_ID); -} - #[actix_web::test] async fn test_index_tuples() { let IndexingTestComponents {