diff --git a/contracts/transfer/tests/transfer.rs b/contracts/transfer/tests/transfer.rs index cb2b7b16f6..700ae096b8 100644 --- a/contracts/transfer/tests/transfer.rs +++ b/contracts/transfer/tests/transfer.rs @@ -149,6 +149,12 @@ fn leaves_from_pos(session: &mut Session, pos: u64) -> Result> { .collect()) } +fn next_pos(session: &mut Session) -> Result { + session + .call(TRANSFER_CONTRACT, "next_pos", &(), u64::MAX) + .map(|r| r.data) +} + fn update_root(session: &mut Session) -> Result<()> { session .call(TRANSFER_CONTRACT, "update_root", &(), POINT_LIMIT) @@ -254,6 +260,13 @@ fn transfer() { assert_eq!(leaves.len(), 1, "There should be one note in the state"); + let pos = next_pos(session).expect("Getting last post should succeed"); + assert_eq!( + pos, + leaves.last().expect("note to exists").note.pos() + 1, + "next_pos should match position of last note + 1" + ); + let leaves = leaves_from_pos(session, 0) .expect("Getting leaves in the given range should succeed"); @@ -364,7 +377,14 @@ fn transfer() { "There should be three notes in the tree at this block height" ); - let leaves = leaves_from_height(session, input_note.pos() + 1) + let pos = next_pos(session).expect("Getting last post should succeed"); + assert_eq!( + pos, + leaves.last().expect("note to exists").note.pos() + 1, + "next_pos should match position of last note + 1" + ); + + let leaves = leaves_from_pos(session, input_note.pos() + 1) .expect("Getting the notes should succeed"); assert_eq!( leaves.len(),