public void SyncFromDate_ChainTipAfterGivenDate_StartsSyncFromHeightAtTime() { this.chain = WalletTestsHelpers.GenerateChainWithHeight(3, this.network); var lightWalletSyncManager = new LightWalletSyncManager(this.LoggerFactory.Object, this.walletManager.Object, this.chain, this.network, this.blockNotification.Object, this.signals.Object, this.nodeLifetime.Object, this.asyncLoopFactory.Object, this.consensusManager.Object); lightWalletSyncManager.SyncFromDate(this.chain.GetBlock(1).Header.BlockTime.DateTime); uint256 expectedBlockHash = this.chain.GetBlock(1).HashBlock; this.blockNotification.Verify(b => b.SyncFrom(expectedBlockHash)); Assert.Equal(lightWalletSyncManager.WalletTip.HashBlock, expectedBlockHash); this.walletManager.VerifySet(b => b.WalletTipHash = expectedBlockHash); }
public void SyncFromDate_EmptyChain_StartsAsyncLoopToCatchup() { this.chain = new ConcurrentChain(this.network); var lightWalletSyncManager = new LightWalletSyncManager(this.LoggerFactory.Object, this.walletManager.Object, this.chain, this.network, this.blockNotification.Object, this.signals.Object, this.nodeLifetime.Object, this.asyncLoopFactory.Object, this.consensusManager.Object); lightWalletSyncManager.SyncFromDate(new DateTime(2017, 1, 1)); this.asyncLoopFactory.Verify( a => a.RunUntil( "LightWalletSyncManager.SyncFromDate", It.IsAny <CancellationToken>(), It.IsAny <Func <bool> >(), It.IsAny <Action>(), It.IsAny <Action <Exception> >(), TimeSpans.FiveSeconds)); this.nodeLifetime.VerifyGet(n => n.ApplicationStopping); }
public void SyncFromDate_ChainTipBeforeGivenDate_StartsAsyncLoopToCatchupChain() { var asyncLoop = new Mock <IAsyncLoop>(); this.chain = WalletTestsHelpers.GenerateChainWithHeight(2, this.network); var lightWalletSyncManager = new LightWalletSyncManager(this.LoggerFactory.Object, this.walletManager.Object, this.chain, this.network, this.blockNotification.Object, this.signals.Object, this.nodeLifetime.Object, this.asyncLoopFactory.Object, this.consensusManager.Object); lightWalletSyncManager.SyncFromDate(this.chain.Tip.Header.BlockTime.DateTime.AddDays(15)); this.asyncLoopFactory.Verify( a => a.RunUntil( "LightWalletSyncManager.SyncFromDate", It.IsAny <CancellationToken>(), It.IsAny <Func <bool> >(), It.IsAny <Action>(), It.IsAny <Action <Exception> >(), TimeSpans.FiveSeconds)); this.nodeLifetime.VerifyGet(n => n.ApplicationStopping); }