Beispiel #1
0
        public void Can_delete()
        {
            LruKeyCache <Address> cache = new LruKeyCache <Address>(Capacity, "test");

            cache.Set(_addresses[0]);
            cache.Delete(_addresses[0]);
            cache.Get(_addresses[0]).Should().BeFalse();
        }
Beispiel #2
0
        public void Can_reset()
        {
            LruKeyCache <Address> cache = new LruKeyCache <Address>(Capacity, "test");

            cache.Set(_addresses[0]);
            cache.Set(_addresses[0]);
            cache.Get(_addresses[0]).Should().BeTrue();
        }
Beispiel #3
0
        public void Beyond_capacity()
        {
            LruKeyCache <Address> cache = new LruKeyCache <Address>(Capacity, "test");

            for (int i = 0; i < Capacity * 2; i++)
            {
                cache.Set(_addresses[i]);
            }

            cache.Get(_addresses[Capacity]).Should().BeTrue();
        }
Beispiel #4
0
        private void VerifyPostSyncCleanUp()
        {
            lock (_dependencies)
            {
                if (_dependencies.Count != 0)
                {
                    if (_logger.IsError)
                    {
                        _logger.Error($"POSSIBLE FAST SYNC CORRUPTION | Dependencies hanging after the root node saved - count: {_dependencies.Count}, first: {_dependencies.Keys.First()}");
                    }
                }

                _dependencies = new Dictionary <Keccak, HashSet <DependentItem> >();
                _alreadySaved = new LruKeyCache <Keccak>(AlreadySavedCapacity, "saved nodes");
            }

            if (_pendingItems.Count != 0)
            {
                if (_logger.IsError)
                {
                    _logger.Error($"POSSIBLE FAST SYNC CORRUPTION | Nodes left after the root node saved - count: {_pendingItems.Count}");
                }
            }
        }
Beispiel #5
0
        public void Can_ask_before_first_set()
        {
            LruKeyCache <Address> cache = new LruKeyCache <Address>(Capacity, "test");

            cache.Get(_addresses[0]).Should().BeFalse();
        }