public async Task RequestBlock_SyncStateIsNotFinished_Test()
        {
            _syncStateProvider.SetSyncTarget(0);

            var      peer     = _peerPool.GetPeers(true).First();
            var      pubKey   = peer.Info.Pubkey;
            Metadata metadata = new Metadata {
                { GrpcConstants.PubkeyMetadataKey, pubKey }
            };
            var context = BuildServerCallContext(metadata);
            var chain   = await _blockchainService.GetChainAsync();

            var reply = await _serverService.RequestBlock(new BlockRequest { Hash = chain.LongestChainHash }, context);

            Assert.NotNull(reply);
            Assert.Null(reply.Block);
        }
        public async Task StartSync_CurrentSyncStateIsNotUnInitialized_Test()
        {
            _syncStateProvider.SetSyncTarget(10);

            _peerPool.TryAddPeer(CreatePeer(15));
            _peerPool.TryAddPeer(CreatePeer(16));

            await _syncStateService.StartSyncAsync();

            _syncStateService.GetCurrentSyncTarget().ShouldBe(10);
        }
Beispiel #3
0
 private void SetSyncTarget(long value) => _syncStateProvider.SetSyncTarget(value);