示例#1
0
        public void TestCachedFind_Empty()
        {
            var snapshot = TestBlockchain.GetTestSnapshot();
            var storages = snapshot.CreateSnapshot();
            var cache    = new ClonedCache(storages);

            cache.Add
            (
                new StorageKey()
            {
                Key = new byte[] { 0x00, 0x02 }, Id = 0
            },
                new StorageItem()
            {
                Value = new byte[] { }
            }
            );
            cache.Add
            (
                new StorageKey()
            {
                Key = new byte[] { 0x01, 0x02 }, Id = 0
            },
                new StorageItem()
            {
                Value = new byte[] { }
            }
            );

            CollectionAssert.AreEqual(
                cache.Find(new byte[5]).Select(u => u.Key.Key[1]).ToArray(),
                new byte[] { 0x02 }
                );
        }
示例#2
0
        public void TestAddInternal()
        {
            clonedCache.Add(new MyKey("key1"), new MyValue("value1"));
            clonedCache[new MyKey("key1")].Should().Be(new MyValue("value1"));

            clonedCache.Commit();
            myDataCache[new MyKey("key1")].Should().Be(new MyValue("value1"));
        }
示例#3
0
        public void TestAddInternal()
        {
            clonedCache.Add(new MyKey("key1"), new MyValue("value1"));
            clonedCache[new MyKey("key1")].Should().Be(new MyValue("value1"));

            clonedCache.Commit();
            Assert.IsTrue(myDataCache[new MyKey("key1")].Value.SequenceEqual(new MyValue("value1").Value));
        }
示例#4
0
        public void TestCachedFind_Last()
        {
            var snapshot = Blockchain.Singleton.GetSnapshot();
            var storages = snapshot.CreateSnapshot();
            var cache    = new ClonedCache(storages);

            storages.Add
            (
                new StorageKey()
            {
                Key = new byte[] { 0x00, 0x01 }, Id = 0
            },
                new StorageItem()
            {
                IsConstant = false, Value = new byte[] { }
            }
            );
            storages.Add
            (
                new StorageKey()
            {
                Key = new byte[] { 0x01, 0x01 }, Id = 0
            },
                new StorageItem()
            {
                IsConstant = false, Value = new byte[] { }
            }
            );
            cache.Add
            (
                new StorageKey()
            {
                Key = new byte[] { 0x00, 0x02 }, Id = 0
            },
                new StorageItem()
            {
                IsConstant = false, Value = new byte[] { }
            }
            );
            cache.Add
            (
                new StorageKey()
            {
                Key = new byte[] { 0x01, 0x02 }, Id = 0
            },
                new StorageItem()
            {
                IsConstant = false, Value = new byte[] { }
            }
            );
            CollectionAssert.AreEqual(cache.Find(new byte[5]).Select(u => u.Key.Key[1]).ToArray(),
                                      new byte[] { 0x01, 0x02 }
                                      );
        }