Skip to content

Commit

Permalink
test: add reach through proxy test
Browse files Browse the repository at this point in the history
  • Loading branch information
mickvandijke committed Dec 8, 2024
1 parent 37555c9 commit 4ee7f93
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 5 deletions.
6 changes: 3 additions & 3 deletions evmlib/src/contract/payment_vault/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ where
}

/// Fetch a quote from the contract
pub async fn fetch_quote(
pub async fn get_quote<I: Into<IPaymentVault::QuotingMetrics>>(
&self,
metrics: IPaymentVault::QuotingMetrics,
metrics: I,
) -> Result<Amount, Error> {
let amount = self.contract.getQuote(metrics).call().await?.price;
let amount = self.contract.getQuote(metrics.into()).call().await?.price;
Ok(amount)
}

Expand Down
2 changes: 1 addition & 1 deletion evmlib/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ fn local_evm_network_from_csv() -> Result<Network, Error> {
}

#[allow(clippy::type_complexity)]
pub(crate) fn http_provider(
pub fn http_provider(
rpc_url: reqwest::Url,
) -> FillProvider<
JoinFill<
Expand Down
19 changes: 18 additions & 1 deletion evmlib/tests/payment_vault.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@ use alloy::providers::fillers::{
use alloy::providers::{Identity, ProviderBuilder, ReqwestProvider, WalletProvider};
use alloy::signers::local::{LocalSigner, PrivateKeySigner};
use alloy::transports::http::{Client, Http};
use evmlib::common::U256;
use evmlib::common::{Amount, U256};
use evmlib::contract::network_token::NetworkToken;
use evmlib::contract::payment_vault::handler::PaymentVaultHandler;
use evmlib::contract::payment_vault::MAX_TRANSFERS_PER_TRANSACTION;
use evmlib::quoting_metrics::QuotingMetrics;
use evmlib::testnet::{deploy_data_payments_contract, deploy_network_token_contract, start_node};
use evmlib::utils::http_provider;
use evmlib::wallet::wallet_address;
use evmlib::Network;

async fn setup() -> (
AnvilInstance,
Expand Down Expand Up @@ -112,6 +115,20 @@ async fn test_deploy() {
setup().await;
}

#[tokio::test]
async fn test_proxy_reachable() {
let network = Network::ArbitrumOne;
let provider = http_provider(network.rpc_url().clone());
let payment_vault = PaymentVaultHandler::new(*network.data_payments_address(), provider);

let amount = payment_vault
.get_quote(QuotingMetrics::default())
.await
.unwrap();

assert_eq!(amount, Amount::from(1));
}

#[tokio::test]
async fn test_pay_for_quotes() {
let (_anvil, network_token, mut data_payments) = setup().await;
Expand Down

0 comments on commit 4ee7f93

Please sign in to comment.