Skip to content

Commit 0a12148

Browse files
authored
fix: get_validity_proof order (#1847)
1 parent ef0dd04 commit 0a12148

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

sdk-libs/program-test/src/indexer/test_indexer.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -554,14 +554,12 @@ impl Indexer for TestIndexer {
554554
}
555555
}
556556

557-
// reverse so that we can pop elements.
558-
proof_inputs.reverse();
559-
// Reinsert.
560-
for index in indices_to_remove.iter().rev() {
561-
if root_indices.len() <= *index {
562-
root_indices.push(proof_inputs.pop().unwrap());
557+
// Reinsert proof_inputs at their original positions in forward order
558+
for (proof_input, &index) in proof_inputs.iter().zip(indices_to_remove.iter()) {
559+
if root_indices.len() <= index {
560+
root_indices.push(proof_input.clone());
563561
} else {
564-
root_indices.insert(*index, proof_inputs.pop().unwrap());
562+
root_indices.insert(index, proof_input.clone());
565563
}
566564
}
567565
root_indices

0 commit comments

Comments
 (0)