Example #1
0
        public void Prunning_off_cache_should_not_find_cached_or_unknown()
        {
            TrieStore trieStore     = new TrieStore(new MemDb(), No.Pruning, No.Persistence, _logManager);
            var       returnedNode  = trieStore.FindCachedOrUnknown(TestItem.KeccakA, true);
            var       returnedNode2 = trieStore.FindCachedOrUnknown(TestItem.KeccakB, true);
            var       returnedNode3 = trieStore.FindCachedOrUnknown(TestItem.KeccakC, true);

            Assert.AreEqual(NodeType.Unknown, returnedNode.NodeType);
            Assert.AreEqual(NodeType.Unknown, returnedNode2.NodeType);
            Assert.AreEqual(NodeType.Unknown, returnedNode3.NodeType);
            trieStore.MemoryUsedByDirtyCache.Should().Be(0);
        }
Example #2
0
        public void FindCachedOrUnknown_CorrectlyCalculatedMemoryUsedByDirtyCache()
        {
            TrieStore trieStore = new TrieStore(new MemDb(), new TestPruningStrategy(true), No.Persistence, _logManager);
            var       startSize = trieStore.MemoryUsedByDirtyCache;

            trieStore.FindCachedOrUnknown(TestItem.KeccakA);
            TrieNode trieNode      = new TrieNode(NodeType.Leaf, Keccak.Zero);
            var      oneKeccakSize = trieNode.GetMemorySize(false);

            Assert.AreEqual(startSize + oneKeccakSize, trieStore.MemoryUsedByDirtyCache);
            trieStore.FindCachedOrUnknown(TestItem.KeccakB);
            Assert.AreEqual(2 * oneKeccakSize + startSize, trieStore.MemoryUsedByDirtyCache);
            trieStore.FindCachedOrUnknown(TestItem.KeccakB);
            Assert.AreEqual(2 * oneKeccakSize + startSize, trieStore.MemoryUsedByDirtyCache);
            trieStore.FindCachedOrUnknown(TestItem.KeccakC);
            Assert.AreEqual(3 * oneKeccakSize + startSize, trieStore.MemoryUsedByDirtyCache);
            trieStore.FindCachedOrUnknown(TestItem.KeccakD, false);
            Assert.AreEqual(3 * oneKeccakSize + startSize, trieStore.MemoryUsedByDirtyCache);
        }