public void transaction_is_addable_to_block_after_fill()
        {
            int chainId     = 5;
            var blockHeader = Build.A.BlockHeader.TestObject;
            var tx          = Build.A.GeneratedTransaction.TestObject;
            var timestamper = Substitute.For <ITimestamper>();
            var stateReader = Substitute.For <IStateReader>();

            UInt256 expectedNonce = 10;

            stateReader.GetNonce(blockHeader.StateRoot, tx.SenderAddress).Returns(expectedNonce);

            ulong expectedTimeStamp = 100;

            timestamper.EpochSeconds.Returns(expectedTimeStamp);

            var gasLimit      = 200;
            var innerTxSource = Substitute.For <ITxSource>();

            innerTxSource.GetTransactions(blockHeader, gasLimit).Returns(new[] { tx });

            var transactionFiller = new GeneratedTxSourceApprover(innerTxSource, new BasicWallet(Build.A.PrivateKey.TestObject), timestamper, stateReader, chainId);

            var txResult = transactionFiller.GetTransactions(blockHeader, gasLimit).First();

            txResult.IsSigned.Should().BeTrue();
            txResult.Nonce.Should().Be(expectedNonce);
            txResult.Hash.Should().Be(tx.CalculateHash());
            txResult.Timestamp.Should().Be(expectedTimeStamp);
        }
        protected override ITxSource CreateTxSourceForProducer(ReadOnlyTxProcessingEnv readOnlyTxProcessingEnv, ReadOnlyTransactionProcessorSource readOnlyTransactionProcessorSource)
        {
            IList <RandomContract> GetRandomContracts(
                IDictionary <long, Address> randomnessContractAddress,
                ITransactionProcessor transactionProcessor,
                IAbiEncoder abiEncoder,
                IReadOnlyTransactionProcessorSource txProcessorSource,
                Address nodeAddress) =>
            randomnessContractAddress
            .Select(kvp => new RandomContract(transactionProcessor,
                                              abiEncoder,
                                              kvp.Value,
                                              txProcessorSource,
                                              kvp.Key,
                                              nodeAddress))
            .ToArray();


            if (_context.ChainSpec == null)
            {
                throw new StepDependencyException(nameof(_context.ChainSpec));
            }
            if (_context.BlockTree == null)
            {
                throw new StepDependencyException(nameof(_context.BlockTree));
            }
            if (_context.NodeKey == null)
            {
                throw new StepDependencyException(nameof(_context.NodeKey));
            }

            IList <ITxSource> txSources = new List <ITxSource> {
                base.CreateTxSourceForProducer(readOnlyTxProcessingEnv, readOnlyTransactionProcessorSource)
            };
            bool needSigner = false;

            if (_context.ChainSpec.AuRa.RandomnessContractAddress?.Any() == true)
            {
                var randomContractTxSource = new RandomContractTxSource(
                    GetRandomContracts(_context.ChainSpec.AuRa.RandomnessContractAddress,
                                       readOnlyTxProcessingEnv.TransactionProcessor, _context.AbiEncoder,
                                       readOnlyTransactionProcessorSource,
                                       _context.NodeKey.Address),
                    new EciesCipher(_context.CryptoRandom),
                    _context.NodeKey,
                    _context.CryptoRandom);

                txSources.Insert(0, randomContractTxSource);
                needSigner = true;
            }

            ITxSource txSource = txSources.Count > 1 ? new CompositeTxSource(txSources.ToArray()) : txSources[0];

            if (needSigner)
            {
                txSource = new GeneratedTxSourceApprover(txSource, new BasicWallet(_context.NodeKey), _context.Timestamper, readOnlyTxProcessingEnv.StateReader, _context.BlockTree.ChainId);
            }

            var txPermissionFilter = GetTxPermissionFilter(readOnlyTxProcessingEnv, readOnlyTransactionProcessorSource);

            if (txPermissionFilter != null)
            {
                txSource = new TxFilterTxSource(txSource, txPermissionFilter);
            }

            return(txSource);
        }