Exemplo n.º 1
0
        public void TestExceptionOnBeginReceive()
        {
            TestHelper.InMethod();

            MockScene scene = new MockScene();

            uint     circuitCodeA = 130000;
            EndPoint epA          = new IPEndPoint(IPAddress.Loopback, 1300);
            UUID     agentIdA     = UUID.Parse("00000000-0000-0000-0000-000000001300");
            UUID     sessionIdA   = UUID.Parse("00000000-0000-0000-0000-000000002300");

            uint     circuitCodeB = 130001;
            EndPoint epB          = new IPEndPoint(IPAddress.Loopback, 1301);
            UUID     agentIdB     = UUID.Parse("00000000-0000-0000-0000-000000001301");
            UUID     sessionIdB   = UUID.Parse("00000000-0000-0000-0000-000000002301");

            TestLLUDPServer     testLLUDPServer;
            TestLLPacketServer  testLLPacketServer;
            AgentCircuitManager acm;

            SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm);
            AddClient(circuitCodeA, epA, agentIdA, sessionIdA, testLLUDPServer, acm);
            AddClient(circuitCodeB, epB, agentIdB, sessionIdB, testLLUDPServer, acm);

            testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "packet1"), epA);
            testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "packet2"), epB);
            testLLUDPServer.LoadReceiveWithBeginException(epA);
            testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(2, "packet3"), epB);
            testLLUDPServer.ReceiveData(null);

            Assert.IsFalse(testLLUDPServer.HasCircuit(circuitCodeA));

            Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(3));
            Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(3));
        }
Exemplo n.º 2
0
        public void TestMalformedPacketSend()
        {
            TestHelper.InMethod();

            uint      myCircuitCode = 123458;
            EndPoint  testEp        = new IPEndPoint(IPAddress.Loopback, 1001);
            MockScene scene         = new MockScene();

            TestLLUDPServer     testLLUDPServer;
            TestLLPacketServer  testLLPacketServer;
            AgentCircuitManager acm;

            SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm);
            AddClient(myCircuitCode, testEp, testLLUDPServer, acm);

            byte[] data = new byte[] { 0x01, 0x02, 0x03, 0x04 };

            // Send two garbled 'packets' in succession
            testLLUDPServer.LoadReceive(data, testEp);
            testLLUDPServer.LoadReceive(data, testEp);
            testLLUDPServer.ReceiveData(null);

            // Check that we are still here
            Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode));
            Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(0));

            // Check that sending a valid packet to same circuit still succeeds
            Assert.That(scene.ObjectNameCallsReceived, Is.EqualTo(0));

            testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "helloooo"), testEp);
            testLLUDPServer.ReceiveData(null);

            Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(1));
            Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(1));
        }
Exemplo n.º 3
0
        /// <summary>
        /// More a placeholder, really
        /// </summary>        
        public void InPacketTest()
        {
            TestHelper.InMethod();

            AgentCircuitData agent = new AgentCircuitData();
            agent.AgentID = UUID.Random();
            agent.firstname = "testfirstname";
            agent.lastname = "testlastname";
            agent.SessionID = UUID.Zero;
            agent.SecureSessionID = UUID.Zero;
            agent.circuitcode = 123;
            agent.BaseFolder = UUID.Zero;
            agent.InventoryFolder = UUID.Zero;
            agent.startpos = Vector3.Zero;
            agent.CapsPath = "http://wibble.com";
            
            TestLLUDPServer testLLUDPServer;
            TestLLPacketServer testLLPacketServer;
            AgentCircuitManager acm;
            IScene scene = new MockScene();
            SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm);
            
            TestClient testClient = new TestClient(agent, scene);
            
            ILLPacketHandler packetHandler 
                = new LLPacketHandler(testClient, testLLPacketServer, new ClientStackUserSettings());
            
            packetHandler.InPacket(new AgentAnimationPacket());
            LLQueItem receivedPacket = packetHandler.PacketQueue.Dequeue();
            
            Assert.That(receivedPacket, Is.Not.Null);
            Assert.That(receivedPacket.Incoming, Is.True);
            Assert.That(receivedPacket.Packet, Is.TypeOf(typeof(AgentAnimationPacket)));
        }
        /// <summary>
        /// More a placeholder, really
        /// </summary>
        public void InPacketTest()
        {
            TestHelper.InMethod();

            AgentCircuitData agent = new AgentCircuitData();

            agent.AgentID         = UUID.Random();
            agent.firstname       = "testfirstname";
            agent.lastname        = "testlastname";
            agent.SessionID       = UUID.Zero;
            agent.SecureSessionID = UUID.Zero;
            agent.circuitcode     = 123;
            agent.BaseFolder      = UUID.Zero;
            agent.InventoryFolder = UUID.Zero;
            agent.startpos        = Vector3.Zero;
            agent.CapsPath        = "http://wibble.com";

            TestLLUDPServer     testLLUDPServer;
            TestLLPacketServer  testLLPacketServer;
            AgentCircuitManager acm;
            IScene scene = new MockScene();

            SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm);

            TestClient testClient = new TestClient(agent, scene);

            ILLPacketHandler packetHandler
                = new LLPacketHandler(testClient, testLLPacketServer, new ClientStackUserSettings());

            packetHandler.InPacket(new AgentAnimationPacket());
            LLQueItem receivedPacket = packetHandler.PacketQueue.Dequeue();

            Assert.That(receivedPacket, Is.Not.Null);
            Assert.That(receivedPacket.Incoming, Is.True);
            Assert.That(receivedPacket.Packet, Is.TypeOf(typeof(AgentAnimationPacket)));
        }
Exemplo n.º 5
0
        public void TestExceptionOnBeginReceive()
        {
            TestHelper.InMethod();

            MockScene scene = new MockScene();
            
            uint circuitCodeA = 130000;
            EndPoint epA = new IPEndPoint(IPAddress.Loopback, 1300);
            UUID agentIdA   = UUID.Parse("00000000-0000-0000-0000-000000001300");
            UUID sessionIdA = UUID.Parse("00000000-0000-0000-0000-000000002300");   
            
            uint circuitCodeB = 130001;
            EndPoint epB = new IPEndPoint(IPAddress.Loopback, 1301);
            UUID agentIdB   = UUID.Parse("00000000-0000-0000-0000-000000001301");
            UUID sessionIdB = UUID.Parse("00000000-0000-0000-0000-000000002301");            
            
            TestLLUDPServer testLLUDPServer;
            TestLLPacketServer testLLPacketServer;
            AgentCircuitManager acm;
            SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm);            
            AddClient(circuitCodeA, epA, agentIdA, sessionIdA, testLLUDPServer, acm);
            AddClient(circuitCodeB, epB, agentIdB, sessionIdB, testLLUDPServer, acm);
            
            testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "packet1"), epA);
            testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "packet2"), epB);
            testLLUDPServer.LoadReceiveWithBeginException(epA);
            testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(2, "packet3"), epB);
            testLLUDPServer.ReceiveData(null);
            
            Assert.IsFalse(testLLUDPServer.HasCircuit(circuitCodeA));
         
            Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(3));  
            Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(3));            
        }        
Exemplo n.º 6
0
        public void TestMalformedPacketSend()
        {
            TestHelper.InMethod();

            uint myCircuitCode = 123458;
            EndPoint testEp = new IPEndPoint(IPAddress.Loopback, 1001);
            MockScene scene = new MockScene(); 
            
            TestLLUDPServer testLLUDPServer;
            TestLLPacketServer testLLPacketServer;
            AgentCircuitManager acm;
            SetupStack(scene, out testLLUDPServer, out testLLPacketServer, out acm);            
            AddClient(myCircuitCode, testEp, testLLUDPServer, acm);  

            byte[] data = new byte[] { 0x01, 0x02, 0x03, 0x04 };

            // Send two garbled 'packets' in succession
            testLLUDPServer.LoadReceive(data, testEp);
            testLLUDPServer.LoadReceive(data, testEp);
            testLLUDPServer.ReceiveData(null); 
            
            // Check that we are still here
            Assert.IsTrue(testLLUDPServer.HasCircuit(myCircuitCode));
            Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(0));
            
            // Check that sending a valid packet to same circuit still succeeds
            Assert.That(scene.ObjectNameCallsReceived, Is.EqualTo(0));
            
            testLLUDPServer.LoadReceive(BuildTestObjectNamePacket(1, "helloooo"), testEp);
            testLLUDPServer.ReceiveData(null);
            
            Assert.That(testLLPacketServer.GetTotalPacketsReceived(), Is.EqualTo(1));  
            Assert.That(testLLPacketServer.GetPacketsReceivedFor(PacketType.ObjectName), Is.EqualTo(1));
        }