public void ReceiveLeaders_Should_Push_Items_Into_The_LeaderProvidersStream() { this.leaderReceiver = new LeaderReceiver(this.loggerFactory); const int LeaderCount = 3; var receivedLeaderCount = 0; this.streamSubscription = this.leaderReceiver.LeaderProvidersStream.Subscribe( _ => { receivedLeaderCount++; }); this.leaderProvider.CurrentLeader.Returns(new NBitcoin.PubKey(PublicKey)); for (var i = 0; i < LeaderCount; i++) { this.leaderReceiver.ReceiveLeader(this.leaderProvider); } receivedLeaderCount.Should().Be(LeaderCount); var logMsg = string.Format("Received federated leader: {0}", PublicKey); this.logger.Received(receivedLeaderCount).Log(LogLevel.Debug, Arg.Any <EventId>(), Arg.Is <object>(o => o.ToString() == logMsg), null, Arg.Any <Func <object, Exception, string> >()); }
public FederationGatewayControllerTests() { this.network = FederatedPegNetwork.NetworksSelector.Regtest(); this.loggerFactory = Substitute.For <ILoggerFactory>(); this.logger = Substitute.For <ILogger>(); this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger); this.maturedBlockReceiver = Substitute.For <IMaturedBlockReceiver>(); this.maturedBlocksRequester = Substitute.For <IMaturedBlocksRequester>(); this.maturedBlocksProvider = Substitute.For <IMaturedBlocksProvider>(); this.leaderProvider = Substitute.For <ILeaderProvider>(); this.depositExtractor = Substitute.For <IDepositExtractor>(); this.leaderReceiver = Substitute.For <ILeaderReceiver>(); }
public FederationGatewayControllerTests() { this.network = FederatedPegNetwork.NetworksSelector.Regtest(); this.loggerFactory = Substitute.For <ILoggerFactory>(); this.logger = Substitute.For <ILogger>(); this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger); this.leaderProvider = Substitute.For <ILeaderProvider>(); this.depositExtractor = Substitute.For <IDepositExtractor>(); this.leaderReceiver = Substitute.For <ILeaderReceiver>(); this.consensusManager = Substitute.For <IConsensusManager>(); this.federationGatewaySettings = Substitute.For <IFederationGatewaySettings>(); this.federationWalletManager = Substitute.For <IFederationWalletManager>(); this.federationManager = new FederationManager(NodeSettings.Default(this.network), this.network, this.loggerFactory); }
public SignedMultisigTransactionBroadcasterTests() { this.loggerFactory = Substitute.For <ILoggerFactory>(); this.logger = Substitute.For <ILogger>(); this.leaderReceiver = Substitute.For <ILeaderReceiver>(); this.federationGatewaySettings = Substitute.For <IFederationGatewaySettings>(); this.loggerFactory.CreateLogger(null).ReturnsForAnyArgs(this.logger); this.leaderReceiverSubscription = Substitute.For <IDisposable>(); this.store = Substitute.For <ICrossChainTransferStore>(); this.broadcasterManager = Substitute.For <IBroadcasterManager>(); this.leaderProvider = Substitute.For <ILeaderProvider>(); // Setup MempoolManager. this.dateTimeProvider = Substitute.For <IDateTimeProvider>(); this.nodeSettings = new NodeSettings(networksSelector: FederatedPegNetwork.NetworksSelector, protocolVersion: NBitcoin.Protocol.ProtocolVersion.ALT_PROTOCOL_VERSION); this.mempoolSettings = new MempoolSettings(this.nodeSettings) { MempoolExpiry = MempoolValidator.DefaultMempoolExpiry }; this.blockPolicyEstimator = new BlockPolicyEstimator( this.mempoolSettings, this.loggerFactory, this.nodeSettings); this.txMempool = new TxMempool( this.dateTimeProvider, this.blockPolicyEstimator, this.loggerFactory, this.nodeSettings); this.mempoolValidator = Substitute.For <IMempoolValidator>(); this.mempoolPersistence = Substitute.For <IMempoolPersistence>(); this.coinView = Substitute.For <ICoinView>(); this.mempoolManager = new MempoolManager( new MempoolSchedulerLock(), this.txMempool, this.mempoolValidator, this.dateTimeProvider, this.mempoolSettings, this.mempoolPersistence, this.coinView, this.loggerFactory, this.nodeSettings.Network); }
public FederationGatewayController( ILoggerFactory loggerFactory, Network network, ILeaderProvider leaderProvider, IMaturedBlocksProvider maturedBlocksProvider, ILeaderReceiver leaderReceiver, IFederationGatewaySettings federationGatewaySettings, IFederationWalletManager federationWalletManager, FederationManager federationManager = null) { this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.network = network; this.leaderProvider = leaderProvider; this.maturedBlocksProvider = maturedBlocksProvider; this.leaderReceiver = leaderReceiver; this.federationGatewaySettings = federationGatewaySettings; this.federationWalletManager = federationWalletManager; this.federationManager = federationManager; }
public FederationGatewayController( ILoggerFactory loggerFactory, IMaturedBlockReceiver maturedBlockReceiver, IMaturedBlocksRequester maturedBlocksRequester, ILeaderProvider leaderProvider, ConcurrentChain chain, IMaturedBlocksProvider maturedBlocksProvider, IDepositExtractor depositExtractor, ILeaderReceiver leaderReceiver) { this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.maturedBlockReceiver = maturedBlockReceiver; this.maturedBlocksRequester = maturedBlocksRequester; this.leaderProvider = leaderProvider; this.chain = chain; this.maturedBlocksProvider = maturedBlocksProvider; this.depositExtractor = depositExtractor; this.leaderReceiver = leaderReceiver; }
public SignedMultisigTransactionBroadcaster(ILoggerFactory loggerFactory, ICrossChainTransferStore store, ILeaderReceiver leaderReceiver, IFederationGatewaySettings settings, MempoolManager mempoolManager, IBroadcasterManager broadcasterManager) { Guard.NotNull(loggerFactory, nameof(loggerFactory)); Guard.NotNull(store, nameof(store)); Guard.NotNull(leaderReceiver, nameof(leaderReceiver)); Guard.NotNull(settings, nameof(settings)); Guard.NotNull(mempoolManager, nameof(mempoolManager)); Guard.NotNull(broadcasterManager, nameof(broadcasterManager)); this.logger = loggerFactory.CreateLogger(this.GetType().FullName); this.store = store; this.publicKey = settings.PublicKey; this.mempoolManager = mempoolManager; this.broadcasterManager = broadcasterManager; this.leaderReceiverSubscription = leaderReceiver.LeaderProvidersStream.Subscribe(async m => await BroadcastTransactionsAsync(m).ConfigureAwait(false)); this.logger.LogDebug("Subscribed to {0}", nameof(leaderReceiver), nameof(leaderReceiver.LeaderProvidersStream)); }