From 0bc22d59ff6752b017a8b6d8ec548a766d6b2a64 Mon Sep 17 00:00:00 2001 From: Stefan Date: Tue, 10 Dec 2024 16:49:11 +0100 Subject: [PATCH] Mempool syncer: fix merge conflicts --- mempool/src/sync/mod.rs | 3 +-- mempool/tests/mod.rs | 14 ++++++++------ test-utils/src/consensus.rs | 7 ++----- validator/src/proposal_buffer.rs | 6 +----- 4 files changed, 12 insertions(+), 18 deletions(-) diff --git a/mempool/src/sync/mod.rs b/mempool/src/sync/mod.rs index 01e0035765..d72065d550 100644 --- a/mempool/src/sync/mod.rs +++ b/mempool/src/sync/mod.rs @@ -25,11 +25,10 @@ use nimiq_network_interface::{ peer_info::Services, request::{request_handler, RequestError}, }; -use nimiq_time::sleep_until; +use nimiq_time::{sleep_until, Sleep}; use nimiq_transaction::{historic_transaction::RawTransactionHash, Transaction}; use nimiq_utils::{spawn, stream::FuturesUnordered}; use parking_lot::RwLock; -use tokio::time::Sleep; use tokio_stream::wrappers::BroadcastStream; use crate::{executor::PubsubIdOrPeerId, mempool_state::MempoolState}; diff --git a/mempool/tests/mod.rs b/mempool/tests/mod.rs index 319eaf2308..ec5f5b29d6 100644 --- a/mempool/tests/mod.rs +++ b/mempool/tests/mod.rs @@ -2051,14 +2051,15 @@ async fn assert_rebase_invalidates_mempool_tx(tx1: Transaction, tx2: Transaction let temp_producer2 = TemporaryBlockProducer::new(); assert_eq!(temp_producer2.push(block), Ok(PushResult::Extended)); + let mut hub = MockHub::new(); + let mock_id = MockId::new(hub.new_address().into()); + let mock_network = Arc::new(hub.new_network()); // Create mempool and subscribe with a custom txn stream. let mempool = Mempool::new( Arc::clone(&temp_producer1.blockchain), MempoolConfig::default(), + Arc::clone(&mock_network), ); - let mut hub = MockHub::new(); - let mock_id = MockId::new(hub.new_address().into()); - let mock_network = Arc::new(hub.new_network()); // Include tx1 in block1 let block1 = temp_producer1.next_block_with_txs(vec![], false, vec![tx1.clone()]); @@ -2088,14 +2089,15 @@ async fn assert_rebase_invalidates_mempool_tx(tx1: Transaction, tx2: Transaction async fn mempool_update_rebase_earlier_time() { let temp_producer1 = TemporaryBlockProducer::new(); + let mut hub = MockHub::new(); + let mock_id = MockId::new(hub.new_address().into()); + let mock_network = Arc::new(hub.new_network()); // Create mempool and subscribe with a custom txn stream. let mempool = Mempool::new( Arc::clone(&temp_producer1.blockchain), MempoolConfig::default(), + Arc::clone(&mock_network), ); - let mut hub = MockHub::new(); - let mock_id = MockId::new(hub.new_address().into()); - let mock_network = Arc::new(hub.new_network()); // Create vesting and redeeming txs let key_pair = ed25519_key_pair(ACCOUNT_SECRET_KEY); diff --git a/test-utils/src/consensus.rs b/test-utils/src/consensus.rs index 70f43d78e6..525c6a3643 100644 --- a/test-utils/src/consensus.rs +++ b/test-utils/src/consensus.rs @@ -2,10 +2,7 @@ use std::sync::Arc; use nimiq_blockchain::Blockchain; use nimiq_blockchain_proxy::BlockchainProxy; -use nimiq_bls::cache::PublicKeyCache; -use nimiq_consensus::{ - sync::syncer_proxy::SyncerProxy, BlsCache, Consensus, ConsensusEvent, ConsensusProxy, -}; +use nimiq_consensus::{sync::syncer_proxy::SyncerProxy, BlsCache, Consensus}; use nimiq_network_interface::network::Network; use nimiq_zkp_component::ZKPComponent; use parking_lot::{Mutex, RwLock}; @@ -13,7 +10,7 @@ use parking_lot::{Mutex, RwLock}; use crate::test_network::TestNetwork; /// Given a blockchain and a network creates an instance of Consensus. -pub async fn consensus( +pub async fn consensus( blockchain: Arc>, net: Arc, ) -> Consensus { diff --git a/validator/src/proposal_buffer.rs b/validator/src/proposal_buffer.rs index cbfa7b5612..0a7709d288 100644 --- a/validator/src/proposal_buffer.rs +++ b/validator/src/proposal_buffer.rs @@ -563,11 +563,7 @@ mod test { use futures::{FutureExt, StreamExt}; use nimiq_block::MacroHeader; - use nimiq_blockchain::Blockchain; - use nimiq_blockchain_proxy::BlockchainProxy; - use nimiq_consensus::{ - sync::syncer_proxy::SyncerProxy, BlsCache, Consensus, ConsensusEvent, ConsensusProxy, - }; + use nimiq_consensus::{ConsensusEvent, ConsensusProxy}; use nimiq_keys::{KeyPair as SchnorrKeyPair, PrivateKey as SchnorrPrivateKey}; use nimiq_network_interface::network::Network as NetworkInterface; use nimiq_network_mock::{MockHub, MockNetwork};