Skip to content

Commit

Permalink
updating tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Brian Corbin authored and briancorbin committed Apr 27, 2023
1 parent 52efa81 commit cdc6f37
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
6 changes: 4 additions & 2 deletions full-service/src/db/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,6 +840,7 @@ mod tests {
use crate::test_utils::WalletDbTestContext;
use mc_account_keys::RootIdentity;
use mc_common::logger::{test_with_logger, Logger};
use mc_crypto_keys::RistrettoPublic;
use mc_util_from_random::FromRandom;
use rand::{rngs::StdRng, SeedableRng};
use std::{collections::HashSet, convert::TryFrom, iter::FromIterator, ops::DerefMut};
Expand Down Expand Up @@ -1149,8 +1150,8 @@ mod tests {
let db_test_context = WalletDbTestContext::default();
let wallet_db = db_test_context.get_db_instance(logger);

let view_private_key = RistrettoPrivate::from_random(&mut rng);
let spend_public_key = RistrettoPublic::from_random(&mut rng);
let view_private_key = RistrettoPrivate::from_random(&mut rng).into();
let spend_public_key = RistrettoPublic::from_random(&mut rng).into();

let account = {
let mut pooled_conn = wallet_db.get_pooled_conn().unwrap();
Expand All @@ -1163,6 +1164,7 @@ mod tests {
12,
None,
None,
false,
conn,
)
.unwrap()
Expand Down
4 changes: 2 additions & 2 deletions full-service/src/service/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,8 +1104,8 @@ mod tests {

let view_only_account = service
.import_view_only_account(
ristretto_to_hex(view_account_key.view_private_key()),
ristretto_public_to_hex(view_account_key.spend_public_key()),
&view_account_key.view_private_key().clone().into(),
&view_account_key.spend_public_key().clone().into(),
None,
None,
None,
Expand Down
21 changes: 11 additions & 10 deletions full-service/src/service/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -198,10 +198,7 @@ mod tests {
db::account::AccountModel,
service::account::AccountService,
test_utils::{get_test_ledger, setup_wallet_service},
util::{
b58::b58_encode_public_address,
encoding_helpers::{ristretto_public_to_hex, ristretto_to_hex},
},
util::b58::b58_encode_public_address,
};
use mc_account_keys::{AccountKey, PublicAddress};
use mc_common::logger::{test_with_logger, Logger};
Expand Down Expand Up @@ -248,15 +245,19 @@ mod tests {
let pooled_conn = &mut service.get_pooled_conn().unwrap();
let conn = pooled_conn.deref_mut();

let view_private_key = RistrettoPrivate::from_random(&mut rng);
let spend_public_key = RistrettoPublic::from_random(&mut rng);

let vpk_hex = ristretto_to_hex(&view_private_key);
let spk_hex = ristretto_public_to_hex(&spend_public_key);
let view_private_key = RistrettoPrivate::from_random(&mut rng).into();
let spend_public_key = RistrettoPublic::from_random(&mut rng).into();

// Create an account.
let account = service
.import_view_only_account(vpk_hex, spk_hex, None, None, None, false)
.import_view_only_account(
&view_private_key,
&spend_public_key,
None,
None,
None,
false,
)
.unwrap();
assert_eq!(account.clone().next_subaddress_index(conn).unwrap(), 2);

Expand Down

0 comments on commit cdc6f37

Please sign in to comment.