()
| 855 | |
| 856 | #[test] |
| 857 | fn commits() { |
| 858 | let repo = repo::Memory::unlimited(); |
| 859 | let commits = vec![ |
| 860 | vec![(0, [1; 32]), (1, [2; 32])], |
| 861 | vec![(2, [3; 32])], |
| 862 | vec![(3, [4; 32]), (4, [5; 32])], |
| 863 | ]; |
| 864 | |
| 865 | let mut writer = repo::create_segment_writer(&repo, <_>::default(), Commit::DEFAULT_EPOCH, 0).unwrap(); |
| 866 | |
| 867 | for commit in &commits { |
| 868 | writer.commit(commit.clone()).unwrap(); |
| 869 | } |
| 870 | |
| 871 | writer.flush().unwrap(); |
| 872 | |
| 873 | let reader = repo::open_segment_reader(&repo, DEFAULT_LOG_FORMAT_VERSION, 0).unwrap(); |
| 874 | let mut commits1 = Vec::with_capacity(commits.len()); |
| 875 | let mut min_tx_offset = 0; |
| 876 | for txs in commits { |
| 877 | let n = txs.len(); |
| 878 | commits1.push(Commit { |
| 879 | min_tx_offset, |
| 880 | n: n as u16, |
| 881 | records: itertools::concat(txs.into_iter().map(|(_, payload)| payload.to_vec())), |
| 882 | epoch: 0, |
| 883 | }); |
| 884 | min_tx_offset += n as u64; |
| 885 | } |
| 886 | let commits2 = reader |
| 887 | .commits() |
| 888 | .map_ok(Into::into) |
| 889 | .collect::<Result<Vec<Commit>, _>>() |
| 890 | .unwrap(); |
| 891 | assert_eq!(commits1, commits2); |
| 892 | } |
| 893 | |
| 894 | #[test] |
| 895 | fn transactions() { |
nothing calls this directly
no test coverage detected
searching dependent graphs…