public void Can_estimate_simple()
        {
            long        gasLimit = 100000;
            Transaction tx       = Build.A.Transaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA, 1).WithGasLimit(gasLimit).TestObject;
            Block       block    = Build.A.Block.WithNumber(1).WithTransactions(tx).WithGasLimit(gasLimit).TestObject;

            EstimateGasTracer tracer = new EstimateGasTracer();

            _transactionProcessor.CallAndRestore(tx, block.Header, tracer);

            Assert.AreEqual(21000, tracer.GasSpent);
            Assert.AreEqual(0, tracer.AdditionalGasRequired);
        }
Пример #2
0
 private void CallAndRestore(BlockReceiptsTracer tracer, Transaction tx, Block block)
 {
     tracer.StartNewBlockTrace(block);
     tracer.StartNewTxTrace(tx.Hash);
     _transactionProcessor.CallAndRestore(tx, block.Header, tracer);
     tracer.EndTxTrace();
 }
        public void Balance_is_not_changed_on_call_and_restore()
        {
            long        gasLimit = 100000;
            Transaction tx       = Build.A.Transaction.SignedAndResolved(_ethereumEcdsa, TestItem.PrivateKeyA, _isEip155Enabled).WithValue(1.Ether() - (UInt256)gasLimit).WithGasPrice(1).WithGasLimit(gasLimit).TestObject;
            Block       block    = Build.A.Block.WithNumber(1).WithTransactions(tx).WithGasLimit(gasLimit).TestObject;

            _transactionProcessor.CallAndRestore(tx, block.Header, NullTxTracer.Instance);

            _stateProvider.GetBalance(TestItem.PrivateKeyA.Address).Should().Be(1.Ether());
        }