public void AddTransactions_TransactionAlreadyInInblock_DoesNotAddTransactionToBlock() { var newOptions = new PosConsensusOptions() { MaxBlockWeight = 1500 }; this.ExecuteWithConsensusOptions(newOptions, () => { var chain = GenerateChainWithHeight(5, this.network, this.key); this.consensusLoop.Setup(c => c.Tip) .Returns(chain.GetBlock(5)); var transaction = CreateTransaction(this.network, this.key, 5, new Money(400 * 1000 * 1000), new Key(), new uint256(124124)); var txFee = new Money(1000); var entries = SetupTxMempool(chain, newOptions, txFee, transaction); var posBlockAssembler = new PosTestBlockAssembler(this.consensusLoop.Object, this.network, new MempoolSchedulerLock(), this.txMempool.Object, this.dateTimeProvider.Object, this.stakeChain.Object, this.stakeValidator.Object, chain.Tip, this.LoggerFactory.Object); posBlockAssembler.AddInBlockTxEntries(entries); var result = posBlockAssembler.AddTransactions(); Assert.Empty(result.Block.Transactions); Assert.Equal(0, result.Selected); Assert.Equal(0, result.Updated); }); }
public void AddTransactions_WithoutTransactionsInMempool_DoesNotAddEntriesToBlock() { var newOptions = new PosConsensusOptions() { MaxBlockWeight = 1500 }; this.ExecuteWithConsensusOptions(newOptions, () => { var chain = GenerateChainWithHeight(5, this.network, new Key()); this.consensusLoop.Setup(c => c.Tip) .Returns(chain.GetBlock(5)); var indexedTransactionSet = new TxMempool.IndexedTransactionSet(); this.txMempool.Setup(t => t.MapTx) .Returns(indexedTransactionSet); var posBlockAssembler = new PosTestBlockAssembler(this.consensusLoop.Object, this.network, new MempoolSchedulerLock(), this.txMempool.Object, this.dateTimeProvider.Object, this.stakeChain.Object, this.stakeValidator.Object, chain.Tip, this.LoggerFactory.Object); var result = posBlockAssembler.AddTransactions(); Assert.Empty(result.Block.Transactions); Assert.Equal(0, result.Selected); Assert.Equal(0, result.Updated); }); }
public void AddTransactions_TransactionNotInblock_AddsTransactionToBlock() { var newOptions = new PosConsensusOptions() { MaxBlockWeight = 1500 }; this.ExecuteWithConsensusOptions(newOptions, () => { ConcurrentChain chain = GenerateChainWithHeight(5, this.stratisTest, this.key); this.consensusLoop.Setup(c => c.Tip) .Returns(chain.GetBlock(5)); Transaction transaction = CreateTransaction(this.stratisTest, this.key, 5, new Money(400 * 1000 * 1000), new Key(), new uint256(124124)); var txFee = new Money(1000); SetupTxMempool(chain, newOptions, txFee, transaction); var posBlockAssembler = new PosTestBlockAssembler(this.consensusLoop.Object, this.stratisTest, new MempoolSchedulerLock(), this.mempool.Object, this.dateTimeProvider.Object, this.stakeChain.Object, this.stakeValidator.Object, this.LoggerFactory.Object); (Block Block, int Selected, int Updated)result = posBlockAssembler.AddTransactions(); Assert.NotEmpty(result.Block.Transactions); Assert.Equal(transaction.ToHex(), result.Block.Transactions[0].ToHex()); Assert.Equal(1, result.Selected); Assert.Equal(0, result.Updated); }); }
public void AddTransactions_TransactionAlreadyInInblock_DoesNotAddTransactionToBlock() { var newOptions = new PosConsensusOptions(); this.ExecuteWithConsensusOptions(newOptions, () => { ConcurrentChain chain = GenerateChainWithHeight(5, this.stratisTest, this.key); this.consensusManager.Setup(c => c.Tip) .Returns(chain.GetBlock(5)); Transaction transaction = CreateTransaction(this.stratisTest, this.key, 5, new Money(400 * 1000 * 1000), new Key(), new uint256(124124)); var txFee = new Money(1000); TxMempoolEntry[] entries = SetupTxMempool(chain, newOptions, txFee, transaction); var posBlockAssembler = new PosTestBlockAssembler(this.consensusManager.Object, this.stratisTest, new MempoolSchedulerLock(), this.mempool.Object, this.minerSettings, this.dateTimeProvider.Object, this.stakeChain.Object, this.stakeValidator.Object, this.LoggerFactory.Object); posBlockAssembler.AddInBlockTxEntries(entries); (Block Block, int Selected, int Updated)result = posBlockAssembler.AddTransactions(); Assert.Empty(result.Block.Transactions); Assert.Equal(0, result.Selected); Assert.Equal(0, result.Updated); }); }
public void AddTransactions_WithoutTransactionsInMempool_DoesNotAddEntriesToBlock() { var newOptions = new PosConsensusOptions(); this.ExecuteWithConsensusOptions(newOptions, () => { ConcurrentChain chain = GenerateChainWithHeight(5, this.stratisTest, new Key()); this.consensusManager.Setup(c => c.Tip) .Returns(chain.GetBlock(5)); var indexedTransactionSet = new TxMempool.IndexedTransactionSet(); this.mempool.Setup(t => t.MapTx) .Returns(indexedTransactionSet); var posBlockAssembler = new PosTestBlockAssembler(this.consensusManager.Object, this.stratisTest, new MempoolSchedulerLock(), this.mempool.Object, this.minerSettings, this.dateTimeProvider.Object, this.stakeChain.Object, this.stakeValidator.Object, this.LoggerFactory.Object); (Block Block, int Selected, int Updated)result = posBlockAssembler.AddTransactions(); Assert.Empty(result.Block.Transactions); Assert.Equal(0, result.Selected); Assert.Equal(0, result.Updated); }); }
public void AddTransactions_TransactionNotInblock_AddsTransactionToBlock() { var newOptions = new PosConsensusOptions(); this.ExecuteWithConsensusOptions(newOptions, () => { ConcurrentChain chain = GenerateChainWithHeight(5, this.stratisTest, this.key); this.consensusManager.Setup(c => c.Tip) .Returns(chain.GetBlock(5)); Mock <IConsensusRuleEngine> consensusRuleEngine = new Mock <IConsensusRuleEngine>(); consensusRuleEngine.Setup(s => s.GetRule <PosFutureDriftRule>()).Returns(new PosFutureDriftRule()); this.consensusManager.Setup(c => c.ConsensusRules) .Returns(consensusRuleEngine.Object); Transaction transaction = CreateTransaction(this.stratisTest, this.key, 5, new Money(400 * 1000 * 1000), new Key(), new uint256(124124)); this.dateTimeProvider.Setup(s => s.GetAdjustedTimeAsUnixTimestamp()).Returns(transaction.Time); var txFee = new Money(1000); SetupTxMempool(chain, newOptions, txFee, transaction); var posBlockAssembler = new PosTestBlockAssembler(this.consensusManager.Object, this.stratisTest, new MempoolSchedulerLock(), this.mempool.Object, this.minerSettings, this.dateTimeProvider.Object, this.stakeChain.Object, this.stakeValidator.Object, this.LoggerFactory.Object); posBlockAssembler.CreateCoinBase(new ChainedHeader(this.stratisTest.GetGenesis().Header, this.stratisTest.GetGenesis().Header.GetHash(), 0), new KeyId().ScriptPubKey); (Block Block, int Selected, int Updated)result = posBlockAssembler.AddTransactions(); Assert.NotEmpty(result.Block.Transactions); Assert.Equal(transaction.ToHex(), result.Block.Transactions[1].ToHex()); Assert.Equal(1, result.Selected); Assert.Equal(0, result.Updated); }); }