示例#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 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 }
                                      );
        }
示例#3
0
 public void Init()
 {
     myDataCache = new MyDataCache();
     clonedCache = new ClonedCache(myDataCache);
 }