Skip to content

Commit

Permalink
Merge branch 'main' of github.com:lambdaclass/miden-client into mFrag…
Browse files Browse the repository at this point in the history
…aBA-fix-endpoint-to-get-account-ids
  • Loading branch information
mFragaBA committed Jan 11, 2024
2 parents d0ca426 + 38141a0 commit 7d409af
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 31 deletions.
29 changes: 8 additions & 21 deletions src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,14 @@ fn generate_sync_state_mock_requests() -> BTreeMap<SyncStateRequest, SyncStateRe
};

// generate test data
let (account, _, _, recorded_notes) = mock_inputs(
let transaction_inputs = mock_inputs(
MockAccountType::StandardExisting,
AssetPreservationStatus::Preserved,
);

let account = transaction_inputs.account();
let recorded_notes = transaction_inputs.input_notes();

let accounts = vec![ProtoAccountId {
id: u64::from(account.id()),
}];
Expand Down Expand Up @@ -133,15 +136,7 @@ fn generate_sync_state_mock_requests() -> BTreeMap<SyncStateRequest, SyncStateRe
merkle_path: Some(MerklePath::default()),
}],
nullifiers: vec![NullifierUpdate {
nullifier: Some(
recorded_notes
.first()
.unwrap()
.note()
.nullifier()
.inner()
.into(),
),
nullifier: Some(recorded_notes.get_note(0).note().nullifier().inner().into()),
block_num: 7,
}],
};
Expand Down Expand Up @@ -177,15 +172,7 @@ fn generate_sync_state_mock_requests() -> BTreeMap<SyncStateRequest, SyncStateRe
merkle_path: Some(MerklePath::default()),
}],
nullifiers: vec![NullifierUpdate {
nullifier: Some(
recorded_notes
.first()
.unwrap()
.note()
.nullifier()
.inner()
.into(),
),
nullifier: Some(recorded_notes.get_note(0).note().nullifier().inner().into()),
block_num: 7,
}],
};
Expand All @@ -202,7 +189,7 @@ pub fn insert_mock_data(client: &mut Client) {
};

// generate test data
let (_account, _, _, recorded_notes) = mock_inputs(
let transaction_inputs = mock_inputs(
MockAccountType::StandardExisting,
AssetPreservationStatus::Preserved,
);
Expand All @@ -212,7 +199,7 @@ pub fn insert_mock_data(client: &mut Client) {
let (_consumed, created_notes) = mock_notes(&assembler, &AssetPreservationStatus::Preserved);

// insert notes into database
for note in recorded_notes.into_iter() {
for note in transaction_inputs.input_notes().clone().into_iter() {
client.import_input_note(note.into()).unwrap();
}

Expand Down
10 changes: 5 additions & 5 deletions src/store/mock_executor_data_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ pub struct MockDataStore {

impl MockDataStore {
pub fn new() -> Self {
let (account, block_header, block_chain, consumed_notes) = mock_inputs(
let transaction_data = mock_inputs(
MockAccountType::StandardExisting,
AssetPreservationStatus::Preserved,
);
Self {
account,
block_header,
block_chain,
input_notes: InputNotes::new(consumed_notes).unwrap(),
account: transaction_data.account().clone(),
block_header: *transaction_data.block_header(),
block_chain: transaction_data.block_chain().clone(),
input_notes: transaction_data.input_notes().clone(),
}
}

Expand Down
14 changes: 9 additions & 5 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ use mock::mock::{
transaction::mock_inputs,
};
use objects::accounts::{AccountId, AccountStub};
use objects::transaction::InputNotes;

#[tokio::test]
async fn test_input_notes_round_trip() {
// generate test store path
Expand All @@ -32,10 +34,11 @@ async fn test_input_notes_round_trip() {
.unwrap();

// generate test data
let (_, _, _, recorded_notes) = mock_inputs(
let transaction_inputs = mock_inputs(
MockAccountType::StandardExisting,
AssetPreservationStatus::Preserved,
);
let recorded_notes = transaction_inputs.input_notes();

// insert notes into database
for note in recorded_notes.iter().cloned() {
Expand Down Expand Up @@ -67,22 +70,23 @@ async fn test_get_input_note() {
.unwrap();

// generate test data
let (_, _, _, recorded_notes) = mock_inputs(
let transaction_inputs = mock_inputs(
MockAccountType::StandardExisting,
AssetPreservationStatus::Preserved,
);
let recorded_notes: InputNotes = transaction_inputs.input_notes().clone();

// insert note into database
client
.import_input_note(recorded_notes[0].clone().into())
.import_input_note(recorded_notes.get_note(0).clone().into())
.unwrap();

// retrieve note from database
let retrieved_note = client
.get_input_note(recorded_notes[0].note().id())
.get_input_note(recorded_notes.get_note(0).note().id())
.unwrap();

let recorded_note: InputNoteRecord = recorded_notes[0].clone().into();
let recorded_note: InputNoteRecord = recorded_notes.get_note(0).clone().into();
assert_eq!(recorded_note.note_id(), retrieved_note.note_id())
}

Expand Down

0 comments on commit 7d409af

Please sign in to comment.