public async Task FinishInitialSync_Test() { InitialSyncFinishedEvent eventData = null; _localEventBus.Subscribe <InitialSyncFinishedEvent>(d => { eventData = d; return(Task.CompletedTask); }); await _blockchainNodeContextService.FinishInitialSyncAsync(); eventData.ShouldNotBeNull(); }
public async Task Sync_Finished_Should_Launch_Event() { InitialSyncFinishedEvent eventData = null; _eventBus.Subscribe <InitialSyncFinishedEvent>(args => { eventData = args; return(Task.CompletedTask); }); await _syncStateService.StartSyncAsync(); eventData.ShouldNotBeNull(); }
public async Task StartSync_NoEnoughPeer_Test() { _peerPool.TryAddPeer(CreatePeer(0)); _peerPool.TryAddPeer(CreatePeer(16)); InitialSyncFinishedEvent eventData = null; _eventBus.Subscribe <InitialSyncFinishedEvent>(args => { eventData = args; return(Task.CompletedTask); }); await _syncStateService.StartSyncAsync(); _syncStateService.GetCurrentSyncTarget().ShouldBe(-1); eventData.ShouldNotBeNull(); }
public async Task UpdateSyncState_Test() { _peerPool.TryAddPeer(CreatePeer(15)); _peerPool.TryAddPeer(CreatePeer(16)); InitialSyncFinishedEvent eventData = null; _eventBus.Subscribe <InitialSyncFinishedEvent>(args => { eventData = args; return(Task.CompletedTask); }); await _syncStateService.StartSyncAsync(); _syncStateService.SyncState.ShouldBe(SyncState.Syncing); _syncStateService.GetCurrentSyncTarget().ShouldBe(15); await _syncStateService.UpdateSyncStateAsync(); _syncStateService.SyncState.ShouldBe(SyncState.Syncing); _syncStateService.GetCurrentSyncTarget().ShouldBe(15); for (var i = 0; i < 4; i++) { await _osTestHelper.MinedOneBlock(); } var chain = await _blockchainService.GetChainAsync(); await _blockchainService.SetIrreversibleBlockAsync(chain, _osTestHelper.BestBranchBlockList.Last().Height, _osTestHelper.BestBranchBlockList.Last().GetHash()); await _syncStateService.UpdateSyncStateAsync(); _syncStateService.SyncState.ShouldBe(SyncState.Finished); _syncStateService.GetCurrentSyncTarget().ShouldBe(-1); eventData.ShouldNotBeNull(); }
public async Task HandleEventAsync(InitialSyncFinishedEvent eventData) { await _crossChainService.FinishInitialSyncAsync(); }