예제 #1
0
        public void RemoteNode_Test_IsHighPriority()
        {
            // high priority commands
            uut.IsHighPriority(new Tcp.ConnectionClosed()).Should().Be(true);
            uut.IsHighPriority(new Connection.Timer()).Should().Be(true);
            uut.IsHighPriority(new Connection.Ack()).Should().Be(true);

            // any random object should not have priority
            object obj = null;
            uut.IsHighPriority(obj).Should().Be(false);
        }
        public void RemoteNode_Test_IsHighPriority()
        {
            ISerializable s = null;

            //handshaking
            uut.IsHighPriority(Message.Create(MessageCommand.Version, s)).Should().Be(true);
            uut.IsHighPriority(Message.Create(MessageCommand.Verack, s)).Should().Be(true);

            //connectivity
            uut.IsHighPriority(Message.Create(MessageCommand.GetAddr, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.Addr, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.Ping, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.Pong, s)).Should().Be(false);

            //synchronization
            uut.IsHighPriority(Message.Create(MessageCommand.GetHeaders, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.Headers, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.GetBlocks, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.Mempool, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.Inv, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.GetData, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.NotFound, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.Transaction, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.Block, s)).Should().Be(false);
            uut.IsHighPriority(Message.Create(MessageCommand.Extensible, s)).Should().Be(true);
            uut.IsHighPriority(Message.Create(MessageCommand.Reject, s)).Should().Be(false);

            //SPV protocol
            uut.IsHighPriority(Message.Create(MessageCommand.FilterLoad, s)).Should().Be(true);
            uut.IsHighPriority(Message.Create(MessageCommand.FilterAdd, s)).Should().Be(true);
            uut.IsHighPriority(Message.Create(MessageCommand.FilterClear, s)).Should().Be(true);
            uut.IsHighPriority(Message.Create(MessageCommand.MerkleBlock, s)).Should().Be(false);

            //others
            uut.IsHighPriority(Message.Create(MessageCommand.Alert, s)).Should().Be(true);

            // high priority commands
            uut.IsHighPriority(new Tcp.ConnectionClosed()).Should().Be(true);
            uut.IsHighPriority(new Connection.Close()).Should().Be(true);
            uut.IsHighPriority(new Connection.Ack()).Should().Be(true);

            // any random object should not have priority
            object obj = null;

            uut.IsHighPriority(obj).Should().Be(false);
        }