Esempio n. 1
0
        public void ExecuteTransaction()
        {
            var transaction = CreateTransaction(100);

            var addr1 = transaction.Sender;
            var addr2 = transaction.Receiver;

            var           store    = new AccountsState();
            AccountsState newstore = null;

            store = store.Put(addr1, new AccountState(new BigInteger(200), 0));

            var processor = new TransactionProcessor();

            Assert.IsTrue(processor.ExecuteTransaction(transaction, store, ref newstore));

            Assert.IsNotNull(newstore);
            Assert.AreNotSame(store, newstore);

            Assert.AreEqual(new BigInteger(200), store.Get(addr1).Balance);
            Assert.AreEqual(BigInteger.Zero, store.Get(addr2).Balance);

            Assert.AreEqual(new BigInteger(100), newstore.Get(addr1).Balance);
            Assert.AreEqual(new BigInteger(100), newstore.Get(addr2).Balance);
        }
Esempio n. 2
0
        public void ExecuteTransactionWithoutFunds()
        {
            var transaction = CreateTransaction(100);

            var addr1 = transaction.Sender;
            var addr2 = transaction.Receiver;

            var           store    = new AccountsState();
            AccountsState newstore = null;

            var processor = new TransactionProcessor();

            Assert.IsFalse(processor.ExecuteTransaction(transaction, store, ref newstore));

            Assert.IsNull(newstore);

            Assert.AreEqual(BigInteger.Zero, store.Get(addr1).Balance);
            Assert.AreEqual(BigInteger.Zero, store.Get(addr2).Balance);
        }