Skip to content
Open
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 25 additions & 21 deletions bin/integration-tests/src/tests/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,10 +218,14 @@ pub async fn test_import_expected_notes(client_config: ClientConfig) -> Result<(
client_2.sync_state().await.unwrap();

// Importing a public note before it's committed onchain should fail
assert!(matches!(
client_2.import_note(NoteFile::NoteId(note.id())).await.unwrap_err(),
ClientError::NoteNotFoundOnChain(_)
));
assert_eq!(
client_2
.import_notes(&[NoteFile::NoteId(note.id())])
.await
.unwrap_err()
.to_string(),
"note import error: No notes fetched from node".to_string()
);
execute_tx_and_sync(&mut client_1, faucet_account.id(), tx_request).await?;

// Use client 1 to wait until a couple of blocks have passed
Expand All @@ -230,7 +234,7 @@ pub async fn test_import_expected_notes(client_config: ClientConfig) -> Result<(
let new_sync_data = client_2.sync_state().await.unwrap();

client_2.add_note_tag(note.metadata().unwrap().tag()).await.unwrap();
client_2.import_note(NoteFile::NoteId(note.clone().id())).await.unwrap();
client_2.import_notes(&[NoteFile::NoteId(note.clone().id())]).await.unwrap();
client_2.sync_state().await.unwrap();
let input_note = client_2.get_input_note(note.id()).await.unwrap().unwrap();
// If imported after execution and syncing then the inclusion proof should be Some
Expand Down Expand Up @@ -260,11 +264,11 @@ pub async fn test_import_expected_notes(client_config: ClientConfig) -> Result<(
// Import the node before it's committed onchain works if we have full `NoteDetails`
client_2.add_note_tag(note.metadata().unwrap().tag()).await.unwrap();
client_2
.import_note(NoteFile::NoteDetails {
.import_notes(&[NoteFile::NoteDetails {
details: note.clone().into(),
after_block_num: client_1.get_sync_height().await.unwrap(),
tag: Some(note.metadata().unwrap().tag()),
})
}])
.await
.unwrap();
let input_note = client_2.get_input_note(note.id()).await.unwrap().unwrap();
Expand Down Expand Up @@ -327,12 +331,12 @@ pub async fn test_import_expected_note_uncommitted(client_config: ClientConfig)

// If the verification is requested before execution then the import should fail
let imported_note_id = client_2
.import_note(NoteFile::NoteDetails {
.import_notes(&[NoteFile::NoteDetails {
details: note.into(),
after_block_num: 0.into(),
tag: None,
})
.await?;
}])
.await?[0];

let imported_note = client_2.get_input_note(imported_note_id).await.unwrap().unwrap();

Expand Down Expand Up @@ -377,12 +381,12 @@ pub async fn test_import_expected_notes_from_the_past_as_committed(

// importing the note before client_2 is synced will result in a note with `Expected` state
let note_id = client_2
.import_note(NoteFile::NoteDetails {
.import_notes(&[NoteFile::NoteDetails {
details: note.clone().into(),
after_block_num: block_height_before,
tag: Some(note.metadata().unwrap().tag()),
})
.await?;
}])
.await?[0];

let imported_note = client_2.get_input_note(note_id).await.unwrap().unwrap();

Expand All @@ -392,12 +396,12 @@ pub async fn test_import_expected_notes_from_the_past_as_committed(

// import the note after syncing the client
let note_id = client_2
.import_note(NoteFile::NoteDetails {
.import_notes(&[NoteFile::NoteDetails {
details: note.clone().into(),
after_block_num: block_height_before,
tag: Some(note.metadata().unwrap().tag()),
})
.await?;
}])
.await?[0];

let imported_note = client_2.get_input_note(note_id).await.unwrap().unwrap();

Expand Down Expand Up @@ -835,10 +839,10 @@ pub async fn test_import_consumed_note_with_proof(client_config: ClientConfig) -

// Import the consumed note
client_2
.import_note(NoteFile::NoteWithProof(
.import_notes(&[NoteFile::NoteWithProof(
note.clone().try_into().unwrap(),
note.inclusion_proof().unwrap().clone(),
))
)])
.await?;

let consumed_note = client_2.get_input_note(note.id()).await.unwrap().unwrap();
Expand Down Expand Up @@ -900,7 +904,7 @@ pub async fn test_import_consumed_note_with_id(client_config: ClientConfig) -> R
client_2.sync_state().await.unwrap();

// Import the consumed note
client_2.import_note(NoteFile::NoteId(note.id())).await.unwrap();
client_2.import_notes(&[NoteFile::NoteId(note.id())]).await.unwrap();

let consumed_note = client_2.get_input_note(note.id()).await.unwrap().unwrap();
assert!(matches!(consumed_note.state(), InputNoteState::ConsumedExternal { .. }));
Expand Down Expand Up @@ -956,10 +960,10 @@ pub async fn test_import_note_with_proof(client_config: ClientConfig) -> Result<

// Import the consumed note
client_2
.import_note(NoteFile::NoteWithProof(
.import_notes(&[NoteFile::NoteWithProof(
note.clone().try_into().unwrap(),
note.inclusion_proof().unwrap().clone(),
))
)])
.await?;

let imported_note = client_2.get_input_note(note.id()).await.unwrap().unwrap();
Expand Down
2 changes: 1 addition & 1 deletion bin/integration-tests/src/tests/onchain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ pub async fn test_onchain_accounts(client_config: ClientConfig) -> Result<()> {
let notes = client_2.get_input_notes(NoteFilter::Committed).await?;

//Import the note on the first client so that we can later check its consumer account
client_1.import_note(NoteFile::NoteId(notes[0].id())).await?;
client_1.import_notes(&[NoteFile::NoteId(notes[0].id())]).await?;

// Consume the note
println!("Consuming note on second client...");
Expand Down
4 changes: 2 additions & 2 deletions bin/integration-tests/src/tests/swap_transaction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -309,11 +309,11 @@ pub async fn test_swap_private(client_config: ClientConfig) -> Result<()> {
)?;
client2.add_note_tag(tag).await?;
client2
.import_note(NoteFile::NoteDetails {
.import_notes(&[NoteFile::NoteDetails {
details: output_note.try_into()?,
after_block_num: client1.get_sync_height().await?,
tag: Some(tag),
})
}])
.await?;

// Sync so we get the inclusion proof info
Expand Down
2 changes: 1 addition & 1 deletion bin/miden-cli/src/commands/import.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl ImportCmd {
let note_file = read_note_file(filename.clone());

if let Ok(note_file) = note_file {
let note_id = client.import_note(note_file).await?;
let note_id = client.import_notes(&[note_file]).await?[0];
println!("Successfully imported note {}", note_id.to_hex());
} else {
info!(
Expand Down
Loading
Loading