public PoaConsensusTests(ITestOutputHelper output) : base(output)
        {
            ContainerProvider.ConfigureContainerBuilder(true, true, true);
            _scope = ContainerProvider.Container.BeginLifetimeScope(CurrentTestName);

            var context = new FfiWrapper();

            _endOfTestCancellationSource = new CancellationTokenSource();

            var poaNodeDetails = Enumerable.Range(0, 3).Select(i =>
            {
                var privateKey     = context.GeneratePrivateKey();
                var publicKey      = privateKey.GetPublicKey();
                var nodeSettings   = PeerSettingsHelper.TestPeerSettings(publicKey.Bytes, 2000 + i);
                var peerIdentifier = nodeSettings.PeerId;
                var name           = $"producer{i.ToString()}";
                return(new { index = i, name, privateKey, nodeSettings, peerIdentifier });
            }
                                                               ).ToList();

            var peerIdentifiers = poaNodeDetails.Select(n => n.peerIdentifier).ToList();

            _nodes = poaNodeDetails.Select(
                p => new PoaTestNode($"producer{p.index.ToString()}",
                                     p.privateKey,
                                     p.nodeSettings,
                                     peerIdentifiers.Except(new[] { p.peerIdentifier }),
                                     FileSystem,
                                     output)).ToList();
        }
Ejemplo n.º 2
0
        public HastingsDiscoveryTests(ITestOutputHelper output) : base(output)
        {
            _testScheduler = new TestScheduler();
            _settings      = PeerSettingsHelper.TestPeerSettings();
            _ownNode       = PeerIdHelper.GetPeerId("ownNode");

            ContainerProvider.ConfigureContainerBuilder(true, true);
            _logger = ContainerProvider.Container.Resolve <ILogger>();
        }
Ejemplo n.º 3
0
        public void Init()
        {
            this.Setup(TestContext.CurrentContext);
            _testScheduler = new TestScheduler();
            _settings      = PeerSettingsHelper.TestPeerSettings();
            _ownNode       = PeerIdHelper.GetPeerId("ownNode");

            ContainerProvider.ConfigureContainerBuilder(true, true);
            _logger = ContainerProvider.Container.Resolve <ILogger>();
        }
Ejemplo n.º 4
0
        public DiscoveryTestBuilder WithDns(IDns dnsClient             = default,
                                            bool mock                  = false,
                                            IPeerSettings peerSettings = default)
        {
            _dnsClient = dnsClient == default(IDns) && mock == false
                ? Substitute.For <IDns>()
                : DiscoveryHelper.MockDnsClient(_peerSettings = _peerSettings == null && peerSettings == default(IPeerSettings)
                    ? PeerSettingsHelper.TestPeerSettings()
                    : peerSettings);

            return(this);
        }
Ejemplo n.º 5
0
        public PeerQueryTipTests(ITestOutputHelper output) : base(output)
        {
            var subbedPeerClient = Substitute.For <IPeerClient>();

            _testSettings         = PeerSettingsHelper.TestPeerSettings();
            _cancellationProvider = new CancellationTokenProvider(TimeSpan.FromSeconds(10));

            _peerQueryTipRequest = new PeerQueryTipRequestRequest(
                Substitute.For <ILogger>(),
                subbedPeerClient,
                _testSettings,
                _cancellationProvider
                );
        }
Ejemplo n.º 6
0
        public void Init()
        {
            var subbedPeerClient = Substitute.For <IPeerClient>();

            _testSettings         = PeerSettingsHelper.TestPeerSettings();
            _cancellationProvider = new CancellationTokenProvider(TimeSpan.FromSeconds(10));

            _peerChallengeRequest = new PeerChallengeRequest(
                Substitute.For <ILogger>(),
                subbedPeerClient,
                _testSettings,
                10
                );
        }
Ejemplo n.º 7
0
        public void Init()
        {
            this.Setup(TestContext.CurrentContext);

            var subbedPeerClient = Substitute.For <IPeerClient>();

            _testSettings         = PeerSettingsHelper.TestPeerSettings();
            _cancellationProvider = new CancellationTokenProvider(TimeSpan.FromSeconds(10));

            _peerQueryTipRequest = new PeerQueryTipRequestRequest(
                Substitute.For <ILogger>(),
                subbedPeerClient,
                _testSettings,
                _cancellationProvider
                );
        }
Ejemplo n.º 8
0
        public void Init()
        {
            this.Setup(TestContext.CurrentContext);

            ContainerProvider.ConfigureContainerBuilder(true, true, true);

            var context = new FfiWrapper();

            _endOfTestCancellationSource = new CancellationTokenSource();

            var poaNodeDetails = Enumerable.Range(0, 3).Select(i =>
            {
                var fileSystem = Substitute.For <IFileSystem>();
                var path       = Path.Combine(FileSystem.GetCatalystDataDir().FullName, $"producer{i}");
                fileSystem.GetCatalystDataDir().Returns(new DirectoryInfo(path));

                var privateKey     = context.GeneratePrivateKey();
                var publicKey      = privateKey.GetPublicKey();
                var nodeSettings   = PeerSettingsHelper.TestPeerSettings(publicKey.Bytes, 2000 + i);
                var peerIdentifier = nodeSettings.PeerId;
                var name           = $"producer{i.ToString()}";
                var dfs            = TestDfs.GetTestDfs(fileSystem);
                return(new { index = i, name, privateKey, nodeSettings, peerIdentifier, dfs, fileSystem });
            }
                                                               ).ToList();

            var peerIdentifiers = poaNodeDetails.Select(n => n.peerIdentifier).ToList();

            _nodes = new List <PoaTestNode>();
            foreach (var nodeDetails in poaNodeDetails)
            {
                nodeDetails.dfs.Options.Discovery.BootstrapPeers = poaNodeDetails.Select(x => x.dfs.LocalPeer.Addresses.First());
                var node = new PoaTestNode(nodeDetails.name,
                                           nodeDetails.privateKey,
                                           nodeDetails.nodeSettings,
                                           nodeDetails.dfs,
                                           peerIdentifiers.Except(new[] { nodeDetails.peerIdentifier }),
                                           nodeDetails.fileSystem);

                _nodes.Add(node);
            }
        }
Ejemplo n.º 9
0
 public HastingsDiscoveryTests()
 {
     _testScheduler = new TestScheduler();
     _settings      = PeerSettingsHelper.TestPeerSettings();
     _ownNode       = PeerIdHelper.GetPeerId("ownNode");
 }
Ejemplo n.º 10
0
 public DiscoveryTestBuilder WithPeerSettings(IPeerSettings peerSettings = default)
 {
     _peerSettings = peerSettings ?? PeerSettingsHelper.TestPeerSettings();
     return(this);
 }