Пример #1
0
        public void should_not_reuse_a_port_used_in_another_envionment()
        {
            const string peerId = "Abc.Peer.0";

            var doNotUsePortFilePath = PathUtil.InBaseDirectory(peerId + ".inboundport.secondenv");
            var expectedPort         = TcpUtil.GetRandomUnusedPort() + 5; // scientifical method to determine what port will be used by the transport :P

            File.WriteAllText(doNotUsePortFilePath, expectedPort.ToString());

            var transport = CreateAndStartZmqTransport(peerId: peerId);
            var endpoint  = new ZmqEndPoint(transport.InboundEndPoint);

            endpoint.GetPort().ShouldNotEqual(expectedPort);
            Console.WriteLine("{0} => {1}", endpoint.GetPort(), expectedPort);
        }
Пример #2
0
        public void should_reuse_last_endpoint_port_when_available_in_current_dir()
        {
            const string peerId = "Abc.Peer.0";

            var expectedPortFilePath = PathUtil.InBaseDirectory(peerId + ".inboundport.test");
            var expectedPort         = TcpUtil.GetRandomUnusedPort();

            File.WriteAllText(expectedPortFilePath, expectedPort.ToString());

            var transport = CreateAndStartZmqTransport(peerId: peerId);
            var endpoint  = new ZmqEndPoint(transport.InboundEndPoint);

            endpoint.GetPort().ShouldEqual(expectedPort);
        }