Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: fix arbitrary test delay #12

Merged
merged 1 commit into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions crates/yttrium/src/bundler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ impl BundlerClient {

let user_operation_hash = response?;

Ok(user_operation_hash)
Ok(user_operation_hash.unwrap())
}

pub async fn estimate_user_operation_gas(
Expand Down Expand Up @@ -108,7 +108,7 @@ impl BundlerClient {

let response_estimate = response?;

Ok(response_estimate)
Ok(response_estimate.unwrap())
}

pub async fn supported_entry_points(
Expand All @@ -132,7 +132,7 @@ impl BundlerClient {
pub async fn get_user_operation_receipt(
&self,
hash: String,
) -> eyre::Result<UserOperationReceipt> {
) -> eyre::Result<Option<UserOperationReceipt>> {
let bundler_url = self.config.url().clone();

let hash_value = serde_json::to_value(&hash)?;
Expand Down Expand Up @@ -180,7 +180,7 @@ impl BundlerClient {

loop {
match self.get_user_operation_receipt(hash.clone()).await {
eyre::Result::Ok(receipt) => return Ok(receipt),
eyre::Result::Ok(Some(receipt)) => return Ok(receipt),
_ => {
if let Some(timeout_duration) = timeout {
if start_time.elapsed() > timeout_duration {
Expand Down Expand Up @@ -351,7 +351,7 @@ mod tests {
.get_user_operation_receipt(user_operation_hash.clone())
.await?;

eyre::ensure!(receipt == response_payload);
assert_eq!(receipt, Some(response_payload));

Ok(())
}
Expand Down
1 change: 1 addition & 0 deletions crates/yttrium/src/bundler/pimlico/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ impl BundlerClient {
let response: Response<GasPrice> = v.into();

let response_estimate = response?;
let response_estimate = response_estimate.unwrap();

Ok(response_estimate)
}
Expand Down
1 change: 1 addition & 0 deletions crates/yttrium/src/bundler/pimlico/paymaster/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ impl PaymasterClient {
let response: Response<SponsorshipResponseV07> = v.into();

let response_estimate = response?;
let response_estimate = response_estimate.unwrap();

let result = SponsorshipResultV07 {
call_gas_limit: response_estimate.call_gas_limit,
Expand Down
6 changes: 3 additions & 3 deletions crates/yttrium/src/jsonrpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use serde::{Deserialize, Serialize};
use std::fmt;
use thiserror::Error;

pub type Response<T> = Result<T, ErrorPayload<T>>;
pub type Response<T> = Result<Option<T>, ErrorPayload<T>>;

#[derive(Debug, Deserialize, Error)]
pub struct ErrorPayload<T> {
Expand All @@ -28,14 +28,14 @@ pub struct JSONRPCResponse<T> {
impl<T> Into<Response<T>> for JSONRPCResponse<T> {
fn into(self) -> Response<T> {
if let Some(result) = self.result {
return Ok(result);
return Ok(Some(result));
}

if let Some(error) = self.error {
return Err(error);
}

panic!("Malformed response");
Ok(None)
}
}

Expand Down
9 changes: 0 additions & 9 deletions crates/yttrium/src/transaction/send/safe_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,15 +440,6 @@ mod tests {

println!("Received User Operation hash: {:?}", user_operation_hash);

// TODO convert to polling
tokio::time::sleep(Duration::from_secs(2)).await;

let receipt = bundler_client
.get_user_operation_receipt(user_operation_hash.clone())
.await?;

println!("Received User Operation receipt: {:?}", receipt);

println!("Querying for receipts...");

let receipt = bundler_client
Expand Down
13 changes: 2 additions & 11 deletions crates/yttrium/src/transaction/send/simple_account_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -236,23 +236,14 @@ mod tests {
)
.await?;

println!("Received User Operation hash: {:?}", user_operation_hash);

// TODO convert to polling
tokio::time::sleep(Duration::from_secs(2)).await;

let receipt = bundler_client
.get_user_operation_receipt(user_operation_hash.clone())
.await?;

println!("Received User Operation receipt: {:?}", receipt);

println!("Querying for receipts...");

let receipt = bundler_client
.wait_for_user_operation_receipt(user_operation_hash.clone())
.await?;

println!("Received User Operation receipt: {:?}", receipt);

let tx_hash = receipt.receipt.transaction_hash;
println!(
"UserOperation included: https://sepolia.etherscan.io/tx/{}",
Expand Down