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 Pre_init_trie_cache_160()
        {
            MemCountingCache memCountingCache
                = new MemCountingCache(1024 * 1024, string.Empty);

            return(memCountingCache);
        }
Exemplo n.º 3
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.º 4
0
        public MemCountingCache With_2_items_cache_504()
        {
            MemCountingCache cache
                = new MemCountingCache(1024 * 1024, string.Empty);

            cache.Set(TestItem.KeccakA, new byte[0]);
            cache.Set(TestItem.KeccakB, new byte[0]);
            return(cache);
        }
Exemplo n.º 5
0
        public void Cache_post_capacity_growth_memory_calculated_correctly()
        {
            MemCountingCache cache = new MemCountingCache(1024, 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.KeccakD, new byte[0]);
            cache.MemorySize.Should().Be(824);
        }
Exemplo n.º 6
0
        public MemCountingCache Post_dictionary_growth_cache_824_and_136_lost()
        {
            MemCountingCache cache
                = new MemCountingCache(1024 * 1024, 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.KeccakD, new byte[0]);
            return(cache);
        }
Exemplo n.º 7
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();
        }
Exemplo n.º 8
0
        public void Cache_initial_memory_calculated_correctly()
        {
            MemCountingCache cache = new MemCountingCache(1024, string.Empty);

            cache.MemorySize.Should().Be(160);
        }