예제 #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);
        }
예제 #2
0
        public void Double_set_get()
        {
            StateDb db = new StateDb(new MemDb());

            db.Set(_hash1, _bytes1);
            db.Set(_hash1, _bytes1);
            byte[] getResult = db.Get(_hash1);
            Assert.AreEqual(_bytes1, getResult);
        }
예제 #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);
        }
예제 #4
0
        public void Set_take_snapshot()
        {
            StateDb db = new StateDb(new MemDb());

            db.Set(_hash1, _bytes1);
            Assert.AreEqual(0, db.TakeSnapshot());
        }
예제 #5
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);
        }