예제 #1
0
        protected override void Load(ContainerBuilder builder)
        {
            var hashingAlgorithm = HashingAlgorithm.GetAlgorithmMetadata("keccak-256");

            builder.RegisterInstance(hashingAlgorithm).SingleInstance();
            builder.RegisterType <HashProvider>().As <IHashProvider>().SingleInstance();
        }
예제 #2
0
        public DaoTests()
        {
            _hashProvider = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));

            var initialisers = new IMapperInitializer[]
            {
                new ProtocolMessageMapperInitialiser(),
                new ConfidentialEntryMapperInitialiser(),
                new CandidateDeltaBroadcastMapperInitialiser(),
                new ProtocolErrorMessageMapperInitialiser(),
                new PeerIdMapperInitialiser(),
                new SigningContextMapperInitialiser(),
                new DeltaMapperInitialiser(),
                new CandidateDeltaBroadcastMapperInitialiser(),
                new DeltaDfsHashBroadcastMapperInitialiser(),
                new FavouriteDeltaBroadcastMapperInitialiser(),
                new CoinbaseEntryMapperInitialiser(),
                new PublicEntryMapperInitialiser(_hashProvider),
                new ConfidentialEntryMapperInitialiser(),
                new TransactionBroadcastMapperInitialiser(),
                new SignatureMapperInitialiser()
            };

            _mapperProvider = new MapperProvider(initialisers);
        }
        public void Init()
        {
            var hashProvider = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256"));

            _deltaVoter         = Substitute.For <IDeltaVoter>();
            _fakeChannelContext = Substitute.For <IChannelHandlerContext>();
            var logger = Substitute.For <ILogger>();

            _newHash    = hashProvider.ComputeUtf8MultiHash("newHash").ToCid();
            _prevHash   = hashProvider.ComputeUtf8MultiHash("prevHash").ToCid();
            _producerId = PeerIdHelper.GetPeerId("candidate delta producer");

            var peerRepository = Substitute.For <IPeerRepository>();

            peerRepository.GetPeersByIpAndPublicKey(Arg.Any <ByteString>(), Arg.Any <ByteString>()).Returns(new List <Lib.P2P.Models.Peer> {
                new Lib.P2P.Models.Peer()
            });

            var deltaIndexService = Substitute.For <IDeltaIndexService>();

            deltaIndexService.LatestDeltaIndex().Returns(new Lib.DAO.Ledger.DeltaIndexDao()
            {
                Cid = _prevHash, Height = 0
            });
            _candidateDeltaObserver = new CandidateDeltaObserver(_deltaVoter, deltaIndexService, new SyncState()
            {
                IsSynchronized = true
            }, peerRepository, hashProvider, logger);
        }
예제 #4
0
        public TestCycleEventProvider(ILogger logger = null)
        {
            Scheduler = new TestScheduler();

            var schedulerProvider = Substitute.For <ICycleSchedulerProvider>();

            schedulerProvider.Scheduler.Returns(Scheduler);

            var dateTimeProvider  = Substitute.For <IDateTimeProvider>();
            var deltaHashProvider = Substitute.For <IDeltaHashProvider>();

            var hashingAlgorithm = HashingAlgorithm.GetAlgorithmMetadata("blake2b-256");
            var hashingProvider  = new HashProvider(hashingAlgorithm);

            dateTimeProvider.UtcNow.Returns(_ => Scheduler.Now.DateTime);

            _cycleEventsProvider = new CycleEventsProvider(
                CycleConfiguration.Default, dateTimeProvider, schedulerProvider, deltaHashProvider,
                logger ?? Substitute.For <ILogger>());

            deltaHashProvider.GetLatestDeltaHash(Arg.Any <DateTime>())
            .Returns(ci => hashingProvider.ComputeMultiHash(
                         BitConverter.GetBytes(((DateTime)ci[0]).Ticks /
                                               (int)_cycleEventsProvider.Configuration.CycleDuration.Ticks)));

            _deltaUpdatesSubscription = PhaseChanges.Subscribe(p => CurrentPhase = p);
        }
예제 #5
0
        public static IDfsService GetTestDfs(IFileSystem fileSystem = default, string hashName = "keccak-256")
        {
            var nodeGuid         = Guid.NewGuid();
            var containerBuilder = new ContainerBuilder();

            if (fileSystem == null)
            {
                var testFileSystem = new TestDfsFileSystem();
                testFileSystem.Setup(TestContext.CurrentContext);
                fileSystem = testFileSystem.FileSystem;
            }

            containerBuilder.RegisterInstance(new PasswordManager(new TestPasswordReader(), new PasswordRegistry())).As <IPasswordManager>().SingleInstance();
            containerBuilder.RegisterInstance(fileSystem).As <IFileSystem>();
            containerBuilder.RegisterType <MigrationManager>().As <IMigrationManager>();
            containerBuilder.RegisterModule <HashingModule>();
            containerBuilder.RegisterInstance(new HashProvider(HashingAlgorithm.GetAlgorithmMetadata(hashName))).As <IHashProvider>();
            containerBuilder.RegisterType <KeyStoreService>().As <IKeyStoreService>().SingleInstance();
            containerBuilder.RegisterModule(new DfsModule());

            var container  = containerBuilder.Build();
            var scope      = container.BeginLifetimeScope(nodeGuid);
            var dfsService = scope.Resolve <IDfsService>();

            dfsService.ConfigApi.SetAsync(
                "Addresses.Swarm",
                JToken.FromObject(new[]
            {
                "/ip4/0.0.0.0/tcp/0"
            })
                ).Wait();

            return(dfsService);
        }
        public DaoTests()
        {
            _hashProvider = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));

            _mappers = new IMapperInitializer[]
            {
                new ProtocolMessageDao(),
                new ConfidentialEntryDao(),
                new CandidateDeltaBroadcastDao(),
                new ProtocolErrorMessageSignedDao(),
                new PeerIdDao(),
                new SigningContextDao(),
                new DeltaDao(),
                new CandidateDeltaBroadcastDao(),
                new DeltaDfsHashBroadcastDao(),
                new FavouriteDeltaBroadcastDao(),
                new CoinbaseEntryDao(),
                new PublicEntryDao(),
                new ConfidentialEntryDao(),
                new TransactionBroadcastDao(),
                new ContractEntryDao(),
                new SignatureDao(),
                new BaseEntryDao(),
            };

            var map = new MapperProvider(_mappers);

            map.Start();
        }
예제 #7
0
        public async Task Can_Receive_Query_Response_On_Observer()
        {
            var recipientPeerId = PeerIdHelper.GetPeerId();

            var hp            = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256"));
            var lastDeltaHash = hp.ComputeMultiHash(ByteUtil.GenerateRandomByteArray(32));

            var collection = new List <DeltaIndex>();

            //// this matches the fake mock
            for (uint x = 0; x < 10; x++)
            {
                var delta = new Delta
                {
                    PreviousDeltaDfsHash = lastDeltaHash.Digest.ToByteString()
                };

                var index = new DeltaIndex
                {
                    Height = 10,
                    Cid    = delta.ToByteString()
                };

                collection.Add(index);
                lastDeltaHash = hp.ComputeMultiHash(ByteUtil.GenerateRandomByteArray(32));
            }

            var deltaHistoryResponse = new PeerDeltaHistoryResponse(recipientPeerId, collection);

            _peerDeltaHistoryRequest.DeltaHistoryResponseMessageStreamer.OnNext(deltaHistoryResponse);
            var response = await _peerDeltaHistoryRequest.DeltaHistoryAsync(recipientPeerId).ConfigureAwait(false);

            response.DeltaCid.Count.Should().Be(10);
        }
예제 #8
0
        public void Init()
        {
            _hashProvider       = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256"));
            _cycleEventProvider = new TestCycleEventProvider();
            _deltaBuilder       = Substitute.For <IDeltaBuilder>();
            _deltaVoter         = Substitute.For <IDeltaVoter>();
            _deltaElector       = Substitute.For <IDeltaElector>();
            _deltaCache         = Substitute.For <IDeltaCache>();
            _deltaHub           = Substitute.For <IDeltaHub>();
            var deltaHashProvider = Substitute.For <IDeltaHashProvider>();
            var logger            = Substitute.For <ILogger>();

            _syncState = new SyncState {
                IsSynchronized = true, IsRunning = true
            };
            _ledger    = Substitute.For <ILedger>();
            _consensus = new Consensus(
                _deltaBuilder,
                _deltaVoter,
                _deltaElector,
                _deltaCache,
                _deltaHub,
                _cycleEventProvider,
                deltaHashProvider,
                logger);

            _consensus.StartProducing();
        }
예제 #9
0
        public CycleEventsProviderTests(ITestOutputHelper output)
        {
            var hashProvider = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));

            _output        = output;
            _testScheduler = new TestScheduler();

            _schedulerProvider = Substitute.For <ICycleSchedulerProvider>();
            _schedulerProvider.Scheduler.Returns(_testScheduler);
            _dateTimeProvider  = Substitute.For <IDateTimeProvider>();
            _deltaHashProvider = Substitute.For <IDeltaHashProvider>();
            _logger            = Substitute.For <ILogger>();

            _deltaHashProvider.GetLatestDeltaHash(Arg.Any <DateTime>())
            .Returns(hashProvider.ComputeUtf8MultiHash("test"));

            _dateTimeProvider.UtcNow.Returns(_ => _testScheduler.Now.DateTime);
            _cycleProvider = new CycleEventsProvider(CycleConfiguration.Default, _dateTimeProvider, _schedulerProvider,
                                                     _deltaHashProvider, _logger);

            _spy = Substitute.For <IObserver <IPhase> >();

            _stopWatch = _testScheduler.StartStopwatch();

            _subscription = _cycleProvider.PhaseChanges.Take(50)
                            .Subscribe(p =>
            {
                _output.WriteLine($"{_stopWatch.Elapsed.TotalSeconds} -- {p}");
                _spy.OnNext(p);
            }, () =>
            {
                _output.WriteLine($"completed after {_stopWatch.Elapsed.TotalSeconds:g}");
                _spy.OnCompleted();
            });
        }
예제 #10
0
        public DevDfsTests(ITestOutputHelper output) : base(output)
        {
            var hashProvider = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));

            _cancellationToken = new CancellationTokenSource(TimeSpan.FromSeconds(200)).Token;
            _dfs = new DevDfs(FileSystem, hashProvider);
        }
        public ConsensusTests()
        {
            var hashingAlgorithm = HashingAlgorithm.GetAlgorithmMetadata("blake2b-256");

            _hashProvider       = new HashProvider(hashingAlgorithm);
            _cycleEventProvider = new TestCycleEventProvider();
            _deltaBuilder       = Substitute.For <IDeltaBuilder>();
            _deltaVoter         = Substitute.For <IDeltaVoter>();
            _deltaElector       = Substitute.For <IDeltaElector>();
            _deltaCache         = Substitute.For <IDeltaCache>();
            _deltaHub           = Substitute.For <IDeltaHub>();
            var deltaHashProvider = Substitute.For <IDeltaHashProvider>();
            var logger            = Substitute.For <ILogger>();

            _consensus = new Consensus(
                _deltaBuilder,
                _deltaVoter,
                _deltaElector,
                _deltaCache,
                _deltaHub,
                _cycleEventProvider,
                deltaHashProvider,
                _hashProvider,
                logger);

            _consensus.StartProducing();
        }
예제 #12
0
        public DeltaBuilderTests()
        {
            _hashProvider = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));

            _random = new Random();

            _randomFactory = Substitute.For <IDeterministicRandomFactory>();
            _randomFactory.GetDeterministicRandomFromSeed(Arg.Any <byte[]>())
            .Returns(ci => new IsaacRandom(((byte[])ci[0]).ToHex()));

            _producerId   = PeerIdHelper.GetPeerId("producer");
            _peerSettings = _producerId.ToSubstitutedPeerSettings();

            _previousDeltaHash = _hashProvider.ComputeUtf8MultiHash("previousDelta").CreateCid();
            _zeroCoinbaseEntry = new CoinbaseEntry
            {
                Amount            = UInt256.Zero.ToUint256ByteString(),
                ReceiverPublicKey = _producerId.PublicKey.ToByteString()
            };

            _logger = Substitute.For <ILogger>();

            _cache = Substitute.For <IDeltaCache>();

            _dateTimeProvider = new DateTimeProvider();
        }
 public DeltaElectorTests()
 {
     _hashProvider           = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));
     _logger                 = Substitute.For <ILogger>();
     _cache                  = Substitute.For <IMemoryCache>();
     _deltaProducersProvider = Substitute.For <IDeltaProducersProvider>();
 }
예제 #14
0
 public DeltaDfsHashObserverTests()
 {
     _hashProvider       = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));
     _deltaHashProvider  = Substitute.For <IDeltaHashProvider>();
     _fakeChannelContext = Substitute.For <IChannelHandlerContext>();
     _logger             = Substitute.For <ILogger>();
 }
예제 #15
0
        public LedgerTests()
        {
            _testScheduler  = new TestScheduler();
            _fakeRepository = Substitute.For <IAccountRepository>();
            _hashProvider   = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256"));
            _mapperProvider = new TestMapperProvider();

            _logger            = Substitute.For <ILogger>();
            _mempool           = Substitute.For <IMempool <PublicEntryDao> >();
            _deltaHashProvider = Substitute.For <IDeltaHashProvider>();
            _receipts          = Substitute.For <ITransactionRepository>();
            _synchroniser      = Substitute.For <ISynchroniser>();
            _genesisHash       = _hashProvider.ComputeUtf8MultiHash("genesis").ToCid();
            _synchroniser.DeltaCache.GenesisHash.Returns(_genesisHash);
            _executor        = Substitute.For <IDeltaExecutor>();
            _stateProvider   = Substitute.For <IStateProvider>();
            _storageProvider = Substitute.For <IStorageProvider>();
            _cryptoContext   = new FfiWrapper();
            _signingContext  = new SigningContext
            {
                NetworkType   = NetworkType.Devnet,
                SignatureType = SignatureType.TransactionPublic
            };

            _deltaIndexService = new DeltaIndexService(new InMemoryRepository <DeltaIndexDao, string>());
        }
예제 #16
0
 public MempoolTests()
 {
     _hashProvider   = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));
     _memPool        = new Mempool(Substitute.For <IMempoolService <PublicEntryDao> >());
     _mapperProvider = new TestMapperProvider();
     _mempoolItem    = TransactionHelper
                       .GetPublicTransaction().PublicEntry
                       .ToDao <PublicEntry, PublicEntryDao>(_mapperProvider);
 }
예제 #17
0
        public SimpleRpcClient(IUserOutput userOutput,
                               IPasswordRegistry passwordRegistry,
                               X509Certificate2 certificate,
                               ILogger logger,
                               SigningContext signingContextProvider)
        {
            _logger      = logger;
            _certificate = certificate;

            var fileSystem = new FileSystem();

            var consolePasswordReader = new ConsolePasswordReader(userOutput, new ConsoleUserInput());
            var passwordManager       = new PasswordManager(consolePasswordReader, passwordRegistry);

            var cryptoContext = new FfiWrapper();

            var hashProvider = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256"));

            var peerSettings = Substitute.For <IPeerSettings>();

            peerSettings.NetworkType.Returns(signingContextProvider.NetworkType);

            var localKeyStore = new LocalKeyStore(passwordManager, cryptoContext, fileSystem, hashProvider, _logger);

            var keyRegistry = new KeyRegistry();
            var keySigner   = new KeySigner(localKeyStore, cryptoContext, keyRegistry);

            var memoryCacheOptions        = new MemoryCacheOptions();
            var memoryCache               = new MemoryCache(memoryCacheOptions);
            var changeTokenProvider       = new TtlChangeTokenProvider(10000);
            var messageCorrelationManager = new RpcMessageCorrelationManager(memoryCache, _logger, changeTokenProvider);
            var peerIdValidator           = new PeerIdValidator(cryptoContext);

            var nodeRpcClientChannelFactory =
                new RpcClientChannelFactory(keySigner, messageCorrelationManager, peerIdValidator, peerSettings);

            var eventLoopGroupFactoryConfiguration = new EventLoopGroupFactoryConfiguration
            {
                TcpClientHandlerWorkerThreads = 4
            };

            var tcpClientEventLoopGroupFactory = new TcpClientEventLoopGroupFactory(eventLoopGroupFactoryConfiguration);

            var handlers = new List <IRpcResponseObserver>
            {
                new BroadcastRawTransactionResponseObserver(_logger),
                new GetVersionResponseObserver(_logger)
            };

            _rpcClientFactory =
                new RpcClientFactory(nodeRpcClientChannelFactory, tcpClientEventLoopGroupFactory, handlers);

            //PeerId for RPC/TCP is currently redundant.
            var publicKey = keyRegistry.GetItemFromRegistry(KeyRegistryTypes.DefaultKey).GetPublicKey().Bytes;

            _senderPeerId = publicKey.BuildPeerIdFromPublicKey(IPAddress.Any, 1026);
        }
예제 #18
0
 public GetFileFromDfsObserverHandlerTests(ITestOutputHelper testOutput) : base(testOutput)
 {
     _hashProvider        = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));
     _logger              = Substitute.For <ILogger>();
     _fakeContext         = Substitute.For <IChannelHandlerContext>();
     _fileDownloadFactory = new DownloadFileTransferFactory(_logger);
     _logger              = Substitute.For <ILogger>();
     _dfs = Substitute.For <IDfs>();
 }
예제 #19
0
 //todo add unit tests
 public PeerSyncManagerUnitTests()
 {
     _hashProvider             = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256"));
     _peerService              = Substitute.For <IPeerService>();
     _peerClient               = Substitute.For <IPeerClient>();
     _peerRepository           = new PeerRepository(new InMemoryRepository <Peer, string>());
     _deltaHeightReplaySubject = new ReplaySubject <IObserverDto <ProtocolMessage> >(1);
     _peerService.MessageStream.Returns(_deltaHeightReplaySubject.AsObservable());
 }
예제 #20
0
        public void Init()
        {
            _hashProvider = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256"));

            _random = new Random(1);

            _randomFactory = Substitute.For <IDeterministicRandomFactory>();
            _randomFactory.GetDeterministicRandomFromSeed(Arg.Any <byte[]>())
            .Returns(ci => new IsaacRandom(((byte[])ci[0]).ToHex()));

            _producerId   = PeerIdHelper.GetPeerId("producer");
            _peerSettings = _producerId.ToSubstitutedPeerSettings();

            _previousDeltaHash = _hashProvider.ComputeUtf8MultiHash("previousDelta").ToCid();
            _zeroCoinbaseEntry = new CoinbaseEntry
            {
                Amount            = UInt256.Zero.ToUint256ByteString(),
                ReceiverPublicKey = _producerId.PublicKey.ToByteString()
            };

            _logger = Substitute.For <ILogger>();

            _cache = Substitute.For <IDeltaCache>();

            Delta previousDelta = new Delta();

            previousDelta.StateRoot = ByteString.CopyFrom(Keccak.EmptyTreeHash.Bytes);
            _cache.TryGetOrAddConfirmedDelta(Arg.Any <Cid>(), out Arg.Any <Delta>()).Returns(x =>
            {
                x[1] = previousDelta;
                return(true);
            });

            _dateTimeProvider = new DateTimeProvider();

            IDb             codeDb       = new MemDb();
            ISnapshotableDb stateDb      = new StateDb();
            ISpecProvider   specProvider = new CatalystSpecProvider();

            _cryptoContext = new FfiWrapper();
            _stateProvider = new StateProvider(stateDb, codeDb, LimboLogs.Instance);
            IStorageProvider  storageProvider = new StorageProvider(stateDb, _stateProvider, LimboLogs.Instance);
            KatVirtualMachine virtualMachine  = new KatVirtualMachine(_stateProvider,
                                                                      storageProvider,
                                                                      new StateUpdateHashProvider(),
                                                                      specProvider,
                                                                      new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256")),
                                                                      new FfiWrapper(),
                                                                      LimboLogs.Instance);

            _deltaExecutor = new DeltaExecutor(specProvider,
                                               _stateProvider,
                                               storageProvider,
                                               virtualMachine,
                                               _cryptoContext,
                                               _logger);
        }
예제 #21
0
        public DeltaDfsReaderTests()
        {
            var hashingAlgorithm = HashingAlgorithm.GetAlgorithmMetadata("blake2b-256");

            _hashProvider = new HashProvider(hashingAlgorithm);
            _dfs          = Substitute.For <IDfs>();
            _logger       = Substitute.For <ILogger>();

            _dfsReader = new DeltaDfsReader(_dfs, _logger);
        }
        public void GetMetadata_Alias()
        {
            var info = HashingAlgorithm.GetAlgorithmMetadata("id");

            Assert.NotNull(info);
            Assert.Equal("identity", info.Name);
            Assert.Equal(0, info.Code);
            Assert.Equal(0, info.DigestSize);
            Assert.NotNull(info.Hasher);
        }
        public void GetMetadata()
        {
            var info = HashingAlgorithm.GetAlgorithmMetadata("sha3-256");

            Assert.NotNull(info);
            Assert.Equal("sha3-256", info.Name);
            Assert.Equal(0x16, info.Code);
            Assert.Equal(256 / 8, info.DigestSize);
            Assert.NotNull(info.Hasher);
        }
예제 #24
0
 public DeltaElectorTests()
 {
     _testScheduler     = new TestScheduler();
     _hashProvider      = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));
     _logger            = Substitute.For <ILogger>();
     _reputationManager =
         new ReputationManager(new PeerRepository(new InMemoryRepository <Peer, string>()), _logger, _testScheduler);
     _cache = Substitute.For <IMemoryCache>();
     _deltaProducersProvider = Substitute.For <IDeltaProducersProvider>();
 }
예제 #25
0
        public void Init()
        {
            var hashingAlgorithm = HashingAlgorithm.GetAlgorithmMetadata("keccak-256");

            _hashProvider = new HashProvider(hashingAlgorithm);
            _dfsService   = Substitute.For <IDfsService>();
            _logger       = Substitute.For <ILogger>();

            _dfsReader = new DeltaDfsReader(_dfsService, _logger);
        }
예제 #26
0
        public void Init()
        {
            _hashProvider        = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256"));
            _fileTransferFactory = Substitute.For <IUploadFileTransferFactory>();
            _dfsService          = Substitute.For <IDfsService>();
            var peerSettings = PeerIdHelper.GetPeerId("test").ToSubstitutedPeerSettings();

            _observer = new GetFileFromDfsRequestObserver(_dfsService, peerSettings, _fileTransferFactory,
                                                          Substitute.For <ILogger>());
        }
예제 #27
0
        public void Init()
        {
            _hashProvider     = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256"));
            _broadcastManager = Substitute.For <IBroadcastManager>();
            var logger = Substitute.For <ILogger>();

            _peerId     = PeerIdHelper.GetPeerId("me");
            _dfsService = Substitute.For <IDfsService>();
            _hub        = new DeltaHubWithFastRetryPolicy(_broadcastManager, _peerId.ToSubstitutedPeerSettings(), _dfsService, _hashProvider, logger);
        }
        public GetFileFromDfsRequestObserverTests()
        {
            _hashProvider        = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));
            _fileTransferFactory = Substitute.For <IUploadFileTransferFactory>();
            _dfs = Substitute.For <IDfs>();
            var peerSettings = PeerIdHelper.GetPeerId("test").ToSubstitutedPeerSettings();

            _observer = new GetFileFromDfsRequestObserver(_dfs, _hashProvider, peerSettings, _fileTransferFactory,
                                                          Substitute.For <ILogger>());
        }
        public void Init()
        {
            Setup(TestContext.CurrentContext);

            _hashProvider        = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("keccak-256"));
            _logger              = Substitute.For <ILogger>();
            _fakeContext         = Substitute.For <IChannelHandlerContext>();
            _fileDownloadFactory = new DownloadFileTransferFactory(_logger);
            _logger              = Substitute.For <ILogger>();
            _dfsService          = Substitute.For <IDfsService>();
        }
예제 #30
0
        public DeltaHubTests()
        {
            _hashProvider     = new HashProvider(HashingAlgorithm.GetAlgorithmMetadata("blake2b-256"));
            _broadcastManager = Substitute.For <IBroadcastManager>();
            var logger = Substitute.For <ILogger>();

            _peerId = PeerIdHelper.GetPeerId("me");
            _dfs    = Substitute.For <IDfs>();
            _hub    = new DeltaHubWithFastRetryPolicy(_broadcastManager, _peerId.ToSubstitutedPeerSettings(), _dfs,
                                                      logger);
        }