From 4b10aeaaa7c6253a57b71ca7655a7f34b168a284 Mon Sep 17 00:00:00 2001 From: Hansie Odendaal Date: Fri, 10 Nov 2023 17:56:09 +0200 Subject: [PATCH] wip --- base_layer/core/benches/mempool.rs | 2 +- .../tests/blockchain_database.rs | 4 +- base_layer/core/src/covenants/covenant.rs | 3 +- base_layer/core/src/covenants/fields.rs | 8 +-- .../src/covenants/filters/absolute_height.rs | 2 +- base_layer/core/src/covenants/filters/and.rs | 2 +- .../core/src/covenants/filters/field_eq.rs | 3 +- .../src/covenants/filters/fields_hashed_eq.rs | 2 +- .../src/covenants/filters/fields_preserved.rs | 3 +- .../core/src/covenants/filters/identity.rs | 2 +- base_layer/core/src/covenants/filters/not.rs | 2 +- base_layer/core/src/covenants/filters/or.rs | 2 +- .../src/covenants/filters/output_hash_eq.rs | 2 +- base_layer/core/src/covenants/filters/xor.rs | 2 +- .../priority/prioritized_transaction.rs | 3 +- .../core/src/mempool/sync_protocol/test.rs | 3 +- .../unconfirmed_pool/unconfirmed_pool.rs | 3 +- .../core/src/test_helpers/blockchain.rs | 2 +- .../core/src/transactions/coinbase_builder.rs | 2 +- .../key_manager/memory_db_key_manager.rs | 69 +++++++++++++++++++ .../core/src/transactions/test_helpers.rs | 41 ++--------- .../transaction_components/test.rs | 3 +- .../transaction_output.rs | 3 +- .../wallet_output_builder.rs | 2 +- .../transaction_protocol/recipient.rs | 3 +- .../transaction_protocol/sender.rs | 2 +- .../transaction_protocol/single_receiver.rs | 3 +- .../transaction_initializer.rs | 2 +- .../aggregate_body_internal_validator.rs | 2 +- base_layer/core/src/validation/helpers.rs | 2 +- base_layer/core/src/validation/test.rs | 3 +- .../core/tests/helpers/sample_blockchains.rs | 2 +- base_layer/core/tests/helpers/sync.rs | 2 +- base_layer/core/tests/tests/base_node_rpc.rs | 3 +- .../core/tests/tests/block_validation.rs | 2 +- base_layer/core/tests/tests/mempool.rs | 2 +- .../core/tests/tests/node_comms_interface.rs | 2 +- base_layer/core/tests/tests/node_service.rs | 3 +- .../core/tests/tests/node_state_machine.rs | 2 +- .../storage/sqlite_db/mod.rs | 2 +- .../transaction_service/storage/sqlite_db.rs | 4 +- .../output_manager_service_tests/service.rs | 3 +- .../output_manager_service_tests/storage.rs | 2 +- .../transaction_service_tests/service.rs | 3 +- .../transaction_service_tests/storage.rs | 3 +- .../transaction_protocols.rs | 3 +- base_layer/wallet/tests/utxo_scanner/mod.rs | 2 +- base_layer/wallet_ffi/src/lib.rs | 2 +- integration_tests/src/world.rs | 2 +- 49 files changed, 138 insertions(+), 93 deletions(-) diff --git a/base_layer/core/benches/mempool.rs b/base_layer/core/benches/mempool.rs index 476cccfb8f1..d2cea09a056 100644 --- a/base_layer/core/benches/mempool.rs +++ b/base_layer/core/benches/mempool.rs @@ -39,7 +39,6 @@ mod benches { test_helpers::blockchain::create_new_blockchain, transactions::{ tari_amount::{uT, T}, - test_helpers::create_memory_db_key_manager, transaction_components::{OutputFeatures, Transaction, MAX_TRANSACTION_OUTPUTS}, CryptoFactories, }, @@ -47,6 +46,7 @@ mod benches { validation::transaction::TransactionFullValidator, }; use tokio::runtime::Runtime; + use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; async fn generate_transactions( num_txs: usize, diff --git a/base_layer/core/src/chain_storage/tests/blockchain_database.rs b/base_layer/core/src/chain_storage/tests/blockchain_database.rs index 519f34b83f2..3f93cb8d0a7 100644 --- a/base_layer/core/src/chain_storage/tests/blockchain_database.rs +++ b/base_layer/core/src/chain_storage/tests/blockchain_database.rs @@ -33,7 +33,7 @@ use crate::{ }, transactions::{ tari_amount::T, - test_helpers::{create_memory_db_key_manager, schema_to_transaction, MemoryDbKeyManager}, + test_helpers::{schema_to_transaction, MemoryDbKeyManager}, transaction_components::{Transaction, WalletOutput}, }, txn_schema, @@ -96,7 +96,7 @@ async fn add_many_chained_blocks( } mod fetch_blocks { - + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; use super::*; #[test] diff --git a/base_layer/core/src/covenants/covenant.rs b/base_layer/core/src/covenants/covenant.rs index e5b2319e345..5eb9373912f 100644 --- a/base_layer/core/src/covenants/covenant.rs +++ b/base_layer/core/src/covenants/covenant.rs @@ -189,8 +189,9 @@ mod test { test::{create_input, create_outputs}, Covenant, }, - transactions::test_helpers::{create_memory_db_key_manager, UtxoTestParams}, + transactions::test_helpers::{UtxoTestParams}, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_succeeds_when_empty() { diff --git a/base_layer/core/src/covenants/fields.rs b/base_layer/core/src/covenants/fields.rs index bec4635fecd..f807d8584eb 100644 --- a/base_layer/core/src/covenants/fields.rs +++ b/base_layer/core/src/covenants/fields.rs @@ -394,9 +394,9 @@ mod test { use super::*; use crate::transactions::{ tari_amount::MicroMinotari, - test_helpers::create_memory_db_key_manager, transaction_components::RangeProofType, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_returns_true_if_eq() { @@ -490,7 +490,7 @@ mod test { mod is_eq_input { use super::*; - use crate::transactions::test_helpers::create_memory_db_key_manager; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_returns_true_if_eq_input() { @@ -561,6 +561,7 @@ mod test { mod output_fields { use super::*; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; mod construct_challenge_from { use blake2::Digest; @@ -570,7 +571,6 @@ mod test { use super::*; use crate::transactions::{ tari_amount::MicroMinotari, - test_helpers::create_memory_db_key_manager, transaction_components::RangeProofType, }; @@ -622,9 +622,9 @@ mod test { use super::*; use crate::transactions::{ tari_amount::MicroMinotari, - test_helpers::create_memory_db_key_manager, transaction_components::RangeProofType, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_retrieves_the_value_as_ref() { diff --git a/base_layer/core/src/covenants/filters/absolute_height.rs b/base_layer/core/src/covenants/filters/absolute_height.rs index 576eb53b724..1892aeb7045 100644 --- a/base_layer/core/src/covenants/filters/absolute_height.rs +++ b/base_layer/core/src/covenants/filters/absolute_height.rs @@ -67,8 +67,8 @@ mod test { use crate::{ covenant, covenants::{filters::test::setup_filter_test, test::create_input}, - transactions::test_helpers::create_memory_db_key_manager, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_filters_all_out_if_height_not_reached() { diff --git a/base_layer/core/src/covenants/filters/and.rs b/base_layer/core/src/covenants/filters/and.rs index ad5a17fea18..219ac433bfe 100644 --- a/base_layer/core/src/covenants/filters/and.rs +++ b/base_layer/core/src/covenants/filters/and.rs @@ -48,8 +48,8 @@ mod test { use crate::{ covenant, covenants::{filters::test::setup_filter_test, test::create_input}, - transactions::test_helpers::create_memory_db_key_manager, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_filters_outputset_using_intersection() { diff --git a/base_layer/core/src/covenants/filters/field_eq.rs b/base_layer/core/src/covenants/filters/field_eq.rs index 9c6deba212a..2fd32df3050 100644 --- a/base_layer/core/src/covenants/filters/field_eq.rs +++ b/base_layer/core/src/covenants/filters/field_eq.rs @@ -85,8 +85,9 @@ mod test { use crate::{ covenant, covenants::test::{create_context, create_input, create_outputs}, - transactions::{test_helpers::create_memory_db_key_manager, transaction_components::OutputType}, + transactions::{transaction_components::OutputType}, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_filters_uint() { diff --git a/base_layer/core/src/covenants/filters/fields_hashed_eq.rs b/base_layer/core/src/covenants/filters/fields_hashed_eq.rs index 45ceaea82d0..19007f33053 100644 --- a/base_layer/core/src/covenants/filters/fields_hashed_eq.rs +++ b/base_layer/core/src/covenants/filters/fields_hashed_eq.rs @@ -59,10 +59,10 @@ mod test { COVENANTS_FIELD_HASHER_LABEL, }, transactions::{ - test_helpers::create_memory_db_key_manager, transaction_components::OutputFeatures, }, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_filters_outputs_with_fields_that_hash_to_given_hash() { diff --git a/base_layer/core/src/covenants/filters/fields_preserved.rs b/base_layer/core/src/covenants/filters/fields_preserved.rs index 9f5134dc4d9..4a4696679ea 100644 --- a/base_layer/core/src/covenants/filters/fields_preserved.rs +++ b/base_layer/core/src/covenants/filters/fields_preserved.rs @@ -44,8 +44,9 @@ mod test { use crate::{ covenant, covenants::{filters::test::setup_filter_test, test::create_input}, - transactions::{test_helpers::create_memory_db_key_manager, transaction_components::OutputType}, + transactions::{transaction_components::OutputType}, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_filters_outputs_that_match_input_fields() { diff --git a/base_layer/core/src/covenants/filters/identity.rs b/base_layer/core/src/covenants/filters/identity.rs index 928f1397953..0a3e4d4474b 100644 --- a/base_layer/core/src/covenants/filters/identity.rs +++ b/base_layer/core/src/covenants/filters/identity.rs @@ -39,8 +39,8 @@ mod tests { use crate::{ covenant, covenants::{filters::test::setup_filter_test, test::create_input}, - transactions::test_helpers::create_memory_db_key_manager, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_returns_the_outputset_unchanged() { diff --git a/base_layer/core/src/covenants/filters/not.rs b/base_layer/core/src/covenants/filters/not.rs index 1ffcd1ffd49..ae6b05a1b15 100644 --- a/base_layer/core/src/covenants/filters/not.rs +++ b/base_layer/core/src/covenants/filters/not.rs @@ -45,8 +45,8 @@ mod test { use crate::{ covenant, covenants::{filters::test::setup_filter_test, test::create_input}, - transactions::test_helpers::create_memory_db_key_manager, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_filters_compliment_of_filter() { diff --git a/base_layer/core/src/covenants/filters/or.rs b/base_layer/core/src/covenants/filters/or.rs index 96659086233..caad0d353eb 100644 --- a/base_layer/core/src/covenants/filters/or.rs +++ b/base_layer/core/src/covenants/filters/or.rs @@ -51,8 +51,8 @@ mod test { use crate::{ covenant, covenants::{filters::test::setup_filter_test, test::create_input}, - transactions::test_helpers::create_memory_db_key_manager, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_filters_outputset_using_union() { diff --git a/base_layer/core/src/covenants/filters/output_hash_eq.rs b/base_layer/core/src/covenants/filters/output_hash_eq.rs index 17abd676b3e..f71db451d0e 100644 --- a/base_layer/core/src/covenants/filters/output_hash_eq.rs +++ b/base_layer/core/src/covenants/filters/output_hash_eq.rs @@ -47,8 +47,8 @@ mod test { filters::test::setup_filter_test, test::{create_input, create_outputs}, }, - transactions::test_helpers::create_memory_db_key_manager, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_filters_output_with_specific_hash() { diff --git a/base_layer/core/src/covenants/filters/xor.rs b/base_layer/core/src/covenants/filters/xor.rs index 9250b8bae5e..75311d3d683 100644 --- a/base_layer/core/src/covenants/filters/xor.rs +++ b/base_layer/core/src/covenants/filters/xor.rs @@ -53,8 +53,8 @@ mod test { use crate::{ covenant, covenants::{filters::test::setup_filter_test, test::create_input}, - transactions::test_helpers::create_memory_db_key_manager, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_filters_outputset_using_symmetric_difference() { diff --git a/base_layer/core/src/mempool/priority/prioritized_transaction.rs b/base_layer/core/src/mempool/priority/prioritized_transaction.rs index 12f7c3c7b51..ac454357a51 100644 --- a/base_layer/core/src/mempool/priority/prioritized_transaction.rs +++ b/base_layer/core/src/mempool/priority/prioritized_transaction.rs @@ -119,8 +119,9 @@ mod tests { use super::*; use crate::transactions::{ tari_amount::{uT, MicroMinotari, T}, - test_helpers::{create_memory_db_key_manager, create_tx, MemoryDbKeyManager}, }; + use crate::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}; + use crate::transactions::test_helpers::create_tx; async fn create_tx_with_fee(fee_per_gram: MicroMinotari, key_manager: &MemoryDbKeyManager) -> Transaction { let (tx, _, _) = create_tx(10 * T, fee_per_gram, 0, 1, 0, 1, Default::default(), key_manager) diff --git a/base_layer/core/src/mempool/sync_protocol/test.rs b/base_layer/core/src/mempool/sync_protocol/test.rs index 6eaf1d819cc..d525b60ecf9 100644 --- a/base_layer/core/src/mempool/sync_protocol/test.rs +++ b/base_layer/core/src/mempool/sync_protocol/test.rs @@ -53,11 +53,12 @@ use crate::{ }, transactions::{ tari_amount::uT, - test_helpers::{create_memory_db_key_manager, create_tx}, + test_helpers::{create_tx}, transaction_components::Transaction, }, validation::mocks::MockValidator, }; +use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; pub async fn create_transactions(n: usize) -> Vec { let key_manager = create_memory_db_key_manager(); diff --git a/base_layer/core/src/mempool/unconfirmed_pool/unconfirmed_pool.rs b/base_layer/core/src/mempool/unconfirmed_pool/unconfirmed_pool.rs index 8b1691d0e71..add90f437ae 100644 --- a/base_layer/core/src/mempool/unconfirmed_pool/unconfirmed_pool.rs +++ b/base_layer/core/src/mempool/unconfirmed_pool/unconfirmed_pool.rs @@ -884,12 +884,13 @@ mod test { aggregated_body::AggregateBody, fee::Fee, tari_amount::MicroMinotari, - test_helpers::{create_memory_db_key_manager, TestParams, UtxoTestParams}, + test_helpers::{TestParams, UtxoTestParams}, weight::TransactionWeight, SenderTransactionProtocol, }, tx, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn test_find_duplicate_input() { diff --git a/base_layer/core/src/test_helpers/blockchain.rs b/base_layer/core/src/test_helpers/blockchain.rs index d6224b9a325..2617f56e61a 100644 --- a/base_layer/core/src/test_helpers/blockchain.rs +++ b/base_layer/core/src/test_helpers/blockchain.rs @@ -64,7 +64,6 @@ use crate::{ proof_of_work::{AchievedTargetDifficulty, Difficulty, PowAlgorithm}, test_helpers::{block_spec::BlockSpecs, create_consensus_rules, BlockSpec}, transactions::{ - test_helpers::{create_memory_db_key_manager, MemoryDbKeyManager}, transaction_components::{TransactionInput, TransactionKernel, TransactionOutput, WalletOutput}, CryptoFactories, }, @@ -75,6 +74,7 @@ use crate::{ }, OutputSmt, }; +use crate::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}; /// Create a new blockchain database containing the genesis block pub fn create_new_blockchain() -> BlockchainDatabase { diff --git a/base_layer/core/src/transactions/coinbase_builder.rs b/base_layer/core/src/transactions/coinbase_builder.rs index 3b3e28a24ec..294c3f1b012 100644 --- a/base_layer/core/src/transactions/coinbase_builder.rs +++ b/base_layer/core/src/transactions/coinbase_builder.rs @@ -692,9 +692,9 @@ mod test { use crate::transactions::{ aggregated_body::AggregateBody, key_manager::{TransactionKeyManagerBranch, TransactionKeyManagerInterface, TxoStage}, - test_helpers::{create_memory_db_key_manager, MemoryDbKeyManager}, transaction_components::TransactionKernelVersion, }; + use crate::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}; #[tokio::test] #[allow(clippy::too_many_lines)] diff --git a/base_layer/core/src/transactions/key_manager/memory_db_key_manager.rs b/base_layer/core/src/transactions/key_manager/memory_db_key_manager.rs index e69de29bb2d..c9f81e3a5d2 100644 --- a/base_layer/core/src/transactions/key_manager/memory_db_key_manager.rs +++ b/base_layer/core/src/transactions/key_manager/memory_db_key_manager.rs @@ -0,0 +1,69 @@ +// Copyright 2023 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. + +use std::{iter, mem::size_of, sync::Arc}; + +use chacha20poly1305::{Key, KeyInit, XChaCha20Poly1305}; +use rand::{distributions::Alphanumeric, rngs::OsRng, Rng, RngCore}; +use tari_common::configuration::Network; +use tari_common_sqlite::connection::{DbConnection, DbConnectionUrl}; +use tari_common_types::types::{Commitment, PrivateKey, PublicKey, Signature}; +use tari_crypto::keys::{PublicKey as PK, SecretKey}; +use tari_key_manager::{ + cipher_seed::CipherSeed, + key_manager_service::{ + storage::{database::KeyManagerDatabase, sqlite_db::KeyManagerSqliteDatabase}, + KeyManagerInterface, + }, +}; +use crate::transactions::key_manager::TransactionKeyManagerWrapper; + +pub type MemoryDbKeyManager = TransactionKeyManagerWrapper>; + +fn random_string(len: usize) -> String { + iter::repeat(()) + .map(|_| OsRng.sample(Alphanumeric) as char) + .take(len) + .collect() +} + +pub fn create_memory_db_key_manager_with_range_proof_size(size: usize) -> MemoryDbKeyManager { + let connection = DbConnection::connect_url(&DbConnectionUrl::MemoryShared(random_string(8))).unwrap(); + let cipher = CipherSeed::new(); + + let mut key = [0u8; size_of::()]; + OsRng.fill_bytes(&mut key); + let key_ga = Key::from_slice(&key); + let db_cipher = XChaCha20Poly1305::new(key_ga); + let factory = CryptoFactories::new(size); + + TransactionKeyManagerWrapper::>::new( + cipher, + KeyManagerDatabase::new(KeyManagerSqliteDatabase::init(connection, db_cipher)), + factory, + ) + .unwrap() +} + +pub fn create_memory_db_key_manager() -> MemoryDbKeyManager { + create_memory_db_key_manager_with_range_proof_size(64) +} diff --git a/base_layer/core/src/transactions/test_helpers.rs b/base_layer/core/src/transactions/test_helpers.rs index a2cacdabae9..e22cf2e5047 100644 --- a/base_layer/core/src/transactions/test_helpers.rs +++ b/base_layer/core/src/transactions/test_helpers.rs @@ -20,18 +20,15 @@ // 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 std::{iter, mem::size_of, sync::Arc}; +use std::{sync::Arc}; -use chacha20poly1305::{Key, KeyInit, XChaCha20Poly1305}; -use rand::{distributions::Alphanumeric, rngs::OsRng, Rng, RngCore}; +use chacha20poly1305::{ KeyInit}; +use rand::{rngs::OsRng}; use tari_common::configuration::Network; -use tari_common_sqlite::connection::{DbConnection, DbConnectionUrl}; use tari_common_types::types::{Commitment, PrivateKey, PublicKey, Signature}; use tari_crypto::keys::{PublicKey as PK, SecretKey}; use tari_key_manager::{ - cipher_seed::CipherSeed, key_manager_service::{ - storage::{database::KeyManagerDatabase, sqlite_db::KeyManagerSqliteDatabase}, KeyManagerInterface, }, }; @@ -70,6 +67,7 @@ use crate::{ SenderTransactionProtocol, }, }; +use crate::transactions::key_manager::memory_db_key_manager::MemoryDbKeyManager; pub async fn create_test_input(amount: MicroMinotari, maturity: u64, key_manager: &MemoryDbKeyManager) -> WalletOutput { let params = TestParams::new(key_manager).await; @@ -890,34 +888,3 @@ pub async fn schema_to_transaction( (txs, utxos) } - -pub type MemoryDbKeyManager = TransactionKeyManagerWrapper>; - -fn random_string(len: usize) -> String { - iter::repeat(()) - .map(|_| OsRng.sample(Alphanumeric) as char) - .take(len) - .collect() -} - -pub fn create_memory_db_key_manager_with_range_proof_size(size: usize) -> MemoryDbKeyManager { - let connection = DbConnection::connect_url(&DbConnectionUrl::MemoryShared(random_string(8))).unwrap(); - let cipher = CipherSeed::new(); - - let mut key = [0u8; size_of::()]; - OsRng.fill_bytes(&mut key); - let key_ga = Key::from_slice(&key); - let db_cipher = XChaCha20Poly1305::new(key_ga); - let factory = CryptoFactories::new(size); - - TransactionKeyManagerWrapper::>::new( - cipher, - KeyManagerDatabase::new(KeyManagerSqliteDatabase::init(connection, db_cipher)), - factory, - ) - .unwrap() -} - -pub fn create_memory_db_key_manager() -> MemoryDbKeyManager { - create_memory_db_key_manager_with_range_proof_size(64) -} diff --git a/base_layer/core/src/transactions/transaction_components/test.rs b/base_layer/core/src/transactions/transaction_components/test.rs index a50f65c81cc..af0b29f7b0b 100644 --- a/base_layer/core/src/transactions/transaction_components/test.rs +++ b/base_layer/core/src/transactions/transaction_components/test.rs @@ -41,8 +41,6 @@ use crate::{ tari_amount::{uT, MicroMinotari, T}, test_helpers, test_helpers::{ - create_memory_db_key_manager, - create_memory_db_key_manager_with_range_proof_size, TestParams, UtxoTestParams, }, @@ -53,6 +51,7 @@ use crate::{ txn_schema, validation::{transaction::TransactionInternalConsistencyValidator, ValidationError}, }; +use crate::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, create_memory_db_key_manager_with_range_proof_size}; #[tokio::test] async fn input_and_output_and_wallet_output_hash_match() { diff --git a/base_layer/core/src/transactions/transaction_components/transaction_output.rs b/base_layer/core/src/transactions/transaction_components/transaction_output.rs index 1d5e9ec23d8..4d1702e47c4 100644 --- a/base_layer/core/src/transactions/transaction_components/transaction_output.rs +++ b/base_layer/core/src/transactions/transaction_components/transaction_output.rs @@ -591,10 +591,11 @@ mod test { use crate::transactions::{ key_manager::TransactionKeyManagerInterface, tari_amount::MicroMinotari, - test_helpers::{create_memory_db_key_manager, MemoryDbKeyManager, TestParams, UtxoTestParams}, + test_helpers::{TestParams, UtxoTestParams}, transaction_components::{OutputFeatures, RangeProofType}, CryptoFactories, }; + use crate::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}; #[tokio::test] async fn it_builds_correctly() { diff --git a/base_layer/core/src/transactions/transaction_components/wallet_output_builder.rs b/base_layer/core/src/transactions/transaction_components/wallet_output_builder.rs index d1b0b5e7fb8..51882717a2a 100644 --- a/base_layer/core/src/transactions/transaction_components/wallet_output_builder.rs +++ b/base_layer/core/src/transactions/transaction_components/wallet_output_builder.rs @@ -231,8 +231,8 @@ mod test { use super::*; use crate::transactions::{ key_manager::TransactionKeyManagerBranch, - test_helpers::create_memory_db_key_manager, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn test_try_build() { diff --git a/base_layer/core/src/transactions/transaction_protocol/recipient.rs b/base_layer/core/src/transactions/transaction_protocol/recipient.rs index 1cc2f623909..50dac1726bf 100644 --- a/base_layer/core/src/transactions/transaction_protocol/recipient.rs +++ b/base_layer/core/src/transactions/transaction_protocol/recipient.rs @@ -196,7 +196,7 @@ mod test { crypto_factories::CryptoFactories, key_manager::{TransactionKeyManagerBranch, TransactionKeyManagerInterface, TxoStage}, tari_amount::*, - test_helpers::{create_memory_db_key_manager, TestParams, UtxoTestParams}, + test_helpers::{TestParams, UtxoTestParams}, transaction_components::{ OutputFeatures, TransactionKernel, @@ -210,6 +210,7 @@ mod test { ReceiverTransactionProtocol, }, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn single_round_recipient() { diff --git a/base_layer/core/src/transactions/transaction_protocol/sender.rs b/base_layer/core/src/transactions/transaction_protocol/sender.rs index 92fe820e481..af2d6e37f10 100644 --- a/base_layer/core/src/transactions/transaction_protocol/sender.rs +++ b/base_layer/core/src/transactions/transaction_protocol/sender.rs @@ -882,7 +882,6 @@ mod test { key_manager::{TransactionKeyManagerBranch, TransactionKeyManagerInterface}, tari_amount::*, test_helpers::{ - create_memory_db_key_manager, create_test_input, create_wallet_output_with_data, TestParams, @@ -902,6 +901,7 @@ mod test { }, validation::transaction::TransactionInternalConsistencyValidator, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[test] fn test_not_single() { diff --git a/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs b/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs index 7da0228a7f6..89b2564e429 100644 --- a/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs +++ b/base_layer/core/src/transactions/transaction_protocol/single_receiver.rs @@ -151,7 +151,7 @@ mod test { transactions::{ key_manager::TransactionKeyManagerInterface, tari_amount::*, - test_helpers::{create_memory_db_key_manager, TestParams}, + test_helpers::{TestParams}, transaction_components::{ EncryptedData, OutputFeatures, @@ -169,6 +169,7 @@ mod test { }, }, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn zero_amount_fails() { diff --git a/base_layer/core/src/transactions/transaction_protocol/transaction_initializer.rs b/base_layer/core/src/transactions/transaction_protocol/transaction_initializer.rs index 17f00cb71ed..0b2347c4387 100644 --- a/base_layer/core/src/transactions/transaction_protocol/transaction_initializer.rs +++ b/base_layer/core/src/transactions/transaction_protocol/transaction_initializer.rs @@ -602,7 +602,6 @@ mod test { fee::Fee, tari_amount::*, test_helpers::{ - create_memory_db_key_manager, create_test_input, create_wallet_output_with_data, TestParams, @@ -612,6 +611,7 @@ mod test { transaction_protocol::{sender::SenderState, transaction_initializer::SenderTransactionInitializer}, }, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; /// One input, 2 outputs #[tokio::test] diff --git a/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs b/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs index b058e9b14f6..215186be3dd 100644 --- a/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs +++ b/base_layer/core/src/validation/aggregate_body/aggregate_body_internal_validator.rs @@ -434,10 +434,10 @@ mod test { covenants::Covenant, transactions::{ test_helpers, - test_helpers::create_memory_db_key_manager, transaction_components::{KernelFeatures, OutputFeatures, TransactionInputVersion}, }, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; mod check_lock_height { use super::*; diff --git a/base_layer/core/src/validation/helpers.rs b/base_layer/core/src/validation/helpers.rs index 1ebbab3be47..fc29a9d6759 100644 --- a/base_layer/core/src/validation/helpers.rs +++ b/base_layer/core/src/validation/helpers.rs @@ -534,9 +534,9 @@ mod test { use super::*; use crate::transactions::{ aggregated_body::AggregateBody, - test_helpers::create_memory_db_key_manager, transaction_components::TransactionError, }; + use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; #[tokio::test] async fn it_succeeds_for_valid_coinbase() { diff --git a/base_layer/core/src/validation/test.rs b/base_layer/core/src/validation/test.rs index 0ef3edfe0d3..6a7081733ae 100644 --- a/base_layer/core/src/validation/test.rs +++ b/base_layer/core/src/validation/test.rs @@ -40,7 +40,6 @@ use crate::{ tari_amount::{uT, MicroMinotari}, test_helpers::{ create_random_signature_from_secret_key, - create_memory_db_key_manager, create_utxo, }, transaction_components::{KernelBuilder, KernelFeatures, OutputFeatures, TransactionKernel}, @@ -49,6 +48,7 @@ use crate::{ tx, validation::{ChainBalanceValidator, DifficultyCalculator, FinalHorizonStateValidation, ValidationError}, }; +use crate::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; mod header_validators { use tari_utilities::epoch_time::EpochTime; @@ -513,7 +513,6 @@ mod transaction_validator { use super::*; use crate::{ transactions::{ - test_helpers::create_memory_db_key_manager, transaction_components::{OutputType, TransactionError}, }, validation::transaction::TransactionInternalConsistencyValidator, diff --git a/base_layer/core/tests/helpers/sample_blockchains.rs b/base_layer/core/tests/helpers/sample_blockchains.rs index 59a086dd38e..4d63c9829b8 100644 --- a/base_layer/core/tests/helpers/sample_blockchains.rs +++ b/base_layer/core/tests/helpers/sample_blockchains.rs @@ -29,12 +29,12 @@ use tari_core::{ test_helpers::blockchain::{create_store_with_consensus, TempDatabase}, transactions::{ tari_amount::{uT, T}, - test_helpers::{create_memory_db_key_manager, MemoryDbKeyManager}, transaction_components::WalletOutput, }, txn_schema, validation::DifficultyCalculator, }; +use tari_core::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}; use crate::helpers::block_builders::{create_genesis_block, generate_new_block}; diff --git a/base_layer/core/tests/helpers/sync.rs b/base_layer/core/tests/helpers/sync.rs index ee5ba611fa3..06b24936ab5 100644 --- a/base_layer/core/tests/helpers/sync.rs +++ b/base_layer/core/tests/helpers/sync.rs @@ -40,13 +40,13 @@ use tari_core::{ mempool::MempoolServiceConfig, proof_of_work::{randomx_factory::RandomXFactory, Difficulty}, test_helpers::blockchain::TempDatabase, - transactions::test_helpers::{create_memory_db_key_manager, MemoryDbKeyManager}, validation::mocks::MockValidator, }; use tari_p2p::{services::liveness::LivenessConfig, P2pConfig}; use tari_shutdown::Shutdown; use tempfile::tempdir; use tokio::sync::{broadcast, watch}; +use tari_core::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}; use crate::helpers::{ block_builders::{append_block, create_genesis_block}, diff --git a/base_layer/core/tests/tests/base_node_rpc.rs b/base_layer/core/tests/tests/base_node_rpc.rs index 89d4dcd0fba..c1301c3b891 100644 --- a/base_layer/core/tests/tests/base_node_rpc.rs +++ b/base_layer/core/tests/tests/base_node_rpc.rs @@ -49,7 +49,7 @@ use tari_core::{ test_helpers::blockchain::TempDatabase, transactions::{ tari_amount::{uT, T}, - test_helpers::{create_memory_db_key_manager, schema_to_transaction, MemoryDbKeyManager}, + test_helpers::{schema_to_transaction}, transaction_components::{TransactionOutput, WalletOutput}, }, txn_schema, @@ -59,6 +59,7 @@ use tari_test_utils::streams::convert_mpsc_to_stream; use tari_utilities::epoch_time::EpochTime; use tempfile::{tempdir, TempDir}; use tokio::sync::broadcast; +use tari_core::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}; use crate::{ helpers::{ diff --git a/base_layer/core/tests/tests/block_validation.rs b/base_layer/core/tests/tests/block_validation.rs index 4ca71373127..08202571468 100644 --- a/base_layer/core/tests/tests/block_validation.rs +++ b/base_layer/core/tests/tests/block_validation.rs @@ -49,7 +49,6 @@ use tari_core::{ key_manager::TransactionKeyManagerInterface, tari_amount::{uT, MicroMinotari, T}, test_helpers::{ - create_memory_db_key_manager, create_wallet_output_with_data, schema_to_transaction, spend_utxos, @@ -1187,6 +1186,7 @@ use tari_core::{ transaction_components::{Transaction, TransactionKernel}, }, }; +use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; use crate::helpers::{block_builders::generate_new_block, sample_blockchains::create_new_blockchain}; diff --git a/base_layer/core/tests/tests/mempool.rs b/base_layer/core/tests/tests/mempool.rs index 082ddd8f7c3..e43a7287e3c 100644 --- a/base_layer/core/tests/tests/mempool.rs +++ b/base_layer/core/tests/tests/mempool.rs @@ -37,7 +37,6 @@ use tari_core::{ key_manager::{TransactionKeyManagerBranch, TransactionKeyManagerInterface, TxoStage}, tari_amount::{uT, MicroMinotari, T}, test_helpers::{ - create_memory_db_key_manager, create_wallet_output_with_data, schema_to_transaction, spend_utxos, @@ -73,6 +72,7 @@ use tari_p2p::{services::liveness::LivenessConfig, tari_message::TariMessageType use tari_script::script; use tari_test_utils::async_assert_eventually; use tempfile::tempdir; +use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; use crate::helpers::{ block_builders::{ diff --git a/base_layer/core/tests/tests/node_comms_interface.rs b/base_layer/core/tests/tests/node_comms_interface.rs index 4f683500c00..c7721ecbdd5 100644 --- a/base_layer/core/tests/tests/node_comms_interface.rs +++ b/base_layer/core/tests/tests/node_comms_interface.rs @@ -42,7 +42,6 @@ use tari_core::{ key_manager::{TransactionKeyManagerBranch, TransactionKeyManagerInterface}, tari_amount::MicroMinotari, test_helpers::{ - create_memory_db_key_manager, create_utxo, MemoryDbKeyManager, TestParams, @@ -65,6 +64,7 @@ use tari_key_manager::key_manager_service::KeyManagerInterface; use tari_script::{inputs, script, ExecutionStack}; use tari_service_framework::reply_channel; use tokio::sync::{broadcast, mpsc}; +use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; use crate::helpers::block_builders::append_block; diff --git a/base_layer/core/tests/tests/node_service.rs b/base_layer/core/tests/tests/node_service.rs index c5788ee092d..c76f9b32c98 100644 --- a/base_layer/core/tests/tests/node_service.rs +++ b/base_layer/core/tests/tests/node_service.rs @@ -36,7 +36,7 @@ use tari_core::{ proof_of_work::{randomx_factory::RandomXFactory, Difficulty, PowAlgorithm}, transactions::{ tari_amount::{uT, T}, - test_helpers::{create_memory_db_key_manager, schema_to_transaction, spend_utxos}, + test_helpers::{ schema_to_transaction, spend_utxos}, transaction_components::OutputFeatures, CryptoFactories, }, @@ -50,6 +50,7 @@ use tari_core::{ }; use tari_test_utils::unpack_enum; use tempfile::tempdir; +use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; use crate::{ helpers::{ diff --git a/base_layer/core/tests/tests/node_state_machine.rs b/base_layer/core/tests/tests/node_state_machine.rs index 80584348848..f565fbf2706 100644 --- a/base_layer/core/tests/tests/node_state_machine.rs +++ b/base_layer/core/tests/tests/node_state_machine.rs @@ -40,7 +40,6 @@ use tari_core::{ mempool::MempoolServiceConfig, proof_of_work::{randomx_factory::RandomXFactory, Difficulty}, test_helpers::blockchain::create_test_blockchain_db, - transactions::test_helpers::create_memory_db_key_manager, validation::mocks::MockValidator, }; use tari_p2p::{services::liveness::config::LivenessConfig, P2pConfig}; @@ -53,6 +52,7 @@ use tokio::{ task, time, }; +use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; use crate::helpers::{ block_builders::{append_block, chain_block, create_genesis_block}, diff --git a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs index ce7ca1996ff..d7d5b008f42 100644 --- a/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs +++ b/base_layer/wallet/src/output_manager_service/storage/sqlite_db/mod.rs @@ -1309,7 +1309,6 @@ mod test { use tari_core::transactions::{ tari_amount::MicroMinotari, test_helpers::{ - create_memory_db_key_manager, create_wallet_output_with_data, MemoryDbKeyManager, TestParams, @@ -1319,6 +1318,7 @@ mod test { use tari_script::script; use tari_test_utils::random; use tempfile::tempdir; + use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; use crate::output_manager_service::storage::{ models::DbWalletOutput, diff --git a/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs b/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs index 3c4bd96b7a5..01986df6692 100644 --- a/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs +++ b/base_layer/wallet/src/transaction_service/storage/sqlite_db.rs @@ -2257,7 +2257,7 @@ mod test { }; use tari_core::transactions::{ tari_amount::MicroMinotari, - test_helpers::{create_memory_db_key_manager, create_wallet_output_with_data, TestParams}, + test_helpers::{ create_wallet_output_with_data, TestParams}, transaction_components::{OutputFeatures, Transaction}, transaction_protocol::sender::TransactionSenderMessage, ReceiverTransactionProtocol, @@ -2267,7 +2267,7 @@ mod test { use tari_script::{inputs, script}; use tari_test_utils::random::string; use tempfile::tempdir; - + use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; use crate::{ storage::sqlite_utilities::wallet_db_connection::WalletDbConnection, test_utils::create_consensus_constants, diff --git a/base_layer/wallet/tests/output_manager_service_tests/service.rs b/base_layer/wallet/tests/output_manager_service_tests/service.rs index 9bac6c3de71..7d5c737d909 100644 --- a/base_layer/wallet/tests/output_manager_service_tests/service.rs +++ b/base_layer/wallet/tests/output_manager_service_tests/service.rs @@ -64,9 +64,7 @@ use tari_core::{ key_manager::{TransactionKeyManagerBranch, TransactionKeyManagerInterface}, tari_amount::{uT, MicroMinotari, T}, test_helpers::{ - create_memory_db_key_manager, create_wallet_output_with_data, - MemoryDbKeyManager, TestParams, }, transaction_components::{OutputFeatures, OutputType, TransactionOutput, WalletOutput}, @@ -85,6 +83,7 @@ use tokio::{ task, time::sleep, }; +use tari_core::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}; use crate::support::{ base_node_service_mock::MockBaseNodeService, diff --git a/base_layer/wallet/tests/output_manager_service_tests/storage.rs b/base_layer/wallet/tests/output_manager_service_tests/storage.rs index 59888e47acb..9b21162722f 100644 --- a/base_layer/wallet/tests/output_manager_service_tests/storage.rs +++ b/base_layer/wallet/tests/output_manager_service_tests/storage.rs @@ -34,9 +34,9 @@ use rand::{rngs::OsRng, RngCore}; use tari_common_types::{transaction::TxId, types::FixedHash}; use tari_core::transactions::{ tari_amount::MicroMinotari, - test_helpers::create_memory_db_key_manager, transaction_components::OutputFeatures, }; +use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; use crate::support::{data::get_temp_sqlite_database_connection, utils::make_input}; diff --git a/base_layer/wallet/tests/transaction_service_tests/service.rs b/base_layer/wallet/tests/transaction_service_tests/service.rs index 4b32ac6e20d..fd2a77c088c 100644 --- a/base_layer/wallet/tests/transaction_service_tests/service.rs +++ b/base_layer/wallet/tests/transaction_service_tests/service.rs @@ -126,9 +126,7 @@ use tari_core::{ key_manager::{TransactionKeyManagerInitializer, TransactionKeyManagerInterface}, tari_amount::*, test_helpers::{ - create_memory_db_key_manager, create_wallet_output_with_data, - MemoryDbKeyManager, TestParams, }, transaction_components::{KernelBuilder, OutputFeatures, Transaction}, @@ -144,6 +142,7 @@ use tari_core::{ }, ConfidentialOutputHasher, }; +use tari_core::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}; use tari_crypto::{ commitment::HomomorphicCommitmentFactory, extended_range_proof::{ExtendedRangeProofService, Statement}, diff --git a/base_layer/wallet/tests/transaction_service_tests/storage.rs b/base_layer/wallet/tests/transaction_service_tests/storage.rs index 971ef652e55..a7e6b1b44fc 100644 --- a/base_layer/wallet/tests/transaction_service_tests/storage.rs +++ b/base_layer/wallet/tests/transaction_service_tests/storage.rs @@ -52,7 +52,7 @@ use tari_core::{ transactions::{ key_manager::{TransactionKeyManagerBranch, TransactionKeyManagerInterface}, tari_amount::{uT, MicroMinotari}, - test_helpers::{create_memory_db_key_manager, create_wallet_output_with_data, TestParams}, + test_helpers::{ create_wallet_output_with_data, TestParams}, transaction_components::{ OutputFeatures, RangeProofType, @@ -71,6 +71,7 @@ use tari_key_manager::key_manager_service::KeyManagerInterface; use tari_script::{inputs, script}; use tari_test_utils::random; use tempfile::tempdir; +use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; pub async fn test_db_backend(backend: T) { let mut db = TransactionDatabase::new(backend); diff --git a/base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs b/base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs index 30c0b8540f3..6b7030fb166 100644 --- a/base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs +++ b/base_layer/wallet/tests/transaction_service_tests/transaction_protocols.rs @@ -79,12 +79,13 @@ use tari_core::{ }, transactions::{ tari_amount::{uT, MicroMinotari, T}, - test_helpers::{create_memory_db_key_manager, schema_to_transaction, MemoryDbKeyManager}, + test_helpers::{ schema_to_transaction, MemoryDbKeyManager}, transaction_components::OutputFeatures, CryptoFactories, }, txn_schema, }; +use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; use tari_service_framework::{reply_channel, reply_channel::Receiver}; use tari_shutdown::Shutdown; use tari_test_utils::random; diff --git a/base_layer/wallet/tests/utxo_scanner/mod.rs b/base_layer/wallet/tests/utxo_scanner/mod.rs index 0f1e2622f1b..7e70f8f56e7 100644 --- a/base_layer/wallet/tests/utxo_scanner/mod.rs +++ b/base_layer/wallet/tests/utxo_scanner/mod.rs @@ -62,11 +62,11 @@ use tari_core::{ proto::base_node::{ChainMetadata, TipInfoResponse}, transactions::{ tari_amount::MicroMinotari, - test_helpers::{create_memory_db_key_manager, MemoryDbKeyManager}, transaction_components::{OutputFeatures, WalletOutput}, CryptoFactories, }, }; +use tari_core::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}; use tari_key_manager::{cipher_seed::CipherSeed, get_birthday_from_unix_epoch_in_seconds}; use tari_service_framework::reply_channel; use tari_shutdown::Shutdown; diff --git a/base_layer/wallet_ffi/src/lib.rs b/base_layer/wallet_ffi/src/lib.rs index c638a9e7c04..70be852166f 100644 --- a/base_layer/wallet_ffi/src/lib.rs +++ b/base_layer/wallet_ffi/src/lib.rs @@ -8584,13 +8584,13 @@ mod test { transactions::{ key_manager::SecretTransactionKeyManagerInterface, test_helpers::{ - create_memory_db_key_manager, create_test_input, create_wallet_output_with_data, TestParams, }, }, }; + use tari_core::transactions::key_manager::memory_db_key_manager::create_memory_db_key_manager; use tari_key_manager::{mnemonic::MnemonicLanguage, mnemonic_wordlists}; use tari_script::script; use tari_test_utils::random; diff --git a/integration_tests/src/world.rs b/integration_tests/src/world.rs index ae92d5264f4..119a7d8cc69 100644 --- a/integration_tests/src/world.rs +++ b/integration_tests/src/world.rs @@ -40,10 +40,10 @@ use tari_core::{ blocks::Block, transactions::{ key_manager::TariKeyId, - test_helpers::{create_memory_db_key_manager, MemoryDbKeyManager}, transaction_components::{Transaction, WalletOutput}, }, }; +use tari_core::transactions::key_manager::memory_db_key_manager::{create_memory_db_key_manager, MemoryDbKeyManager}; use tari_crypto::keys::{PublicKey as PK, SecretKey}; use tari_utilities::hex::Hex; use thiserror::Error;