Skip to content

Commit

Permalink
wallet-core: change notes test to be close to SDK ones
Browse files Browse the repository at this point in the history
  • Loading branch information
ZER0 committed Sep 9, 2024
1 parent 257321c commit 13c0883
Showing 1 changed file with 14 additions and 20 deletions.
34 changes: 14 additions & 20 deletions wallet-core/tests/notes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,41 +17,35 @@ use execution_core::{
};

use wallet_core::{
keys::derive_multiple_phoenix_sk, map_owned, phoenix_balance, BalanceInfo,
keys::derive_multiple_phoenix_sk, keys::derive_phoenix_sk, map_owned,
phoenix_balance, BalanceInfo, Seed,
};

#[test]
fn test_map_owned() {
// Assuming this set of notes where the number used as suffix is the
// "owner":
// notes := [A1, B1, C2, D2, E1, F3]

let mut rng = StdRng::seed_from_u64(0xdab);
const SEED_1: [u8; 64] = [1; 64];
const SEED_2: [u8; 64] = [2; 64];
const SEED: Seed = [1; 64];

let owner_1_sks = derive_multiple_phoenix_sk(&SEED_1, 0..3);
let owner_1_sks = derive_multiple_phoenix_sk(&SEED, 0..3);
let owner_1_pks = [
PhoenixPublicKey::from(&owner_1_sks[0]),
PhoenixPublicKey::from(&owner_1_sks[1]),
PhoenixPublicKey::from(&owner_1_sks[2]),
];
let owner_2_sks = derive_multiple_phoenix_sk(&SEED_2, 0..2);
let owner_2_sks = derive_multiple_phoenix_sk(&SEED, 3..5);
let owner_2_pks = [
PhoenixPublicKey::from(&owner_2_sks[0]),
PhoenixPublicKey::from(&owner_2_sks[1]),
];
let owner_3_pk =
PhoenixPublicKey::from(&PhoenixSecretKey::random(&mut rng));
let owner_3_pk = PhoenixPublicKey::from(&derive_phoenix_sk(&SEED, 5));

let value = 42;
let note_leaves = vec![
gen_note(&mut rng, true, &owner_1_pks[0], value), // owner 1
gen_note(&mut rng, true, &owner_1_pks[1], value), // owner 1
gen_note(&mut rng, true, &owner_2_pks[0], value), // owner 2
gen_note(&mut rng, true, &owner_2_pks[1], value), // owner 2
gen_note(&mut rng, true, &owner_1_pks[2], value), // owner 1
gen_note(&mut rng, true, &owner_3_pk, value), // owner 3
gen_note(&mut rng, true, &owner_1_pks[0], 12), // owner 1
gen_note(&mut rng, true, &owner_1_pks[1], 1), // owner 1
gen_note(&mut rng, true, &owner_2_pks[0], 3), // owner 2
gen_note(&mut rng, true, &owner_2_pks[1], 76), // owner 2
gen_note(&mut rng, true, &owner_1_pks[2], 6), // owner 1
gen_note(&mut rng, true, &owner_3_pk, 42), // owner 3
];

// notes with idx 0, 1 and 4 are owned by owner_1
Expand Down Expand Up @@ -139,7 +133,7 @@ fn gen_note(
note: Note::obfuscated(
rng,
&sender_pk,
&owner_pk,
owner_pk,
value,
value_blinder,
sender_blinder,
Expand All @@ -151,7 +145,7 @@ fn gen_note(
note: Note::transparent(
rng,
&sender_pk,
&owner_pk,
owner_pk,
value,
sender_blinder,
),
Expand Down

0 comments on commit 13c0883

Please sign in to comment.