aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs71
1 files changed, 12 insertions, 59 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs
index e9aeffe..ef5e861 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs
@@ -47,7 +47,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
47 public class BasicCircuitTests : OpenSimTestCase 47 public class BasicCircuitTests : OpenSimTestCase
48 { 48 {
49 private Scene m_scene; 49 private Scene m_scene;
50 private TestLLUDPServer m_udpServer;
51 50
52 [TestFixtureSetUp] 51 [TestFixtureSetUp]
53 public void FixtureInit() 52 public void FixtureInit()
@@ -90,55 +89,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
90 return onp; 89 return onp;
91 } 90 }
92 91
93 private void AddUdpServer()
94 {
95 AddUdpServer(new IniConfigSource());
96 }
97
98 private void AddUdpServer(IniConfigSource configSource)
99 {
100 uint port = 0;
101 AgentCircuitManager acm = m_scene.AuthenticateHandler;
102
103 m_udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, configSource, acm);
104 m_udpServer.AddScene(m_scene);
105 }
106
107 /// <summary>
108 /// Used by tests that aren't testing this stage.
109 /// </summary>
110 private ScenePresence AddClient()
111 {
112 UUID myAgentUuid = TestHelpers.ParseTail(0x1);
113 UUID mySessionUuid = TestHelpers.ParseTail(0x2);
114 uint myCircuitCode = 123456;
115 IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999);
116
117 UseCircuitCodePacket uccp = new UseCircuitCodePacket();
118
119 UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock
120 = new UseCircuitCodePacket.CircuitCodeBlock();
121 uccpCcBlock.Code = myCircuitCode;
122 uccpCcBlock.ID = myAgentUuid;
123 uccpCcBlock.SessionID = mySessionUuid;
124 uccp.CircuitCode = uccpCcBlock;
125
126 byte[] uccpBytes = uccp.ToBytes();
127 UDPPacketBuffer upb = new UDPPacketBuffer(testEp, uccpBytes.Length);
128 upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor.
129 Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length);
130
131 AgentCircuitData acd = new AgentCircuitData();
132 acd.AgentID = myAgentUuid;
133 acd.SessionID = mySessionUuid;
134
135 m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd);
136
137 m_udpServer.PacketReceived(upb);
138
139 return m_scene.GetScenePresence(myAgentUuid);
140 }
141
142 /// <summary> 92 /// <summary>
143 /// Test adding a client to the stack 93 /// Test adding a client to the stack
144 /// </summary> 94 /// </summary>
@@ -148,7 +98,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
148 TestHelpers.InMethod(); 98 TestHelpers.InMethod();
149// TestHelpers.EnableLogging(); 99// TestHelpers.EnableLogging();
150 100
151 AddUdpServer(); 101 TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(m_scene);
152 102
153 UUID myAgentUuid = TestHelpers.ParseTail(0x1); 103 UUID myAgentUuid = TestHelpers.ParseTail(0x1);
154 UUID mySessionUuid = TestHelpers.ParseTail(0x2); 104 UUID mySessionUuid = TestHelpers.ParseTail(0x2);
@@ -169,7 +119,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
169 upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. 119 upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor.
170 Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); 120 Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length);
171 121
172 m_udpServer.PacketReceived(upb); 122 udpServer.PacketReceived(upb);
173 123
174 // Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet 124 // Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet
175 Assert.That(m_scene.GetScenePresence(myAgentUuid), Is.Null); 125 Assert.That(m_scene.GetScenePresence(myAgentUuid), Is.Null);
@@ -180,15 +130,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
180 130
181 m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd); 131 m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd);
182 132
183 m_udpServer.PacketReceived(upb); 133 udpServer.PacketReceived(upb);
184 134
185 // Should succeed now 135 // Should succeed now
186 ScenePresence sp = m_scene.GetScenePresence(myAgentUuid); 136 ScenePresence sp = m_scene.GetScenePresence(myAgentUuid);
187 Assert.That(sp.UUID, Is.EqualTo(myAgentUuid)); 137 Assert.That(sp.UUID, Is.EqualTo(myAgentUuid));
188 138
189 Assert.That(m_udpServer.PacketsSent.Count, Is.EqualTo(1)); 139 Assert.That(udpServer.PacketsSent.Count, Is.EqualTo(1));
190 140
191 Packet packet = m_udpServer.PacketsSent[0]; 141 Packet packet = udpServer.PacketsSent[0];
192 Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket))); 142 Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket)));
193 143
194 PacketAckPacket ackPacket = packet as PacketAckPacket; 144 PacketAckPacket ackPacket = packet as PacketAckPacket;
@@ -200,15 +150,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests
200 public void TestLogoutClientDueToAck() 150 public void TestLogoutClientDueToAck()
201 { 151 {
202 TestHelpers.InMethod(); 152 TestHelpers.InMethod();
203 TestHelpers.EnableLogging(); 153// TestHelpers.EnableLogging();
204 154
205 IniConfigSource ics = new IniConfigSource(); 155 IniConfigSource ics = new IniConfigSource();
206 IConfig config = ics.AddConfig("ClientStack.LindenUDP"); 156 IConfig config = ics.AddConfig("ClientStack.LindenUDP");
207 config.Set("AckTimeout", -1); 157 config.Set("AckTimeout", -1);
208 AddUdpServer(ics); 158 TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(m_scene, ics);
159
160 ScenePresence sp
161 = ClientStackHelpers.AddChildClient(
162 m_scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456);
209 163
210 ScenePresence sp = AddClient(); 164 udpServer.ClientOutgoingPacketHandler(sp.ControllingClient, true, false, false);
211 m_udpServer.ClientOutgoingPacketHandler(sp.ControllingClient, true, false, false);
212 165
213 ScenePresence spAfterAckTimeout = m_scene.GetScenePresence(sp.UUID); 166 ScenePresence spAfterAckTimeout = m_scene.GetScenePresence(sp.UUID);
214 Assert.That(spAfterAckTimeout, Is.Null); 167 Assert.That(spAfterAckTimeout, Is.Null);