Skip to content

Commit

Permalink
Add test with local anvil instance
Browse files Browse the repository at this point in the history
  • Loading branch information
entropidelic committed Oct 18, 2024
1 parent 1c60221 commit fe666db
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 22 deletions.
42 changes: 40 additions & 2 deletions batcher/aligned-batcher/src/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,20 @@ where
mod test {
use super::*;
use crate::eth;
use ethers::{providers::Middleware, types::U256};
use std::time::SystemTime;
use aligned_sdk::eth::batcher_payment_service::BatcherPaymentService;
use ethers::{
contract::abigen,
providers::{Http, Middleware, Provider},
types::{Address, U256},
utils::Anvil,
};
use std::str::FromStr;
use std::{sync::Arc, time::SystemTime};

abigen!(
BatcherPaymentServiceContract,
"../aligned-sdk/abi/BatcherPaymentService.json"
);

#[tokio::test]
async fn retry_test() {
Expand Down Expand Up @@ -81,4 +93,30 @@ mod test {

assert!(retry_function(get_gas_price, 2000, 2.0, 3).await.is_ok());
}

#[tokio::test]
async fn test_anvil() {
let _anvil = Anvil::new()
.port(8545u16)
.arg("--load-state")
.arg("../../contracts/scripts/anvil/state/alignedlayer-deployed-anvil-state.json")
.spawn();

let eth_rpc_provider: Provider<Http> =
eth::get_provider(String::from("http://localhost:8545"))
.expect("Failed to get provider");

let payment_service_addr =
Address::from_str("0x7969c5eD335650692Bc04293B07F5BF2e7A673C0").unwrap();

let payment_service =
BatcherPaymentService::new(payment_service_addr, Arc::new(eth_rpc_provider));

let dummy_user_addr =
Address::from_str("0x8969c5eD335650692Bc04293B07F5BF2e7A673C0").unwrap();

if let Ok(balance) = payment_service.user_balances(dummy_user_addr).call().await {
println!("ALIGNED USER BALANCE: {:?}", balance)
};
}
}
2 changes: 0 additions & 2 deletions batcher/aligned/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ async fn main() -> Result<(), AlignedError> {

let chain_id = get_chain_id(eth_rpc_url.as_str()).await?;
wallet = wallet.with_chain_id(chain_id);

let nonce = match &submit_args.nonce {
Some(nonce) => U256::from_dec_str(nonce).map_err(|_| SubmitError::InvalidNonce)?,
None => {
Expand Down Expand Up @@ -342,7 +341,6 @@ async fn main() -> Result<(), AlignedError> {
};

let mut unique_batch_merkle_roots = HashSet::new();

for aligned_verification_data in aligned_verification_data_vec {
save_response(
batch_inclusion_data_directory_path.clone(),
Expand Down
41 changes: 23 additions & 18 deletions operator/merkle_tree/lib/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit fe666db

Please sign in to comment.