Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
fix: Fix TransferOut test (#1356)
Browse files Browse the repository at this point in the history
* fix: Fix TransferOut test

* fix: add append_variable_outputs to contract call

* fix: Updated assertion in tests

* Fix: re-integrated the TransferOut test within the index_receipt_types test

---------

Co-authored-by: Alexander <[email protected]>
  • Loading branch information
dadepo and deekerno authored Sep 19, 2023
1 parent 46dea91 commit 67b09ae
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
4 changes: 2 additions & 2 deletions packages/fuel-indexer-tests/src/fixtures.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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<Arc<AppState>>,
) -> impl Responder {
Expand All @@ -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")
Expand Down
43 changes: 15 additions & 28 deletions packages/fuel-indexer-tests/tests/indexing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,21 @@ async fn test_index_receipt_types() {
assert_eq!(row.get::<BigDecimal, usize>(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::<BigDecimal, usize>(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")
Expand Down Expand Up @@ -346,34 +361,6 @@ async fn test_index_optional_types() {
assert!(row.get::<Option<&str>, 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::<BigDecimal, usize>(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 {
Expand Down

0 comments on commit 67b09ae

Please sign in to comment.