public void a_stream_can_be_found() { Assert.True(_newtable.TryGetLatestEntry(0x010800000000, out var entry)); Assert.AreEqual(0x0108, entry.Stream); Assert.AreEqual(0, entry.Version); Assert.AreEqual(0x0108, entry.Position); }
public void try_get_latest_entry_for_smallest_hash_returns_correct_index_entry() { IndexEntry entry; Assert.IsTrue(PTable.TryGetLatestEntry(0x010100000000, out entry)); Assert.AreEqual(GetHash(0x010100000000), entry.Stream); Assert.AreEqual(0, entry.Version); Assert.AreEqual(0x0002, entry.Position); }
public void try_get_latest_entry_for_largest_hash_returns_correct_index_entry() { IndexEntry entry; Assert.IsTrue(PTable.TryGetLatestEntry(1, out entry)); Assert.AreEqual(1, entry.Stream); Assert.AreEqual(0, entry.Version); Assert.AreEqual(0x0005, entry.Position); }
public void a_stream_can_be_found() { var stream = (ulong)0x010400000000; Assert.True(_newtable.TryGetLatestEntry(stream, out var entry)); Assert.AreEqual(stream, entry.Stream); Assert.AreEqual(1, entry.Version); Assert.AreEqual(9, entry.Position); }
public void a_stream_can_be_found() { ulong entry1 = 0x0103; var stream = _upgradeHash($"{entry1}", entry1); Assert.True(_newtable.TryGetLatestEntry(stream, out var entry)); Assert.AreEqual(stream, entry.Stream); Assert.AreEqual(1, entry.Version); Assert.AreEqual(4, entry.Position); }
public void the_streams_can_be_found() { for (int j = 0; j < 10; j++) { var stream = (ulong)(0x010100000000 << (j + 1)); Assert.True(_newtable.TryGetLatestEntry(stream, out var entry)); Assert.AreEqual(GetHash(stream), entry.Stream); Assert.AreEqual(2, entry.Version); Assert.AreEqual(1 * j, entry.Position); } }
public void throw_exception_if_index_entries_not_descending_during_ptable_get_latest_entry_2(byte version, bool skipIndexVerify) { string ptableFileName = ConstructPTable(version); CorruptPTableFile(ptableFileName, version, "maxOutMiddleEntries"); //loading with a depth of 1 should load only 2 midpoints (first and last index entry) PTable pTable = PTable.FromFile(ptableFileName, 1, skipIndexVerify); IndexEntry entry; Assert.Throws <MaybeCorruptIndexException>(() => pTable.TryGetLatestEntry(GetOriginalHash(numIndexEntries / 2, version), out entry)); pTable.Dispose(); }
public void throw_exception_if_index_entries_not_descending_during_ptable_get_latest_entry(byte version, bool skipIndexVerify) { string ptableFileName = ConstructPTable(version); CorruptPTableFile(ptableFileName, version, "zeroOutMiddleEntries"); //loading with a depth of 1 should load only 2 midpoints (first and last index entry) PTable pTable = PTable.FromFile(ptableFileName, Constants.PTableInitialReaderCount, Constants.PTableMaxReaderCountDefault, 1, skipIndexVerify); IndexEntry entry; Assert.Throws <MaybeCorruptIndexException>(() => // changed 2 to 4 here because the corruption actually removes the stream at /2, so it isn't in the bloom filter pTable.TryGetLatestEntry(GetOriginalHash(numIndexEntries / 4, version), out entry)); pTable.Dispose(); }
public void try_get_latest_entry_returns_nothing_for_nonexistent_stream() { IndexEntry entry; Assert.IsFalse(PTable.TryGetLatestEntry(0x010200000000, out entry)); }