Merge pull request #162 from ethcore/db

fix iterator in indexed blocks
This commit is contained in:
Marek Kotewicz 2016-11-21 17:51:43 +01:00 committed by GitHub
commit c988a346e9
1 changed files with 15 additions and 1 deletions

View File

@ -57,7 +57,9 @@ impl<'a> Iterator for IndexedTransactions<'a> {
None
}
else {
Some((&self.block.transaction_hashes[self.position], &self.block.transactions[self.position]))
let result = Some((&self.block.transaction_hashes[self.position], &self.block.transactions[self.position]));
self.position += 1;
result
}
}
}
@ -74,4 +76,16 @@ mod tests {
assert_eq!(*indexed_block.transactions().nth(0).unwrap().0, block.transactions()[0].hash());
}
#[test]
fn iter() {
let block = test_data::block_builder()
.header().build()
.transaction().coinbase().output().value(3).build().build()
.transaction().coinbase().output().value(5).build().build()
.build();
let indexed_block: IndexedBlock = block.clone().into();
assert_eq!(*indexed_block.transactions().nth(1).unwrap().0, block.transactions()[1].hash());
}
}