Skip to content

Commit

Permalink
fix: token amount in approval (#46)
Browse files Browse the repository at this point in the history
* fix: token amount in approval

* feat: Add source amount to BridgeResult struct and methods

* fix: remove incorrect tests

---------

Co-authored-by: Ankur Dubey <[email protected]>
  • Loading branch information
AmanRaj1608 and ankurdubey521 authored Jul 17, 2024
1 parent b900ebf commit 1118c35
Showing 1 changed file with 1 addition and 46 deletions.
47 changes: 1 addition & 46 deletions crates/routing-engine/src/settlement_engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -594,51 +594,6 @@ mod tests {
)
}

#[tokio::test]
async fn test_should_take_existing_approval_into_consideration_while_building_approval_data() {
let config = Arc::new(setup_config());
let engine = setup(&config);

let required_approval_data = RequiredApprovalDetails {
chain_id: 42161,
token_address: TOKEN_ADDRESS_USDC_42161.to_string().try_into().unwrap(),
owner: TEST_OWNER_WALLET.to_string(),
target: TARGET_100_USDC_APPROVAL_BY_OWNER_ON_42161_FOR_USDC.to_string(),
amount: U256::from(150),
};

let transaction = engine
.generate_transaction_for_approval(&required_approval_data)
.await
.unwrap()
.unwrap();

assert!(if let TransactionType::Approval(_) = transaction.transaction_type {
true
} else {
false
});

assert_eq!(transaction.transaction.to, TOKEN_ADDRESS_USDC_42161);
assert_eq!(transaction.transaction.value, U256::ZERO);
assert_eq!(
transaction.transaction.calldata,
engine
.erc20_instance_map
.get(&(required_approval_data.chain_id, required_approval_data.token_address))
.expect("ERC20 Utils not found")
.approve(
TARGET_100_USDC_APPROVAL_BY_OWNER_ON_42161_FOR_USDC
.to_string()
.parse()
.expect("Invalid address"),
U256::from(50)
)
.calldata()
.to_string()
)
}

#[tokio::test]
async fn test_should_generate_approvals_for_multiple_required_transactions() {
let config = Arc::new(setup_config());
Expand Down Expand Up @@ -713,7 +668,7 @@ mod tests {
.to_string()
.parse()
.expect("Invalid address"),
U256::from(50)
U256::from(150)
)
.calldata()
.to_string()
Expand Down

0 comments on commit 1118c35

Please sign in to comment.