public void BlockNotificationFeatureCallsNotifyOnStart() { var cancellationProvider = new FullNode.CancellationProvider { Cancellation = new CancellationTokenSource() }; var blockNotification = new Mock <BlockNotification>(new ConcurrentChain(), new BlockPullerStub(), new Signals()); var blockNotificationFeature = new BlockNotificationFeature(blockNotification.Object, new BlockNotificationStartHash(0), cancellationProvider); blockNotificationFeature.Start(); blockNotification.Verify(notif => notif.Notify(0, cancellationProvider.Cancellation.Token), Times.Once); }
public void BlockNotificationFeatureCallsNotifyOnStart() { var cancellationProvider = new FullNode.CancellationProvider { Cancellation = new CancellationTokenSource() }; var connectionManager = new Mock <ConnectionManager>(Network.Main, new Mock <NodeConnectionParameters>().Object, new Mock <NodeSettings>().Object); var chain = new Mock <ConcurrentChain>(); var chainState = new Mock <ChainBehavior.ChainState>(new Mock <FullNode>().Object); var blockPuller = new Mock <LookaheadBlockPuller>(chain.Object, connectionManager.Object); var blockNotification = new Mock <BlockNotification>(chain.Object, blockPuller.Object, new Signals()); var blockNotificationFeature = new BlockNotificationFeature(blockNotification.Object, cancellationProvider, connectionManager.Object, blockPuller.Object, chainState.Object, chain.Object); blockNotificationFeature.Start(); blockNotification.Verify(notif => notif.Notify(cancellationProvider.Cancellation.Token), Times.Once); }
public void BlockNotificationFeatureCallsNotifyOnStart() { var connectionManager = new Mock <IConnectionManager>(); connectionManager.Setup(c => c.ConnectedNodes) .Returns(new NodesCollection()); connectionManager.Setup(c => c.NodeSettings) .Returns(NodeSettings.Default()); connectionManager.Setup(c => c.Parameters) .Returns(new NodeConnectionParameters()); var chain = new Mock <ConcurrentChain>(); var chainState = new Mock <ChainState>(new Mock <FullNode>().Object); var blockPuller = new Mock <LookaheadBlockPuller>(chain.Object, connectionManager.Object, new LoggerFactory()); var blockNotification = new Mock <BlockNotification>(chain.Object, blockPuller.Object, new Bitcoin.Signals.Signals(), new AsyncLoopFactory(new LoggerFactory()), new NodeLifetime()); var blockNotificationFeature = new BlockNotificationFeature(blockNotification.Object, connectionManager.Object, blockPuller.Object, chainState.Object, chain.Object); blockNotificationFeature.Start(); blockNotification.Verify(notif => notif.Notify(), Times.Once); }