Exemplo n.º 1
0
        public void Capacity_grwoth_and_shrinkage()
        {
            StateDb db = new StateDb(new MemDb());

            for (int i = 0; i < 16; i++)
            {
                _hash1 = Keccak.Compute(_hash1.Bytes);
                db.Set(_hash1, _bytes1);
            }

            db.Restore(-1);

            byte[] getResult = db.Get(_hash1);
            Assert.AreEqual(null, getResult);

            for (int i = 0; i < 16; i++)
            {
                _hash1 = Keccak.Compute(_hash1.Bytes);
                db.Set(_hash1, _bytes1);
            }

            db.Commit();

            getResult = db.Get(_hash1);
            Assert.AreEqual(_bytes1, getResult);
        }
Exemplo n.º 2
0
        public void Set_restore_get()
        {
            StateDb db = new StateDb(new MemDb());

            db.Set(_hash1, _bytes1);
            db.Restore(-1);
            byte[] getResult = db.Get(_hash1);
            Assert.AreEqual(null, getResult);
        }
Exemplo n.º 3
0
        public void Restore_in_the_middle()
        {
            StateDb db = new StateDb(new MemDb());

            db.Set(_hash1, _bytes1);
            int snapshot = db.TakeSnapshot();

            db.Set(_hash2, _bytes2);
            db.Restore(snapshot);
            byte[] getResult = db.Get(_hash2);
            Assert.IsNull(getResult);
        }