From 2d58760e0556666ce6e639ee8024761d72612b56 Mon Sep 17 00:00:00 2001 From: Hansie Odendaal Date: Tue, 19 Oct 2021 15:13:59 +0200 Subject: [PATCH] Change test organization --- base_layer/wallet_ffi/Cargo.toml | 2 +- base_layer/wallet_ffi/src/callback_handler.rs | 631 ------------------ .../tests/{handler => }/callbacks.rs | 8 +- base_layer/wallet_ffi/tests/handler/mod.rs | 23 - .../mock_output_manager_service.rs | 6 + base_layer/wallet_ffi/tests/mod.rs | 27 - base_layer/wallet_ffi/tests/support/mod.rs | 23 - 7 files changed, 13 insertions(+), 707 deletions(-) rename base_layer/wallet_ffi/tests/{handler => }/callbacks.rs (99%) delete mode 100644 base_layer/wallet_ffi/tests/handler/mod.rs rename base_layer/wallet_ffi/tests/{support => }/mock_output_manager_service.rs (98%) delete mode 100644 base_layer/wallet_ffi/tests/mod.rs delete mode 100644 base_layer/wallet_ffi/tests/support/mod.rs diff --git a/base_layer/wallet_ffi/Cargo.toml b/base_layer/wallet_ffi/Cargo.toml index c0e2e813265..afade9eae23 100644 --- a/base_layer/wallet_ffi/Cargo.toml +++ b/base_layer/wallet_ffi/Cargo.toml @@ -44,7 +44,7 @@ default-features = false features = ["transactions"] [lib] -crate-type = ["staticlib","cdylib"] +crate-type = ["staticlib","cdylib", "lib"] [dev-dependencies] tempfile = "3.1.0" diff --git a/base_layer/wallet_ffi/src/callback_handler.rs b/base_layer/wallet_ffi/src/callback_handler.rs index 4d25190b886..a18f597da2b 100644 --- a/base_layer/wallet_ffi/src/callback_handler.rs +++ b/base_layer/wallet_ffi/src/callback_handler.rs @@ -584,634 +584,3 @@ where TBackend: TransactionBackend + 'static } } } - -#[cfg(test)] -mod test { - use crate::callback_handler::CallbackHandler; - use chrono::Utc; - use rand::rngs::OsRng; - use std::{ - sync::{Arc, Mutex}, - thread, - time::Duration, - }; - use tari_common_types::{ - transaction::{TransactionDirection, TransactionStatus}, - types::{BlindingFactor, PrivateKey, PublicKey}, - }; - use tari_comms_dht::event::DhtEvent; - use tari_core::transactions::{ - tari_amount::{uT, MicroTari}, - transaction::Transaction, - ReceiverTransactionProtocol, - SenderTransactionProtocol, - }; - use tari_crypto::keys::{PublicKey as PublicKeyTrait, SecretKey}; - use tari_service_framework::reply_channel; - use tari_shutdown::Shutdown; - use tari_wallet::{ - output_manager_service::{ - handle::{OutputManagerEvent, OutputManagerHandle}, - service::Balance, - }, - test_utils::make_wallet_database_connection, - transaction_service::{ - handle::TransactionEvent, - storage::{ - database::TransactionDatabase, - models::{CompletedTransaction, InboundTransaction, OutboundTransaction}, - sqlite_db::TransactionServiceSqliteDatabase, - }, - }, - }; - use tokio::{runtime::Runtime, sync::broadcast}; - - use futures::StreamExt; - use tari_service_framework::reply_channel::Receiver; - use tari_shutdown::ShutdownSignal; - use tari_wallet::output_manager_service::{ - error::OutputManagerError, - handle::{OutputManagerRequest, OutputManagerResponse}, - }; - use tokio::time::Instant; - - /// This macro unlocks a Mutex or RwLock. If the lock is poisoned (i.e. panic while unlocked) the last value - /// before the panic is used. - macro_rules! acquire_lock { - ($e:expr, $m:ident) => { - match $e.$m() { - Ok(lock) => lock, - Err(poisoned) => { - log::warn!(target: "wallet", "Lock has been POISONED and will be silently recovered"); - poisoned.into_inner() - }, - } - }; - ($e:expr) => { - acquire_lock!($e, lock) - }; - } - - #[derive(Clone, Debug)] - pub struct ResponseState { - balance: Arc>, - } - - impl ResponseState { - pub fn new() -> Self { - Self { - balance: Arc::new(Mutex::new(Balance::zero())), - } - } - - /// Set the mock server balance response - pub fn set_balance(&mut self, balance: Balance) { - let mut lock = acquire_lock!(self.balance); - *lock = balance; - } - - /// Get the mock server balance value - pub fn get_balance(&mut self) -> Balance { - let lock = acquire_lock!(self.balance); - (*lock).clone() - } - } - - pub struct MockOutputManagerService { - request_stream: Option>>, - state: ResponseState, - shutdown_signal: Option, - } - - impl MockOutputManagerService { - pub fn new( - request_stream: Receiver>, - shutdown_signal: ShutdownSignal, - ) -> Self { - Self { - request_stream: Some(request_stream), - state: ResponseState::new(), - shutdown_signal: Some(shutdown_signal), - } - } - - pub async fn run(mut self) -> Result<(), OutputManagerError> { - let shutdown_signal = self - .shutdown_signal - .take() - .expect("Output Manager Service initialized without shutdown signal"); - - let mut request_stream = self - .request_stream - .take() - .expect("Output Manager Service initialized without request_stream") - .take_until(shutdown_signal); - - while let Some(request_context) = request_stream.next().await { - // Incoming requests - let (request, reply_tx) = request_context.split(); - let response = self.handle_request(request); - let _ = reply_tx.send(response); - } - - Ok(()) - } - - fn handle_request( - &mut self, - request: OutputManagerRequest, - ) -> Result { - match request { - OutputManagerRequest::GetBalance => Ok(OutputManagerResponse::Balance(self.state.get_balance())), - _ => Err(OutputManagerError::InvalidResponseError(format!( - "Request '{}' not defined for MockOutputManagerService!", - request - ))), - } - } - - /// Returns a clone of the response state to enable updating after the service started - pub fn get_response_state(&mut self) -> ResponseState { - self.state.clone() - } - } - - struct CallbackState { - pub received_tx_callback_called: bool, - pub received_tx_reply_callback_called: bool, - pub received_finalized_tx_callback_called: bool, - pub broadcast_tx_callback_called: bool, - pub mined_tx_callback_called: bool, - pub mined_tx_unconfirmed_callback_called: u64, - pub direct_send_callback_called: bool, - pub store_and_forward_send_callback_called: bool, - pub tx_cancellation_callback_called_completed: bool, - pub tx_cancellation_callback_called_inbound: bool, - pub tx_cancellation_callback_called_outbound: bool, - pub callback_txo_validation_complete: u32, - pub callback_balance_updated: u32, - pub callback_transaction_validation_complete: u32, - pub saf_messages_received: bool, - } - - impl CallbackState { - fn new() -> Self { - Self { - received_tx_callback_called: false, - received_tx_reply_callback_called: false, - received_finalized_tx_callback_called: false, - broadcast_tx_callback_called: false, - mined_tx_callback_called: false, - mined_tx_unconfirmed_callback_called: 0, - direct_send_callback_called: false, - store_and_forward_send_callback_called: false, - callback_txo_validation_complete: 0, - callback_balance_updated: 0, - callback_transaction_validation_complete: 0, - tx_cancellation_callback_called_completed: false, - tx_cancellation_callback_called_inbound: false, - tx_cancellation_callback_called_outbound: false, - saf_messages_received: false, - } - } - } - - lazy_static! { - static ref CALLBACK_STATE: Mutex = Mutex::new(CallbackState::new()); - } - - unsafe extern "C" fn received_tx_callback(tx: *mut InboundTransaction) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.received_tx_callback_called = true; - drop(lock); - Box::from_raw(tx); - } - - unsafe extern "C" fn received_tx_reply_callback(tx: *mut CompletedTransaction) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.received_tx_reply_callback_called = true; - drop(lock); - Box::from_raw(tx); - } - - unsafe extern "C" fn received_tx_finalized_callback(tx: *mut CompletedTransaction) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.received_finalized_tx_callback_called = true; - drop(lock); - Box::from_raw(tx); - } - - unsafe extern "C" fn broadcast_callback(tx: *mut CompletedTransaction) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.broadcast_tx_callback_called = true; - drop(lock); - Box::from_raw(tx); - } - - unsafe extern "C" fn mined_callback(tx: *mut CompletedTransaction) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.mined_tx_callback_called = true; - drop(lock); - Box::from_raw(tx); - } - - unsafe extern "C" fn mined_unconfirmed_callback(tx: *mut CompletedTransaction, confirmations: u64) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.mined_tx_unconfirmed_callback_called = confirmations; - drop(lock); - Box::from_raw(tx); - } - - unsafe extern "C" fn direct_send_callback(_tx_id: u64, _result: bool) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.direct_send_callback_called = true; - drop(lock); - } - - unsafe extern "C" fn store_and_forward_send_callback(_tx_id: u64, _result: bool) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.store_and_forward_send_callback_called = true; - drop(lock); - } - - unsafe extern "C" fn saf_messages_received_callback() { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.saf_messages_received = true; - drop(lock); - } - - unsafe extern "C" fn tx_cancellation_callback(tx: *mut CompletedTransaction) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - match (*tx).tx_id { - 3 => lock.tx_cancellation_callback_called_inbound = true, - 4 => lock.tx_cancellation_callback_called_completed = true, - 5 => lock.tx_cancellation_callback_called_outbound = true, - _ => (), - } - drop(lock); - Box::from_raw(tx); - } - - unsafe extern "C" fn txo_validation_complete_callback(_tx_id: u64, result: u8) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.callback_txo_validation_complete += result as u32; - drop(lock); - } - - unsafe extern "C" fn balance_updated_callback(balance: *mut Balance) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.callback_balance_updated += 1; - drop(lock); - Box::from_raw(balance); - } - - unsafe extern "C" fn transaction_validation_complete_callback(_tx_id: u64, result: u8) { - let mut lock = CALLBACK_STATE.lock().unwrap(); - lock.callback_transaction_validation_complete += result as u32; - drop(lock); - } - - #[test] - fn test_callback_handler() { - let runtime = Runtime::new().unwrap(); - - let (connection, _tempdir) = make_wallet_database_connection(None); - let db = TransactionDatabase::new(TransactionServiceSqliteDatabase::new(connection, None)); - - let rtp = ReceiverTransactionProtocol::new_placeholder(); - let inbound_tx = InboundTransaction::new( - 1u64, - PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)), - 22 * uT, - rtp, - TransactionStatus::Pending, - "1".to_string(), - Utc::now().naive_utc(), - ); - let completed_tx = CompletedTransaction::new( - 2u64, - PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)), - PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)), - MicroTari::from(100), - MicroTari::from(2000), - Transaction::new( - Vec::new(), - Vec::new(), - Vec::new(), - BlindingFactor::default(), - BlindingFactor::default(), - ), - TransactionStatus::Completed, - "2".to_string(), - Utc::now().naive_utc(), - TransactionDirection::Inbound, - None, - ); - let stp = SenderTransactionProtocol::new_placeholder(); - let outbound_tx = OutboundTransaction::new( - 3u64, - PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)), - 22 * uT, - 23 * uT, - stp, - TransactionStatus::Pending, - "3".to_string(), - Utc::now().naive_utc(), - false, - ); - let inbound_tx_cancelled = InboundTransaction { - tx_id: 4u64, - ..inbound_tx.clone() - }; - let completed_tx_cancelled = CompletedTransaction { - tx_id: 5u64, - ..completed_tx.clone() - }; - - runtime - .block_on(db.add_pending_inbound_transaction(1u64, inbound_tx.clone())) - .unwrap(); - runtime - .block_on(db.insert_completed_transaction(2u64, completed_tx.clone())) - .unwrap(); - runtime - .block_on(db.add_pending_inbound_transaction(4u64, inbound_tx_cancelled)) - .unwrap(); - runtime.block_on(db.cancel_pending_transaction(4u64)).unwrap(); - runtime - .block_on(db.insert_completed_transaction(5u64, completed_tx_cancelled.clone())) - .unwrap(); - runtime.block_on(db.cancel_completed_transaction(5u64)).unwrap(); - runtime - .block_on(db.add_pending_outbound_transaction(3u64, outbound_tx.clone())) - .unwrap(); - runtime.block_on(db.cancel_pending_transaction(3u64)).unwrap(); - - let (transaction_event_sender, transaction_event_receiver) = broadcast::channel(20); - let (oms_event_sender, oms_event_receiver) = broadcast::channel(20); - let (dht_event_sender, dht_event_receiver) = broadcast::channel(20); - - let (oms_request_sender, oms_request_receiver) = reply_channel::unbounded(); - let mut oms_handle = OutputManagerHandle::new(oms_request_sender, oms_event_sender.clone()); - - let shutdown_signal = Shutdown::new(); - let mut mock_output_manager_service = - MockOutputManagerService::new(oms_request_receiver, shutdown_signal.to_signal()); - let mut balance = Balance { - available_balance: completed_tx.amount + - completed_tx.fee + - completed_tx_cancelled.amount + - completed_tx_cancelled.fee, - time_locked_balance: None, - pending_incoming_balance: inbound_tx.amount, - pending_outgoing_balance: outbound_tx.amount + outbound_tx.fee, - }; - let mut mock_output_manager_service_state = mock_output_manager_service.get_response_state(); - mock_output_manager_service_state.set_balance(balance.clone()); - runtime.spawn(mock_output_manager_service.run()); - assert_eq!(balance, runtime.block_on(oms_handle.get_balance()).unwrap()); - - let callback_handler = CallbackHandler::new( - db, - transaction_event_receiver, - oms_event_receiver, - oms_handle, - dht_event_receiver, - shutdown_signal.to_signal(), - PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)), - received_tx_callback, - received_tx_reply_callback, - received_tx_finalized_callback, - broadcast_callback, - mined_callback, - mined_unconfirmed_callback, - direct_send_callback, - store_and_forward_send_callback, - tx_cancellation_callback, - txo_validation_complete_callback, - balance_updated_callback, - transaction_validation_complete_callback, - saf_messages_received_callback, - ); - - runtime.spawn(callback_handler.start()); - let mut callback_balance_updated = 0; - - // The balance updated callback is bundled with other callbacks and will only fire if the balance actually - // changed from an initial zero balance. - // Balance updated should be detected with following event, total = 1 times - transaction_event_sender - .send(Arc::new(TransactionEvent::ReceivedTransaction(1u64))) - .unwrap(); - let start = Instant::now(); - while start.elapsed().as_secs() < 10 { - { - let lock = CALLBACK_STATE.lock().unwrap(); - if lock.callback_balance_updated == 1 { - callback_balance_updated = 1; - break; - } - } - thread::sleep(Duration::from_millis(100)); - } - assert_eq!(callback_balance_updated, 1); - - balance.time_locked_balance = Some(completed_tx_cancelled.amount); - mock_output_manager_service_state.set_balance(balance.clone()); - // Balance updated should be detected with following event, total = 2 times - transaction_event_sender - .send(Arc::new(TransactionEvent::ReceivedTransactionReply(2u64))) - .unwrap(); - let start = Instant::now(); - while start.elapsed().as_secs() < 10 { - { - let lock = CALLBACK_STATE.lock().unwrap(); - if lock.callback_balance_updated == 2 { - callback_balance_updated = 2; - break; - } - } - thread::sleep(Duration::from_millis(100)); - } - assert_eq!(callback_balance_updated, 2); - - balance.pending_incoming_balance += inbound_tx.amount; - mock_output_manager_service_state.set_balance(balance.clone()); - // Balance updated should be detected with following event, total = 3 times - transaction_event_sender - .send(Arc::new(TransactionEvent::ReceivedFinalizedTransaction(2u64))) - .unwrap(); - let start = Instant::now(); - while start.elapsed().as_secs() < 10 { - { - let lock = CALLBACK_STATE.lock().unwrap(); - if lock.callback_balance_updated == 3 { - callback_balance_updated = 3; - break; - } - } - thread::sleep(Duration::from_millis(100)); - } - assert_eq!(callback_balance_updated, 3); - - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionBroadcast(2u64))) - .unwrap(); - - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionMined { - tx_id: 2u64, - is_valid: true, - })) - .unwrap(); - - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionMinedUnconfirmed { - tx_id: 2u64, - num_confirmations: 22u64, - is_valid: true, - })) - .unwrap(); - - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionDirectSendResult(2u64, true))) - .unwrap(); - - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionStoreForwardSendResult( - 2u64, true, - ))) - .unwrap(); - - balance.pending_outgoing_balance += outbound_tx.amount; - mock_output_manager_service_state.set_balance(balance.clone()); - // Balance updated should be detected with following event, total = 4 times - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionCancelled(3u64))) - .unwrap(); - let start = Instant::now(); - while start.elapsed().as_secs() < 10 { - { - let lock = CALLBACK_STATE.lock().unwrap(); - if lock.callback_balance_updated == 4 { - callback_balance_updated = 4; - break; - } - } - thread::sleep(Duration::from_millis(100)); - } - assert_eq!(callback_balance_updated, 4); - - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionCancelled(4u64))) - .unwrap(); - - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionCancelled(5u64))) - .unwrap(); - - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationSuccess(1u64))) - .unwrap(); - - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationSuccess(1u64))) - .unwrap(); - - balance.available_balance -= completed_tx_cancelled.amount; - mock_output_manager_service_state.set_balance(balance); - // Balance updated should be detected with following event, total = 5 times - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationSuccess(1u64))) - .unwrap(); - let start = Instant::now(); - while start.elapsed().as_secs() < 10 { - { - let lock = CALLBACK_STATE.lock().unwrap(); - if lock.callback_balance_updated == 5 { - callback_balance_updated = 5; - break; - } - } - thread::sleep(Duration::from_millis(100)); - } - assert_eq!(callback_balance_updated, 5); - - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionValidationSuccess(1u64))) - .unwrap(); - - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationFailure(1u64))) - .unwrap(); - - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationFailure(1u64))) - .unwrap(); - - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationFailure(1u64))) - .unwrap(); - - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionValidationFailure(1u64))) - .unwrap(); - - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationAborted(1u64))) - .unwrap(); - - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationAborted(1u64))) - .unwrap(); - - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationAborted(1u64))) - .unwrap(); - - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionValidationAborted(1u64))) - .unwrap(); - - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationDelayed(1u64))) - .unwrap(); - - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationDelayed(1u64))) - .unwrap(); - - oms_event_sender - .send(Arc::new(OutputManagerEvent::TxoValidationDelayed(1u64))) - .unwrap(); - - transaction_event_sender - .send(Arc::new(TransactionEvent::TransactionValidationDelayed(1u64))) - .unwrap(); - - dht_event_sender - .send(Arc::new(DhtEvent::StoreAndForwardMessagesReceived)) - .unwrap(); - - thread::sleep(Duration::from_secs(10)); - - let lock = CALLBACK_STATE.lock().unwrap(); - assert!(lock.received_tx_callback_called); - assert!(lock.received_tx_reply_callback_called); - assert!(lock.received_finalized_tx_callback_called); - assert!(lock.broadcast_tx_callback_called); - assert!(lock.mined_tx_callback_called); - assert_eq!(lock.mined_tx_unconfirmed_callback_called, 22u64); - assert!(lock.direct_send_callback_called); - assert!(lock.store_and_forward_send_callback_called); - assert!(lock.tx_cancellation_callback_called_inbound); - assert!(lock.tx_cancellation_callback_called_completed); - assert!(lock.tx_cancellation_callback_called_outbound); - assert!(lock.saf_messages_received); - assert_eq!(lock.callback_txo_validation_complete, 18); - assert_eq!(lock.callback_balance_updated, 5); - assert_eq!(lock.callback_transaction_validation_complete, 6); - - drop(lock); - } -} diff --git a/base_layer/wallet_ffi/tests/handler/callbacks.rs b/base_layer/wallet_ffi/tests/callbacks.rs similarity index 99% rename from base_layer/wallet_ffi/tests/handler/callbacks.rs rename to base_layer/wallet_ffi/tests/callbacks.rs index 541414ffda8..867b568c1cb 100644 --- a/base_layer/wallet_ffi/tests/handler/callbacks.rs +++ b/base_layer/wallet_ffi/tests/callbacks.rs @@ -20,10 +20,10 @@ // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -use crate::support::mock_output_manager_service::MockOutputManagerService; -use tari_wallet_ffi::callback_handler::CallbackHandler; +mod mock_output_manager_service; use chrono::Utc; +use mock_output_manager_service::MockOutputManagerService; use rand::rngs::OsRng; use std::{ sync::{Arc, Mutex}, @@ -59,8 +59,12 @@ use tari_wallet::{ }, }, }; +use tari_wallet_ffi::callback_handler::CallbackHandler; use tokio::{runtime::Runtime, sync::broadcast}; +#[macro_use] +extern crate lazy_static; + struct CallbackState { pub received_tx_callback_called: bool, pub received_tx_reply_callback_called: bool, diff --git a/base_layer/wallet_ffi/tests/handler/mod.rs b/base_layer/wallet_ffi/tests/handler/mod.rs deleted file mode 100644 index 563b0f516b2..00000000000 --- a/base_layer/wallet_ffi/tests/handler/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019. The Tari Project -// -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the -// following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following -// disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the -// following disclaimer in the documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote -// products derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#[macro_use] -pub mod callbacks; diff --git a/base_layer/wallet_ffi/tests/support/mock_output_manager_service.rs b/base_layer/wallet_ffi/tests/mock_output_manager_service.rs similarity index 98% rename from base_layer/wallet_ffi/tests/support/mock_output_manager_service.rs rename to base_layer/wallet_ffi/tests/mock_output_manager_service.rs index 36d8429672c..946ee59097c 100644 --- a/base_layer/wallet_ffi/tests/support/mock_output_manager_service.rs +++ b/base_layer/wallet_ffi/tests/mock_output_manager_service.rs @@ -72,6 +72,12 @@ impl ResponseState { } } +impl Default for ResponseState { + fn default() -> Self { + Self::new() + } +} + pub struct MockOutputManagerService { request_stream: Option>>, state: ResponseState, diff --git a/base_layer/wallet_ffi/tests/mod.rs b/base_layer/wallet_ffi/tests/mod.rs deleted file mode 100644 index 600584931ee..00000000000 --- a/base_layer/wallet_ffi/tests/mod.rs +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright 2019. The Tari Project -// -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the -// following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following -// disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the -// following disclaimer in the documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote -// products derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -pub mod handler; -pub mod support; - -#[macro_use] -extern crate lazy_static; diff --git a/base_layer/wallet_ffi/tests/support/mod.rs b/base_layer/wallet_ffi/tests/support/mod.rs deleted file mode 100644 index e5490216c9d..00000000000 --- a/base_layer/wallet_ffi/tests/support/mod.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2019. The Tari Project -// -// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the -// following conditions are met: -// -// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following -// disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the -// following disclaimer in the documentation and/or other materials provided with the distribution. -// -// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote -// products derived from this software without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, -// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR -// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE -// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -#[macro_use] -pub mod mock_output_manager_service;