diff options
author | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
---|---|---|
committer | David Walter Seikel | 2016-11-03 21:44:39 +1000 |
commit | 134f86e8d5c414409631b25b8c6f0ee45fbd8631 (patch) | |
tree | 216b89d3fb89acfb81be1e440c25c41ab09fa96d /OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs | |
parent | More changing to production grid. Double oops. (diff) | |
download | opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.zip opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.gz opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.bz2 opensim-SC_OLD-134f86e8d5c414409631b25b8c6f0ee45fbd8631.tar.xz |
Initial update to OpenSim 0.8.2.1 source code.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs | 110 |
1 files changed, 31 insertions, 79 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs index 556df30..a935dd2 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/Tests/BasicCircuitTests.cs | |||
@@ -33,9 +33,9 @@ using NUnit.Framework; | |||
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenMetaverse.Packets; | 34 | using OpenMetaverse.Packets; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Monitoring; | ||
36 | using OpenSim.Region.Framework.Scenes; | 37 | using OpenSim.Region.Framework.Scenes; |
37 | using OpenSim.Tests.Common; | 38 | using OpenSim.Tests.Common; |
38 | using OpenSim.Tests.Common.Mock; | ||
39 | 39 | ||
40 | namespace OpenSim.Region.ClientStack.LindenUDP.Tests | 40 | namespace OpenSim.Region.ClientStack.LindenUDP.Tests |
41 | { | 41 | { |
@@ -46,7 +46,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
46 | public class BasicCircuitTests : OpenSimTestCase | 46 | public class BasicCircuitTests : OpenSimTestCase |
47 | { | 47 | { |
48 | private Scene m_scene; | 48 | private Scene m_scene; |
49 | private TestLLUDPServer m_udpServer; | ||
50 | 49 | ||
51 | [TestFixtureSetUp] | 50 | [TestFixtureSetUp] |
52 | public void FixtureInit() | 51 | public void FixtureInit() |
@@ -69,74 +68,26 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
69 | { | 68 | { |
70 | base.SetUp(); | 69 | base.SetUp(); |
71 | m_scene = new SceneHelpers().SetupScene(); | 70 | m_scene = new SceneHelpers().SetupScene(); |
71 | StatsManager.SimExtraStats = new SimExtraStatsCollector(); | ||
72 | } | 72 | } |
73 | 73 | ||
74 | /// <summary> | 74 | // /// <summary> |
75 | /// Build an object name packet for test purposes | 75 | // /// Build an object name packet for test purposes |
76 | /// </summary> | 76 | // /// </summary> |
77 | /// <param name="objectLocalId"></param> | 77 | // /// <param name="objectLocalId"></param> |
78 | /// <param name="objectName"></param> | 78 | // /// <param name="objectName"></param> |
79 | private ObjectNamePacket BuildTestObjectNamePacket(uint objectLocalId, string objectName) | 79 | // private ObjectNamePacket BuildTestObjectNamePacket(uint objectLocalId, string objectName) |
80 | { | 80 | // { |
81 | ObjectNamePacket onp = new ObjectNamePacket(); | 81 | // ObjectNamePacket onp = new ObjectNamePacket(); |
82 | ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock(); | 82 | // ObjectNamePacket.ObjectDataBlock odb = new ObjectNamePacket.ObjectDataBlock(); |
83 | odb.LocalID = objectLocalId; | 83 | // odb.LocalID = objectLocalId; |
84 | odb.Name = Utils.StringToBytes(objectName); | 84 | // odb.Name = Utils.StringToBytes(objectName); |
85 | onp.ObjectData = new ObjectNamePacket.ObjectDataBlock[] { odb }; | 85 | // onp.ObjectData = new ObjectNamePacket.ObjectDataBlock[] { odb }; |
86 | onp.Header.Zerocoded = false; | 86 | // onp.Header.Zerocoded = false; |
87 | 87 | // | |
88 | return onp; | 88 | // return onp; |
89 | } | 89 | // } |
90 | 90 | // | |
91 | private void AddUdpServer() | ||
92 | { | ||
93 | AddUdpServer(new IniConfigSource()); | ||
94 | } | ||
95 | |||
96 | private void AddUdpServer(IniConfigSource configSource) | ||
97 | { | ||
98 | uint port = 0; | ||
99 | AgentCircuitManager acm = m_scene.AuthenticateHandler; | ||
100 | |||
101 | m_udpServer = new TestLLUDPServer(IPAddress.Any, ref port, 0, false, configSource, acm); | ||
102 | m_udpServer.AddScene(m_scene); | ||
103 | } | ||
104 | |||
105 | /// <summary> | ||
106 | /// Used by tests that aren't testing this stage. | ||
107 | /// </summary> | ||
108 | private ScenePresence AddClient() | ||
109 | { | ||
110 | UUID myAgentUuid = TestHelpers.ParseTail(0x1); | ||
111 | UUID mySessionUuid = TestHelpers.ParseTail(0x2); | ||
112 | uint myCircuitCode = 123456; | ||
113 | IPEndPoint testEp = new IPEndPoint(IPAddress.Loopback, 999); | ||
114 | |||
115 | UseCircuitCodePacket uccp = new UseCircuitCodePacket(); | ||
116 | |||
117 | UseCircuitCodePacket.CircuitCodeBlock uccpCcBlock | ||
118 | = new UseCircuitCodePacket.CircuitCodeBlock(); | ||
119 | uccpCcBlock.Code = myCircuitCode; | ||
120 | uccpCcBlock.ID = myAgentUuid; | ||
121 | uccpCcBlock.SessionID = mySessionUuid; | ||
122 | uccp.CircuitCode = uccpCcBlock; | ||
123 | |||
124 | byte[] uccpBytes = uccp.ToBytes(); | ||
125 | UDPPacketBuffer upb = new UDPPacketBuffer(testEp, uccpBytes.Length); | ||
126 | upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. | ||
127 | Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); | ||
128 | |||
129 | AgentCircuitData acd = new AgentCircuitData(); | ||
130 | acd.AgentID = myAgentUuid; | ||
131 | acd.SessionID = mySessionUuid; | ||
132 | |||
133 | m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd); | ||
134 | |||
135 | m_udpServer.PacketReceived(upb); | ||
136 | |||
137 | return m_scene.GetScenePresence(myAgentUuid); | ||
138 | } | ||
139 | |||
140 | /// <summary> | 91 | /// <summary> |
141 | /// Test adding a client to the stack | 92 | /// Test adding a client to the stack |
142 | /// </summary> | 93 | /// </summary> |
@@ -146,7 +97,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
146 | TestHelpers.InMethod(); | 97 | TestHelpers.InMethod(); |
147 | // TestHelpers.EnableLogging(); | 98 | // TestHelpers.EnableLogging(); |
148 | 99 | ||
149 | AddUdpServer(); | 100 | TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(m_scene); |
150 | 101 | ||
151 | UUID myAgentUuid = TestHelpers.ParseTail(0x1); | 102 | UUID myAgentUuid = TestHelpers.ParseTail(0x1); |
152 | UUID mySessionUuid = TestHelpers.ParseTail(0x2); | 103 | UUID mySessionUuid = TestHelpers.ParseTail(0x2); |
@@ -167,7 +118,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
167 | upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. | 118 | upb.DataLength = uccpBytes.Length; // God knows why this isn't set by the constructor. |
168 | Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); | 119 | Buffer.BlockCopy(uccpBytes, 0, upb.Data, 0, uccpBytes.Length); |
169 | 120 | ||
170 | m_udpServer.PacketReceived(upb); | 121 | udpServer.PacketReceived(upb); |
171 | 122 | ||
172 | // Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet | 123 | // Presence shouldn't exist since the circuit manager doesn't know about this circuit for authentication yet |
173 | Assert.That(m_scene.GetScenePresence(myAgentUuid), Is.Null); | 124 | Assert.That(m_scene.GetScenePresence(myAgentUuid), Is.Null); |
@@ -178,15 +129,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
178 | 129 | ||
179 | m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd); | 130 | m_scene.AuthenticateHandler.AddNewCircuit(myCircuitCode, acd); |
180 | 131 | ||
181 | m_udpServer.PacketReceived(upb); | 132 | udpServer.PacketReceived(upb); |
182 | 133 | ||
183 | // Should succeed now | 134 | // Should succeed now |
184 | ScenePresence sp = m_scene.GetScenePresence(myAgentUuid); | 135 | ScenePresence sp = m_scene.GetScenePresence(myAgentUuid); |
185 | Assert.That(sp.UUID, Is.EqualTo(myAgentUuid)); | 136 | Assert.That(sp.UUID, Is.EqualTo(myAgentUuid)); |
186 | 137 | ||
187 | Assert.That(m_udpServer.PacketsSent.Count, Is.EqualTo(1)); | 138 | Assert.That(udpServer.PacketsSent.Count, Is.EqualTo(1)); |
188 | 139 | ||
189 | Packet packet = m_udpServer.PacketsSent[0]; | 140 | Packet packet = udpServer.PacketsSent[0]; |
190 | Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket))); | 141 | Assert.That(packet, Is.InstanceOf(typeof(PacketAckPacket))); |
191 | 142 | ||
192 | PacketAckPacket ackPacket = packet as PacketAckPacket; | 143 | PacketAckPacket ackPacket = packet as PacketAckPacket; |
@@ -203,15 +154,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
203 | IniConfigSource ics = new IniConfigSource(); | 154 | IniConfigSource ics = new IniConfigSource(); |
204 | IConfig config = ics.AddConfig("ClientStack.LindenUDP"); | 155 | IConfig config = ics.AddConfig("ClientStack.LindenUDP"); |
205 | config.Set("AckTimeout", -1); | 156 | config.Set("AckTimeout", -1); |
206 | AddUdpServer(ics); | 157 | TestLLUDPServer udpServer = ClientStackHelpers.AddUdpServer(m_scene, ics); |
158 | |||
159 | ScenePresence sp | ||
160 | = ClientStackHelpers.AddChildClient( | ||
161 | m_scene, udpServer, TestHelpers.ParseTail(0x1), TestHelpers.ParseTail(0x2), 123456); | ||
207 | 162 | ||
208 | ScenePresence sp = AddClient(); | 163 | udpServer.ClientOutgoingPacketHandler(sp.ControllingClient, true, false, false); |
209 | m_udpServer.ClientOutgoingPacketHandler(sp.ControllingClient, true, false, false); | ||
210 | 164 | ||
211 | ScenePresence spAfterAckTimeout = m_scene.GetScenePresence(sp.UUID); | 165 | ScenePresence spAfterAckTimeout = m_scene.GetScenePresence(sp.UUID); |
212 | Assert.That(spAfterAckTimeout, Is.Null); | 166 | Assert.That(spAfterAckTimeout, Is.Null); |
213 | |||
214 | // TestHelpers.DisableLogging(); | ||
215 | } | 167 | } |
216 | 168 | ||
217 | // /// <summary> | 169 | // /// <summary> |
@@ -233,7 +185,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP.Tests | |||
233 | // testLLUDPServer.RemoveClientCircuit(myCircuitCode); | 185 | // testLLUDPServer.RemoveClientCircuit(myCircuitCode); |
234 | // Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode)); | 186 | // Assert.IsFalse(testLLUDPServer.HasCircuit(myCircuitCode)); |
235 | // | 187 | // |
236 | // // Check that removing a non-existant circuit doesn't have any bad effects | 188 | // // Check that removing a non-existent circuit doesn't have any bad effects |
237 | // testLLUDPServer.RemoveClientCircuit(101); | 189 | // testLLUDPServer.RemoveClientCircuit(101); |
238 | // Assert.IsFalse(testLLUDPServer.HasCircuit(101)); | 190 | // Assert.IsFalse(testLLUDPServer.HasCircuit(101)); |
239 | // } | 191 | // } |