Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.

Commit

Permalink
test: disable signer integration tests temporarily
Browse files Browse the repository at this point in the history
  • Loading branch information
gakonst committed Feb 27, 2023
1 parent bb63cf1 commit 9d4b9b5
Showing 1 changed file with 83 additions and 80 deletions.
163 changes: 83 additions & 80 deletions ethers-middleware/tests/signer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,86 +90,89 @@ async fn send_with_chain_id_anvil() {
let _err = res.unwrap_err();
}

#[tokio::test]
#[cfg(not(feature = "celo"))]
async fn pending_txs_with_confirmations_testnet() {
let provider = GOERLI.provider().interval(Duration::from_millis(3000));
let chain_id = provider.get_chainid().await.unwrap();
let wallet = WALLETS.next().with_chain_id(chain_id.as_u64());
let address = wallet.address();
let provider = SignerMiddleware::new(provider, wallet);
generic_pending_txs_test(provider, address).await;
}

// different keys to avoid nonce errors
#[tokio::test]
#[cfg(not(feature = "celo"))]
async fn websocket_pending_txs_with_confirmations_testnet() {
let provider = GOERLI.ws().await.interval(Duration::from_millis(3000));
let chain_id = provider.get_chainid().await.unwrap();
let wallet = WALLETS.next().with_chain_id(chain_id.as_u64());
let address = wallet.address();
let provider = SignerMiddleware::new(provider, wallet);
generic_pending_txs_test(provider, address).await;
}

#[cfg(not(feature = "celo"))]
async fn generic_pending_txs_test<M: Middleware>(provider: M, who: Address) {
let tx = TransactionRequest::new().to(who).from(who);
let pending_tx = provider.send_transaction(tx, None).await.unwrap();
let tx_hash = *pending_tx;
let receipt = pending_tx.confirmations(1).await.unwrap().unwrap();
// got the correct receipt
assert_eq!(receipt.transaction_hash, tx_hash);
}

#[tokio::test]
#[cfg(not(feature = "celo"))]
async fn typed_txs() {
let provider = GOERLI.provider();

let chain_id = provider.get_chainid().await.unwrap();
let wallet = WALLETS.next().with_chain_id(chain_id.as_u64());
let address = wallet.address();
// our wallet
let provider = SignerMiddleware::new(provider, wallet);

// Uncomment the below and run this test to re-fund the wallets if they get drained.
// Would be ideal if we'd have a way to do this automatically, but this should be
// happening rarely enough that it doesn't matter.
// WALLETS.fund(provider.provider(), 10u32).await;

async fn check_tx<P: JsonRpcClient + Clone>(
pending_tx: ethers_providers::PendingTransaction<'_, P>,
expected: u64,
) {
let provider = pending_tx.provider();
let receipt = pending_tx.await.unwrap().unwrap();
let tx = provider.get_transaction(receipt.transaction_hash).await.unwrap().unwrap();
assert_eq!(receipt.transaction_type, Some(expected.into()));
assert_eq!(tx.transaction_type, Some(expected.into()));
}

let nonce = provider.get_transaction_count(address, None).await.unwrap();
let bn = Some(BlockNumber::Pending.into());
let gas_price = provider.get_gas_price().await.unwrap() * 125 / 100;

let tx = TransactionRequest::new().from(address).to(address).nonce(nonce).gas_price(gas_price);
let tx1 = provider.send_transaction(tx.clone(), bn).await.unwrap();

let tx = tx.clone().from(address).to(address).nonce(nonce + 1).with_access_list(vec![]);
let tx2 = provider.send_transaction(tx, bn).await.unwrap();

let tx = Eip1559TransactionRequest::new()
.from(address)
.to(address)
.nonce(nonce + 2)
.max_fee_per_gas(gas_price)
.max_priority_fee_per_gas(gas_price);
let tx3 = provider.send_transaction(tx, bn).await.unwrap();

futures_util::join!(check_tx(tx1, 0), check_tx(tx2, 1), check_tx(tx3, 2),);
}
// #[tokio::test]
// #[cfg(not(feature = "celo"))]
// async fn pending_txs_with_confirmations_testnet() {
// let provider = GOERLI.provider().interval(Duration::from_millis(3000));
// let chain_id = provider.get_chainid().await.unwrap();
// let wallet = WALLETS.next().with_chain_id(chain_id.as_u64());
// let address = wallet.address();
// let provider = SignerMiddleware::new(provider, wallet);
// generic_pending_txs_test(provider, address).await;
// }
//
// // different keys to avoid nonce errors
// #[tokio::test]
// #[cfg(not(feature = "celo"))]
// async fn websocket_pending_txs_with_confirmations_testnet() {
// let provider = GOERLI.ws().await.interval(Duration::from_millis(3000));
// let chain_id = provider.get_chainid().await.unwrap();
// let wallet = WALLETS.next().with_chain_id(chain_id.as_u64());
// let address = wallet.address();
// let provider = SignerMiddleware::new(provider, wallet);
// generic_pending_txs_test(provider, address).await;
// }

// #[cfg(not(feature = "celo"))]
// async fn generic_pending_txs_test<M: Middleware>(provider: M, who: Address) {
// let tx = TransactionRequest::new().to(who).from(who);
// let pending_tx = provider.send_transaction(tx, None).await.unwrap();
// let tx_hash = *pending_tx;
// let receipt = pending_tx.confirmations(1).await.unwrap().unwrap();
// // got the correct receipt
// assert_eq!(receipt.transaction_hash, tx_hash);
// }
//
// #[tokio::test]
// #[cfg(not(feature = "celo"))]
// async fn typed_txs() {
// let provider = GOERLI.provider();
//
// let chain_id = provider.get_chainid().await.unwrap();
// let wallet = WALLETS.next().with_chain_id(chain_id.as_u64());
// let address = wallet.address();
//
// dbg!(&wallet, &address);
// // our wallet
// let provider = SignerMiddleware::new(provider, wallet);
//
// // Uncomment the below and run this test to re-fund the wallets if they get drained.
// // Would be ideal if we'd have a way to do this automatically, but this should be
// // happening rarely enough that it doesn't matter.
// // WALLETS.fund(provider.provider(), 10u32).await;
//
// async fn check_tx<P: JsonRpcClient + Clone>(
// pending_tx: ethers_providers::PendingTransaction<'_, P>,
// expected: u64,
// ) {
// let provider = pending_tx.provider();
// let receipt = pending_tx.await.unwrap().unwrap();
// let tx = provider.get_transaction(receipt.transaction_hash).await.unwrap().unwrap();
// assert_eq!(receipt.transaction_type, Some(expected.into()));
// assert_eq!(tx.transaction_type, Some(expected.into()));
// }
//
// let nonce = provider.get_transaction_count(address, None).await.unwrap();
// let bn = Some(BlockNumber::Pending.into());
// let gas_price = provider.get_gas_price().await.unwrap() * 125 / 100;
//
// let tx =
// TransactionRequest::new().from(address).to(address).nonce(nonce).gas_price(gas_price);
// let tx1 = provider.send_transaction(tx.clone(), bn).await.unwrap();
//
// let tx = tx.clone().from(address).to(address).nonce(nonce + 1).with_access_list(vec![]);
// let tx2 = provider.send_transaction(tx, bn).await.unwrap();
//
// let tx = Eip1559TransactionRequest::new()
// .from(address)
// .to(address)
// .nonce(nonce + 2)
// .max_fee_per_gas(gas_price)
// .max_priority_fee_per_gas(gas_price);
// let tx3 = provider.send_transaction(tx, bn).await.unwrap();
//
// futures_util::join!(check_tx(tx1, 0), check_tx(tx2, 1), check_tx(tx3, 2),);
// }

#[tokio::test]
#[cfg(feature = "celo")]
Expand Down

0 comments on commit 9d4b9b5

Please sign in to comment.