Exemplo n.º 1
0
        public void Cache_post_init_memory_calculated_correctly()
        {
            MemCountingCache cache = new MemCountingCache(1024, string.Empty);

            cache.Set(Keccak.Zero, new byte[0]);
            cache.MemorySize.Should().Be(400);
        }
Exemplo n.º 2
0
        public MemCountingCache Post_init_trie_cache_with_item_400()
        {
            MemCountingCache cache
                = new MemCountingCache(1024 * 1024, string.Empty);

            cache.Set(Keccak.Zero, new byte[0]);
            return(cache);
        }
Exemplo n.º 3
0
        public void Limit_by_memory_works_fine_wth_deletes()
        {
            MemCountingCache cache = new MemCountingCache(800, string.Empty);

            cache.Set(TestItem.KeccakA, new byte[0]);
            cache.Set(TestItem.KeccakB, new byte[0]);
            cache.Set(TestItem.KeccakC, new byte[0]);

            cache.Set(TestItem.KeccakA, null);

            cache.MemorySize.Should().Be(504);
            cache.Get(TestItem.KeccakA).Should().BeNull();

            cache.Set(TestItem.KeccakD, new byte[0]);
            cache.MemorySize.Should().Be(608);
            cache.Get(TestItem.KeccakB).Should().NotBeNull();
            cache.Get(TestItem.KeccakD).Should().NotBeNull();
        }