Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
fix test

fix test

fix
  • Loading branch information
SWvheerden committed May 30, 2024
1 parent b02d185 commit c8fa3de
Show file tree
Hide file tree
Showing 11 changed files with 45 additions and 4 deletions.
1 change: 0 additions & 1 deletion base_layer/core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#[macro_use]
extern crate bitflags;
extern crate core;

pub mod blocks;
#[cfg(feature = "base_node")]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ use crate::{
tari_amount::{uT, T},
test_helpers,
test_helpers::{TestParams, UtxoTestParams},
transaction_components::{transaction_output::batch_verify_range_proofs, OutputFeatures},
transaction_components::{
encrypted_data::PaymentId,
transaction_output::batch_verify_range_proofs,
OutputFeatures,
},
transaction_protocol::TransactionProtocolError,
CryptoFactories,
},
Expand Down
1 change: 1 addition & 0 deletions base_layer/wallet/src/output_manager_service/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2130,6 +2130,7 @@ where
output.minimum_value_promise,
output.proof,
payment_id,
);

let message = "SHA-XTR atomic swap".to_string();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2193,7 +2193,7 @@ mod test {
key_manager::create_memory_db_key_manager,
tari_amount::MicroMinotari,
test_helpers::{create_wallet_output_with_data, TestParams},
transaction_components::{OutputFeatures, Transaction},
transaction_components::{encrypted_data::PaymentId, OutputFeatures, Transaction},
transaction_protocol::sender::TransactionSenderMessage,
ReceiverTransactionProtocol,
SenderTransactionProtocol,
Expand Down Expand Up @@ -2481,6 +2481,7 @@ mod test {
mined_height: None,
mined_in_block: None,
mined_timestamp: None,
payment_id: None,
};
let source_address = TariAddress::new_dual_address_with_default_features(
PublicKey::from_secret_key(&PrivateKey::random(&mut OsRng)),
Expand Down Expand Up @@ -2511,6 +2512,7 @@ mod test {
mined_height: None,
mined_in_block: None,
mined_timestamp: None,
payment_id: None,
};

CompletedTransactionSql::try_from(completed_tx1.clone(), &cipher)
Expand Down Expand Up @@ -2750,6 +2752,7 @@ mod test {
mined_height: None,
mined_in_block: None,
mined_timestamp: None,
payment_id: Some(PaymentId::Zero),
};

let completed_tx_sql = CompletedTransactionSql::try_from(completed_tx.clone(), &cipher).unwrap();
Expand Down Expand Up @@ -2882,6 +2885,7 @@ mod test {
mined_height: None,
mined_in_block: None,
mined_timestamp: None,
payment_id: None,
};
let completed_tx_sql = CompletedTransactionSql::try_from(completed_tx, &cipher).unwrap();

Expand Down Expand Up @@ -3024,6 +3028,7 @@ mod test {
mined_height: None,
mined_in_block: None,
mined_timestamp: None,
payment_id: None,
};
let completed_tx_sql = CompletedTransactionSql::try_from(completed_tx.clone(), &cipher).unwrap();

Expand Down
9 changes: 9 additions & 0 deletions base_layer/wallet/tests/transaction_service_tests/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3130,6 +3130,7 @@ async fn test_power_mode_updates() {
mined_height: None,
mined_in_block: None,
mined_timestamp: None,
payment_id: None,
};

let source_address = TariAddress::new_dual_address_with_default_features(
Expand Down Expand Up @@ -3161,6 +3162,7 @@ async fn test_power_mode_updates() {
mined_height: None,
mined_in_block: None,
mined_timestamp: None,
payment_id: None,
};

tx_backend
Expand Down Expand Up @@ -5853,6 +5855,7 @@ async fn broadcast_all_completed_transactions_on_startup() {
mined_height: None,
mined_in_block: None,
mined_timestamp: None,
payment_id: None,
};

let completed_tx2 = CompletedTransaction {
Expand Down Expand Up @@ -5991,6 +5994,7 @@ async fn test_update_faux_tx_on_oms_validation() {
uo_1.to_transaction_output(&alice_ts_interface.key_manager_handle)
.await
.unwrap(),
PaymentId::Zero,
)
.await
.unwrap();
Expand All @@ -6007,6 +6011,7 @@ async fn test_update_faux_tx_on_oms_validation() {
uo_2.to_transaction_output(&alice_ts_interface.key_manager_handle)
.await
.unwrap(),
PaymentId::Zero,
)
.await
.unwrap();
Expand All @@ -6023,6 +6028,7 @@ async fn test_update_faux_tx_on_oms_validation() {
uo_3.to_transaction_output(&alice_ts_interface.key_manager_handle)
.await
.unwrap(),
PaymentId::Zero,
)
.await
.unwrap();
Expand Down Expand Up @@ -6166,6 +6172,7 @@ async fn test_update_coinbase_tx_on_oms_validation() {
uo_1.to_transaction_output(&alice_ts_interface.key_manager_handle)
.await
.unwrap(),
PaymentId::Zero,
)
.await
.unwrap();
Expand All @@ -6182,6 +6189,7 @@ async fn test_update_coinbase_tx_on_oms_validation() {
uo_2.to_transaction_output(&alice_ts_interface.key_manager_handle)
.await
.unwrap(),
PaymentId::Zero,
)
.await
.unwrap();
Expand All @@ -6198,6 +6206,7 @@ async fn test_update_coinbase_tx_on_oms_validation() {
uo_3.to_transaction_output(&alice_ts_interface.key_manager_handle)
.await
.unwrap(),
PaymentId::Zero,
)
.await
.unwrap();
Expand Down
4 changes: 4 additions & 0 deletions base_layer/wallet/tests/transaction_service_tests/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ pub async fn test_db_backend<T: TransactionBackend + 'static>(backend: T) {
mined_height: None,
mined_in_block: None,
mined_timestamp: None,
payment_id: Some(PaymentId::Zero),
});
db.complete_outbound_transaction(outbound_txs[i].tx_id, completed_txs[i].clone())
.unwrap();
Expand Down Expand Up @@ -594,6 +595,7 @@ async fn import_tx_and_read_it_from_db() {
TransactionDirection::Inbound,
Some(5),
Some(NaiveDateTime::from_timestamp_opt(0, 0).unwrap()),
None,
)
.unwrap();

Expand Down Expand Up @@ -623,6 +625,7 @@ async fn import_tx_and_read_it_from_db() {
TransactionDirection::Inbound,
Some(6),
Some(NaiveDateTime::from_timestamp_opt(0, 0).unwrap()),
None,
)
.unwrap();

Expand Down Expand Up @@ -652,6 +655,7 @@ async fn import_tx_and_read_it_from_db() {
TransactionDirection::Inbound,
Some(7),
Some(NaiveDateTime::from_timestamp_opt(0, 0).unwrap()),
None,
)
.unwrap();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ pub async fn add_transaction_to_database(
TransactionDirection::Outbound,
None,
None,
None,
)
.unwrap();
db.insert_completed_transaction(tx_id, completed_tx1).unwrap();
Expand Down
4 changes: 4 additions & 0 deletions base_layer/wallet/tests/utxo_scanner/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,7 @@ async fn test_utxo_scanner_recovery_with_restart() {
current_height: _,
mined_timestamp: _,
scanned_output: _,
payment_id: _,
} = req
{
assert_eq!(message, "Output found on blockchain during Wallet Recovery".to_string());
Expand Down Expand Up @@ -550,6 +551,7 @@ async fn test_utxo_scanner_recovery_with_restart() {
current_height: _,
mined_timestamp: _,
scanned_output: _,
payment_id: _,
} = req
{
assert_eq!(message, "recovery".to_string());
Expand Down Expand Up @@ -969,6 +971,7 @@ async fn test_utxo_scanner_one_sided_payments() {
current_height: _,
mined_timestamp: _,
scanned_output: _,
payment_id: _,
} = req
{
assert_eq!(message, "Output found on blockchain during Wallet Recovery".to_string());
Expand Down Expand Up @@ -1067,6 +1070,7 @@ async fn test_utxo_scanner_one_sided_payments() {
current_height: h,
mined_timestamp: _,
scanned_output: _,
payment_id: _,
} = req
{
println!("{:?}", h);
Expand Down
3 changes: 3 additions & 0 deletions base_layer/wallet_ffi/src/callback_handler_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ mod test {
TransactionDirection::Inbound,
None,
None,
None,
)
.unwrap();
db.insert_completed_transaction(2u64.into(), completed_tx.clone())
Expand Down Expand Up @@ -396,6 +397,7 @@ mod test {
TransactionDirection::Inbound,
Some(2),
Some(NaiveDateTime::from_timestamp_opt(0, 0).unwrap_or(NaiveDateTime::MIN)),
None,
)
.unwrap();
db.insert_completed_transaction(6u64.into(), faux_unconfirmed_tx.clone())
Expand Down Expand Up @@ -430,6 +432,7 @@ mod test {
TransactionDirection::Inbound,
Some(5),
Some(NaiveDateTime::from_timestamp_opt(0, 0).unwrap()),
None,
)
.unwrap();
db.insert_completed_transaction(7u64.into(), faux_confirmed_tx.clone())
Expand Down
2 changes: 1 addition & 1 deletion base_layer/wallet_ffi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6730,7 +6730,7 @@ pub unsafe extern "C" fn wallet_send_transaction(
let payment_id = match payment_id {
0 => PaymentId::Zero,
x if x <= u64::from(u32::MAX) => PaymentId::U32(x.try_into().expect("number should fit into u32")),
x => PaymentId::U64(x.try_into().expect("number should fit into u64")),
x => PaymentId::U64(x),
};
match (*wallet).runtime.block_on(
(*wallet)
Expand Down
11 changes: 11 additions & 0 deletions integration_tests/tests/steps/wallet_steps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -706,6 +706,7 @@ async fn send_amount_from_source_wallet_to_dest_wallet_without_broadcast(
dest_wallet.as_str()
),
payment_type: 0, // normal mimblewimble payment type
payment_id: "".to_string(),
};
let transfer_req = TransferRequest {
recipients: vec![payment_recipient],
Expand Down Expand Up @@ -766,6 +767,7 @@ async fn send_one_sided_transaction_from_source_wallet_to_dest_wallt(
dest_wallet.as_str()
),
payment_type: 1, // one sided transaction
payment_id: "".to_string(),
};
let transfer_req = TransferRequest {
recipients: vec![payment_recipient],
Expand Down Expand Up @@ -865,6 +867,7 @@ async fn send_amount_from_wallet_to_wallet_at_fee(
fee_per_gram
),
payment_type: 0, // mimblewimble transaction
payment_id: "".to_string(),
};
let transfer_req = TransferRequest {
recipients: vec![payment_recipient],
Expand Down Expand Up @@ -1294,6 +1297,7 @@ async fn send_num_transactions_to_wallets_at_fee(
receiver_wallet.as_str()
),
payment_type: 0, // standard mimblewimble transaction
payment_id: "".to_string(),
};
let transfer_req = TransferRequest {
recipients: vec![payment_recipient],
Expand Down Expand Up @@ -1435,6 +1439,7 @@ async fn transfer_tari_from_wallet_to_receiver(world: &mut TariWorld, amount: u6
receiver.as_str()
),
payment_type: 0, // normal mimblewimble payment type
payment_id: "".to_string(),
};
let transfer_req = TransferRequest {
recipients: vec![payment_recipient],
Expand Down Expand Up @@ -1629,6 +1634,7 @@ async fn transfer_from_wallet_to_two_recipients_at_fee(
receiver1.as_str()
),
payment_type: 0, // normal mimblewimble payment type
payment_id: "".to_string(),
};

let payment_recipient2 = PaymentRecipient {
Expand All @@ -1642,6 +1648,7 @@ async fn transfer_from_wallet_to_two_recipients_at_fee(
receiver2.as_str()
),
payment_type: 0, // normal mimblewimble payment type
payment_id: "".to_string(),
};
let transfer_req = TransferRequest {
recipients: vec![payment_recipient1, payment_recipient2],
Expand Down Expand Up @@ -1753,6 +1760,7 @@ async fn transfer_tari_to_self(world: &mut TariWorld, amount: u64, sender: Strin
fee_per_gram,
message: format!("transfer amount {} from {} to self", amount, sender.as_str(),),
payment_type: 0, // normal mimblewimble payment type
payment_id: "".to_string(),
};
let transfer_req = TransferRequest {
recipients: vec![payment_recipient],
Expand Down Expand Up @@ -1838,6 +1846,7 @@ async fn htlc_transaction(world: &mut TariWorld, amount: u64, sender: String, re
fee_per_gram
),
payment_type: 0, // normal mimblewimble transaction
payment_id: "".to_string(),
};

let atomic_swap_request = SendShaAtomicSwapRequest {
Expand Down Expand Up @@ -2127,6 +2136,7 @@ async fn send_one_sided_stealth_transaction(
receiver.as_str()
),
payment_type: 2, // one sided stealth transaction
payment_id: "".to_string(),
};
let transfer_req = TransferRequest {
recipients: vec![payment_recipient],
Expand Down Expand Up @@ -2608,6 +2618,7 @@ async fn multi_send_txs_from_wallet(
fee_per_gram
),
payment_type: 0, // mimblewimble transaction
payment_id: "".to_string(),
};

let transfer_req = TransferRequest {
Expand Down

0 comments on commit c8fa3de

Please sign in to comment.