Skip to content

Commit

Permalink
test: add test for expired transaction (#649)
Browse files Browse the repository at this point in the history
* test: add test for expired transaction

* review: remove debug print
  • Loading branch information
SantiagoPittella authored Jan 3, 2025
1 parent 5f13c47 commit 2149038
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions tests/integration/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1411,3 +1411,47 @@ async fn test_locked_account() {
let account_record = client_2.get_account(from_account_id).await.unwrap();
assert!(!account_record.is_locked());
}

#[tokio::test]
async fn test_expired_transaction_fails() {
let mut client = create_test_client().await;
let (faucet_account, _) = insert_new_fungible_faucet(&mut client, AccountStorageMode::Private)
.await
.unwrap();

let (private_account, _) =
insert_new_wallet(&mut client, AccountStorageMode::Private).await.unwrap();

let from_account_id = private_account.id();
let faucet_account_id = faucet_account.id();

wait_for_node(&mut client).await;

let expiration_delta = 2;

// Create a Mint Tx for 1000 units of our fungible asset
let fungible_asset = FungibleAsset::new(faucet_account_id, MINT_AMOUNT).unwrap();
println!("Minting Asset");
let tx_request = TransactionRequestBuilder::mint_fungible_asset(
fungible_asset,
from_account_id,
NoteType::Public,
client.rng(),
)
.unwrap()
.with_expiration_delta(expiration_delta)
.unwrap()
.build();

println!("Executing transaction...");
let transaction_execution_result =
client.new_transaction(faucet_account_id, tx_request).await.unwrap();

println!("Transaction executed successfully");
wait_for_blocks(&mut client, (expiration_delta + 1).into()).await;

println!("Sending transaction to node");
let submited_tx_result = client.submit_transaction(transaction_execution_result).await;

assert!(submited_tx_result.is_err());
}

0 comments on commit 2149038

Please sign in to comment.