77using Blockcore . Base ;
88using Blockcore . Configuration ;
99using Blockcore . Connection ;
10+ using Blockcore . Consensus ;
1011using Blockcore . Controllers ;
1112using Blockcore . Controllers . Models ;
1213using Blockcore . Interfaces ;
@@ -45,6 +46,7 @@ public class NodeControllerTest : LogsTestBase
4546 private readonly Mock < IPooledTransaction > pooledTransaction ;
4647 private readonly Mock < IAsyncProvider > asyncProvider ;
4748 private readonly Mock < ISelfEndpointTracker > selfEndpointTracker ;
49+ private readonly Mock < IConsensusManager > consensusManager ;
4850
4951 private NodeController controller ;
5052
@@ -68,7 +70,12 @@ public NodeControllerTest()
6870 this . pooledTransaction = new Mock < IPooledTransaction > ( ) ;
6971 this . asyncProvider = new Mock < IAsyncProvider > ( ) ;
7072 this . selfEndpointTracker = new Mock < ISelfEndpointTracker > ( ) ;
73+ this . consensusManager = new Mock < IConsensusManager > ( ) ;
7174
75+ this . CreateNewController ( ) ;
76+ }
77+
78+ private void CreateNewController ( ) {
7279 this . controller = new NodeController (
7380 this . chainIndexer ,
7481 this . chainState . Object ,
@@ -84,7 +91,8 @@ public NodeControllerTest()
8491 this . getUnspentTransaction . Object ,
8592 this . networkDifficulty . Object ,
8693 this . pooledGetUnspentTransaction . Object ,
87- this . pooledTransaction . Object ) ;
94+ this . pooledTransaction . Object ,
95+ this . consensusManager . Object ) ;
8896 }
8997
9098 [ Fact ]
@@ -126,10 +134,8 @@ public async Task GetRawTransactionAsync_TransactionCannotBeFound_ReturnsNullAsy
126134 this . blockStore . Setup ( b => b . GetTransactionById ( txId ) )
127135 . Returns ( ( Transaction ) null )
128136 . Verifiable ( ) ;
129- this . controller = new NodeController ( this . chainIndexer , this . chainState . Object ,
130- this . connectionManager . Object , this . dateTimeProvider . Object , this . fullNode . Object ,
131- this . LoggerFactory . Object , this . nodeSettings , this . network , this . asyncProvider . Object , this . selfEndpointTracker . Object , this . blockStore . Object , this . getUnspentTransaction . Object ,
132- this . networkDifficulty . Object , this . pooledGetUnspentTransaction . Object , this . pooledTransaction . Object ) ;
137+
138+ this . CreateNewController ( ) ;
133139
134140 string txid = txId . ToString ( ) ;
135141 bool verbose = false ;
@@ -150,10 +156,9 @@ public async Task GetRawTransactionAsync_TransactionNotInPooledTransaction_Retur
150156 Transaction transaction = this . CreateTransaction ( ) ;
151157 this . blockStore . Setup ( b => b . GetTransactionById ( txId ) )
152158 . Returns ( transaction ) ;
153- this . controller = new NodeController ( this . chainIndexer , this . chainState . Object ,
154- this . connectionManager . Object , this . dateTimeProvider . Object , this . fullNode . Object ,
155- this . LoggerFactory . Object , this . nodeSettings , this . network , this . asyncProvider . Object , this . selfEndpointTracker . Object , this . blockStore . Object , this . getUnspentTransaction . Object ,
156- this . networkDifficulty . Object , this . pooledGetUnspentTransaction . Object , this . pooledTransaction . Object ) ;
159+
160+ this . CreateNewController ( ) ;
161+
157162 string txid = txId . ToString ( ) ;
158163 bool verbose = false ;
159164
@@ -189,10 +194,9 @@ public async Task GetRawTransactionAsync_PooledTransactionServiceNotAvailable_Re
189194 Transaction transaction = this . CreateTransaction ( ) ;
190195 this . blockStore . Setup ( b => b . GetTransactionById ( txId ) )
191196 . Returns ( transaction ) ;
192- this . controller = new NodeController ( this . chainIndexer , this . chainState . Object ,
193- this . connectionManager . Object , this . dateTimeProvider . Object , this . fullNode . Object ,
194- this . LoggerFactory . Object , this . nodeSettings , this . network , this . asyncProvider . Object , this . selfEndpointTracker . Object , this . blockStore . Object , this . getUnspentTransaction . Object ,
195- this . networkDifficulty . Object , this . pooledGetUnspentTransaction . Object , this . pooledTransaction . Object ) ;
197+
198+ this . CreateNewController ( ) ;
199+
196200 string txid = txId . ToString ( ) ;
197201 bool verbose = false ;
198202
@@ -210,10 +214,9 @@ public async Task GetRawTransactionAsync_PooledTransactionAndBlockStoreServiceNo
210214 this . blockStore . Setup ( f => f . GetTransactionById ( txId ) )
211215 . Returns ( ( Transaction ) null )
212216 . Verifiable ( ) ;
213- this . controller = new NodeController ( this . chainIndexer , this . chainState . Object ,
214- this . connectionManager . Object , this . dateTimeProvider . Object , this . fullNode . Object ,
215- this . LoggerFactory . Object , this . nodeSettings , this . network , this . asyncProvider . Object , this . selfEndpointTracker . Object , this . blockStore . Object , this . getUnspentTransaction . Object ,
216- this . networkDifficulty . Object , this . pooledGetUnspentTransaction . Object , this . pooledTransaction . Object ) ;
217+
218+ this . CreateNewController ( ) ;
219+
217220 string txid = txId . ToString ( ) ;
218221 bool verbose = false ;
219222
@@ -231,10 +234,7 @@ public void DecodeRawTransaction_ReturnsTransaction()
231234 . ReturnsAsync ( ( Transaction ) null ) ;
232235 Transaction transaction = this . CreateTransaction ( ) ;
233236
234- this . controller = new NodeController ( this . chainIndexer , this . chainState . Object ,
235- this . connectionManager . Object , this . dateTimeProvider . Object , this . fullNode . Object ,
236- this . LoggerFactory . Object , this . nodeSettings , this . network , this . asyncProvider . Object , this . selfEndpointTracker . Object , this . blockStore . Object , this . getUnspentTransaction . Object ,
237- this . networkDifficulty . Object , this . pooledGetUnspentTransaction . Object , this . pooledTransaction . Object ) ;
237+ this . CreateNewController ( ) ;
238238
239239 var json = ( JsonResult ) this . controller . DecodeRawTransaction ( new DecodeRawTransactionModel ( ) { RawHex = transaction . ToHex ( ) } ) ;
240240 var resultModel = ( TransactionVerboseModel ) json . Value ;
@@ -403,11 +403,11 @@ public async Task GetTxOutAsync_NotIncludeInMempool_UnspentTransactionNotFound_R
403403 public async Task GetTxOutAsync_NotIncludeInMempool_GetUnspentTransactionNotAvailable_ReturnsNullAsync ( )
404404 {
405405 var txId = new uint256 ( 1243124 ) ;
406- this . controller = new NodeController ( this . chainIndexer , this . chainState . Object ,
407- this . connectionManager . Object , this . dateTimeProvider . Object , this . fullNode . Object ,
408- this . LoggerFactory . Object , this . nodeSettings , this . network , this . asyncProvider . Object , this . selfEndpointTracker . Object , this . blockStore . Object , this . getUnspentTransaction . Object ,
409- this . networkDifficulty . Object , this . pooledGetUnspentTransaction . Object , this . pooledTransaction . Object ) ;
406+
407+ this . CreateNewController ( ) ;
408+
410409 string txid = txId . ToString ( ) ;
410+
411411 uint vout = 0 ;
412412 bool includeMemPool = false ;
413413
@@ -423,10 +423,9 @@ public async Task GetTxOutAsync_IncludeMempool_UnspentTransactionNotFound_Return
423423 this . pooledGetUnspentTransaction . Setup ( s => s . GetUnspentTransactionAsync ( new OutPoint ( txId , 0 ) ) )
424424 . ReturnsAsync ( ( UnspentOutput ) null )
425425 . Verifiable ( ) ;
426- this . controller = new NodeController ( this . chainIndexer , this . chainState . Object ,
427- this . connectionManager . Object , this . dateTimeProvider . Object , this . fullNode . Object ,
428- this . LoggerFactory . Object , this . nodeSettings , this . network , this . asyncProvider . Object , this . selfEndpointTracker . Object , this . blockStore . Object , this . getUnspentTransaction . Object ,
429- this . networkDifficulty . Object , this . pooledGetUnspentTransaction . Object , this . pooledTransaction . Object ) ;
426+
427+ this . CreateNewController ( ) ;
428+
430429 string txid = txId . ToString ( ) ;
431430 uint vout = 0 ;
432431 bool includeMemPool = true ;
@@ -441,10 +440,9 @@ public async Task GetTxOutAsync_IncludeMempool_UnspentTransactionNotFound_Return
441440 public async Task GetTxOutAsync_IncludeMempool_PooledGetUnspentTransactionNotAvailable_UnspentTransactionNotFound_ReturnsNullAsync ( )
442441 {
443442 var txId = new uint256 ( 1243124 ) ;
444- this . controller = new NodeController ( this . chainIndexer , this . chainState . Object ,
445- this . connectionManager . Object , this . dateTimeProvider . Object , this . fullNode . Object ,
446- this . LoggerFactory . Object , this . nodeSettings , this . network , this . asyncProvider . Object , this . selfEndpointTracker . Object , this . blockStore . Object , this . getUnspentTransaction . Object ,
447- this . networkDifficulty . Object , this . pooledGetUnspentTransaction . Object , this . pooledTransaction . Object ) ;
443+
444+ this . CreateNewController ( ) ;
445+
448446 string txid = txId . ToString ( ) ;
449447 uint vout = 0 ;
450448 bool includeMemPool = true ;
@@ -463,10 +461,9 @@ public async Task GetTxOutAsync_NotIncludeInMempool_UnspentTransactionFound_Retu
463461 this . getUnspentTransaction . Setup ( s => s . GetUnspentTransactionAsync ( new OutPoint ( txId , 0 ) ) )
464462 . ReturnsAsync ( unspentOutputs )
465463 . Verifiable ( ) ;
466- this . controller = new NodeController ( this . chainIndexer , this . chainState . Object ,
467- this . connectionManager . Object , this . dateTimeProvider . Object , this . fullNode . Object ,
468- this . LoggerFactory . Object , this . nodeSettings , this . network , this . asyncProvider . Object , this . selfEndpointTracker . Object , this . blockStore . Object , this . getUnspentTransaction . Object ,
469- this . networkDifficulty . Object , this . pooledGetUnspentTransaction . Object , this . pooledTransaction . Object ) ;
464+
465+ this . CreateNewController ( ) ;
466+
470467 string txid = txId . ToString ( ) ;
471468 uint vout = 0 ;
472469 bool includeMemPool = false ;
@@ -491,10 +488,9 @@ public async Task GetTxOutAsync_IncludeInMempool_UnspentTransactionFound_Returns
491488 this . pooledGetUnspentTransaction . Setup ( s => s . GetUnspentTransactionAsync ( new OutPoint ( txId , 0 ) ) )
492489 . ReturnsAsync ( unspentOutputs )
493490 . Verifiable ( ) ;
494- this . controller = new NodeController ( this . chainIndexer , this . chainState . Object ,
495- this . connectionManager . Object , this . dateTimeProvider . Object , this . fullNode . Object ,
496- this . LoggerFactory . Object , this . nodeSettings , this . network , this . asyncProvider . Object , this . selfEndpointTracker . Object , this . blockStore . Object , this . getUnspentTransaction . Object ,
497- this . networkDifficulty . Object , this . pooledGetUnspentTransaction . Object , this . pooledTransaction . Object ) ;
491+
492+ this . CreateNewController ( ) ;
493+
498494 string txid = txId . ToString ( ) ;
499495 uint vout = 0 ;
500496 bool includeMemPool = true ;
0 commit comments