public void Can_collect_many() { WitnessCollector witnessCollector = new WitnessCollector(new MemDb(), LimboLogs.Instance); witnessCollector.Add(TestItem.KeccakA); witnessCollector.Add(TestItem.KeccakB); witnessCollector.Collected.Should().HaveCount(2); }
public void Collects_each_cache_once() { WitnessCollector witnessCollector = new WitnessCollector(new MemDb(), LimboLogs.Instance); witnessCollector.Add(Keccak.Zero); witnessCollector.Add(Keccak.Zero); witnessCollector.Collected.Should().HaveCount(1); }
public void Collects_what_it_should_collect() { WitnessCollector witnessCollector = new WitnessCollector(new MemDb(), LimboLogs.Instance); witnessCollector.Add(TestItem.KeccakA); witnessCollector.Add(TestItem.KeccakB); witnessCollector.Collected.Should().Contain(TestItem.KeccakA); witnessCollector.Collected.Should().Contain(TestItem.KeccakB); }
public void Can_collect_after_reset() { WitnessCollector witnessCollector = new WitnessCollector(new MemDb(), LimboLogs.Instance); witnessCollector.Add(TestItem.KeccakA); witnessCollector.Add(TestItem.KeccakB); witnessCollector.Reset(); witnessCollector.Add(TestItem.KeccakC); witnessCollector.Collected.Should().HaveCount(1); }
public void Can_persist_and_load() { IKeyValueStore keyValueStore = new MemDb(); WitnessCollector witnessCollector = new WitnessCollector(keyValueStore, LimboLogs.Instance); witnessCollector.Add(TestItem.KeccakA); witnessCollector.Add(TestItem.KeccakB); witnessCollector.Persist(Keccak.Zero); var witness = witnessCollector.Load(Keccak.Zero); witness.Should().HaveCount(2); }
public void Can_persist_more() { IKeyValueStore keyValueStore = new MemDb(); WitnessCollector witnessCollector = new WitnessCollector(keyValueStore, LimboLogs.Instance); witnessCollector.Add(TestItem.KeccakA); witnessCollector.Add(TestItem.KeccakB); witnessCollector.Persist(Keccak.Zero); var witness = keyValueStore[Keccak.Zero.Bytes]; witness.Length.Should().Be(64); }
public void Can_reset_non_empty_many_times() { WitnessCollector witnessCollector = new WitnessCollector(new MemDb(), LimboLogs.Instance); witnessCollector.Add(TestItem.KeccakA); witnessCollector.Reset(); witnessCollector.Add(TestItem.KeccakA); witnessCollector.Reset(); witnessCollector.Add(TestItem.KeccakA); witnessCollector.Reset(); witnessCollector.Collected.Should().HaveCount(0); }
public void GetOneWitnessHash() { _blockFinder.FindHeader((BlockParameter)null).ReturnsForAnyArgs(_block.Header); _blockFinder.Head.Returns(_block); _witnessRepository.Add(_block.Hash); _witnessRepository.Persist(_block.Hash); string serialized = RpcTest.TestSerializedRequest <IWitnessRpcModule>(_witnessRpcModule, "get_witnesses", _block.CalculateHash().ToString()); serialized.Should().Be(GetOneWitnessHashResponse); }
public void Can_read_beyond_cache() { IKeyValueStore keyValueStore = new MemDb(); WitnessCollector witnessCollector = new WitnessCollector(keyValueStore, LimboLogs.Instance); for (int i = 0; i < 255; i++) { witnessCollector.Add(TestItem.Keccaks[i]); witnessCollector.Persist(TestItem.Keccaks[i]); } witnessCollector.Persist(TestItem.KeccakA); witnessCollector.Persist(TestItem.KeccakB); witnessCollector.Load(TestItem.Keccaks[0]); }