public void TestCrossOnSameSimulator()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);
            int sceneObjectIdTail = 0x2;

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneA, config, etmA);
            SceneHelpers.SetupSceneModules(sceneB, config, etmB);

            SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
            UUID so1Id = so1.UUID;
            so1.AbsolutePosition = new Vector3(128, 10, 20);

            // Cross with a negative value
            so1.AbsolutePosition = new Vector3(128, -10, 20);

            Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id));
            Assert.NotNull(sceneB.GetSceneObjectGroup(so1Id));
        }
        public void Init()
        {
            TestHelpers.InMethod();

            SceneHelpers sh = new SceneHelpers();

            scene = sh.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
            scene2 = sh.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
            scene3 = sh.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000);

            ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
            interregionComms.Initialise(new IniConfigSource());
            interregionComms.PostInitialise();
            SceneHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
            SceneHelpers.SetupSceneModules(scene2, new IniConfigSource(), interregionComms);
            SceneHelpers.SetupSceneModules(scene3, new IniConfigSource(), interregionComms);

            agent1 = UUID.Random();
            agent2 = UUID.Random();
            agent3 = UUID.Random();
            random = new Random();
            sog1 = SceneHelpers.CreateSceneObject(1, agent1);
            scene.AddSceneObject(sog1);
            sog2 = SceneHelpers.CreateSceneObject(1, agent1);
            scene.AddSceneObject(sog2);
            sog3 = SceneHelpers.CreateSceneObject(1, agent1);
            scene.AddSceneObject(sog3);

            region1 = scene.RegionInfo.RegionHandle;
            region2 = scene2.RegionInfo.RegionHandle;
            region3 = scene3.RegionInfo.RegionHandle;
        }
Esempio n. 3
0
        public void TestNoTelehubSpawnPoints()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            EstateManagementModule emm = new EstateManagementModule();

            SceneHelpers sh = new SceneHelpers();
            Scene scene = sh.SetupScene();
            SceneHelpers.SetupSceneModules(scene, emm);

            UUID telehubSceneObjectOwner = TestHelpers.ParseTail(0x1);

            SceneObjectGroup telehubSo = SceneHelpers.AddSceneObject(scene, "telehubObject", telehubSceneObjectOwner);

            emm.HandleOnEstateManageTelehub(null, UUID.Zero, UUID.Zero, "connect", telehubSo.LocalId);
            scene.RegionInfo.EstateSettings.AllowDirectTeleport = false;

            // Must still be possible to successfully log in
            UUID loggingInUserId = TestHelpers.ParseTail(0x2);

            UserAccount ua 
                = UserAccountHelpers.CreateUserWithInventory(scene, "Test", "User", loggingInUserId, "password");

            SceneHelpers.AddScenePresence(scene, ua);

            Assert.That(scene.GetScenePresence(loggingInUserId), Is.Not.Null);
        }
        public void TestCachedUserNameForNewAgent()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            HGUserManagementModule hgumm = new HGUserManagementModule();
            UUID userId = TestHelpers.ParseStem("11");
            string firstName = "Fred";
            string lastName = "Astaire";
            string homeUri = "example.com";

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Modules");
            config.Configs["Modules"].Set("UserManagementModule", hgumm.Name);

            SceneHelpers sceneHelpers = new SceneHelpers();
            TestScene scene = sceneHelpers.SetupScene();
            SceneHelpers.SetupSceneModules(scene, config, hgumm);

            AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
            acd.firstname = firstName;
            acd.lastname = lastName;
            acd.ServiceURLs["HomeURI"] = "http://" + homeUri;

            SceneHelpers.AddScenePresence(scene, acd);

            string name = hgumm.GetUserName(userId);
            Assert.That(name, Is.EqualTo(string.Format("{0}.{1} @{2}", firstName, lastName, homeUri)));
        }
Esempio n. 5
0
        public void TestClose()
        {
            TestHelpers.InMethod();

            SceneHelpers sh = new SceneHelpers();
            Scene scene = sh.SetupScene();

            sh.SceneManager.Close();
            Assert.That(scene.ShuttingDown, Is.True);
        }
Esempio n. 6
0
        public override void SetUp()
        {
            base.SetUp();

            m_archiverModule = new ArchiverModule();
            m_serialiserModule = new SerialiserModule();
            TerrainModule terrainModule = new TerrainModule();

            m_sceneHelpers = new SceneHelpers();
            m_scene = m_sceneHelpers.SetupScene();
            SceneHelpers.SetupSceneModules(m_scene, m_archiverModule, m_serialiserModule, terrainModule);
        }
Esempio n. 7
0
        public void SetUp()
        {
            UUID userId = TestHelpers.ParseTail(0x3);

            J2KDecoderModule j2kdm = new J2KDecoderModule();

            SceneHelpers sceneHelpers = new SceneHelpers();
            scene = sceneHelpers.SetupScene();
            SceneHelpers.SetupSceneModules(scene, j2kdm);

            tc = new TestClient(SceneHelpers.GenerateAgentData(userId), scene);
            llim = new LLImageManager(tc, scene.AssetService, j2kdm);
        }
Esempio n. 8
0
        public override void SetUp()
        {
            base.SetUp();

            // FIXME: Do something about this - relying on statics in unit tests causes trouble sooner or later
            new SceneManager();

            m_archiverModule = new ArchiverModule();
            m_serialiserModule = new SerialiserModule();
            TerrainModule terrainModule = new TerrainModule();

            m_sceneHelpers = new SceneHelpers();
            m_scene = m_sceneHelpers.SetupScene();
            SceneHelpers.SetupSceneModules(m_scene, m_archiverModule, m_serialiserModule, terrainModule);
        }
        public void SetUp()
        {
            m_iam = new BasicInventoryAccessModule();

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Modules");
            config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");

            SceneHelpers sceneHelpers = new SceneHelpers();
            m_scene = sceneHelpers.SetupScene();
            SceneHelpers.SetupSceneModules(m_scene, config, m_iam);
            
            // Create user
            string userFirstName = "Jock";
            string userLastName = "Stirrup";
            string userPassword = "******";
            UserAccountHelpers.CreateUserWithInventory(m_scene, userFirstName, userLastName, m_userId, userPassword);                        
            
            AgentCircuitData acd = new AgentCircuitData();
            acd.AgentID = m_userId;
            m_tc = new TestClient(acd, m_scene);
        }
Esempio n. 10
0
        public void TestLoadPublishedOar()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            SceneObjectPart part1 = CreateSceneObjectPart1();
            SceneObjectGroup sog1 = new SceneObjectGroup(part1);
            m_scene.AddNewSceneObject(sog1, false);

            SceneObjectPart part2 = CreateSceneObjectPart2();
            
            AssetNotecard nc = new AssetNotecard();
            nc.BodyText = "Hello World!";
            nc.Encode();
            UUID ncAssetUuid = new UUID("00000000-0000-0000-1000-000000000000");
            UUID ncItemUuid = new UUID("00000000-0000-0000-1100-000000000000");
            AssetBase ncAsset 
                = AssetHelpers.CreateAsset(ncAssetUuid, AssetType.Notecard, nc.AssetData, UUID.Zero);
            m_scene.AssetService.Store(ncAsset);
            SceneObjectGroup sog2 = new SceneObjectGroup(part2);
            TaskInventoryItem ncItem 
                = new TaskInventoryItem { Name = "ncItem", AssetID = ncAssetUuid, ItemID = ncItemUuid };
            part2.Inventory.AddInventoryItem(ncItem, true);
            
            m_scene.AddNewSceneObject(sog2, false);

            MemoryStream archiveWriteStream = new MemoryStream();
            m_scene.EventManager.OnOarFileSaved += SaveCompleted;

            Guid requestId = new Guid("00000000-0000-0000-0000-808080808080");
            
            lock (this)
            {
                m_archiverModule.ArchiveRegion(
                    archiveWriteStream, requestId, new Dictionary<string, Object>() { { "wipe-owners", Boolean.TrueString } });
                
                Monitor.Wait(this, 60000);
            }
            
            Assert.That(m_lastRequestId, Is.EqualTo(requestId));

            byte[] archive = archiveWriteStream.ToArray();
            MemoryStream archiveReadStream = new MemoryStream(archive);

            {
                UUID estateOwner = TestHelpers.ParseTail(0x4747);
                UUID objectOwner = TestHelpers.ParseTail(0x15);

                // Reload to new scene
                ArchiverModule archiverModule = new ArchiverModule();
                SerialiserModule serialiserModule = new SerialiserModule();
                TerrainModule terrainModule = new TerrainModule();

                SceneHelpers m_sceneHelpers2 = new SceneHelpers();
                TestScene scene2 = m_sceneHelpers2.SetupScene();
                SceneHelpers.SetupSceneModules(scene2, archiverModule, serialiserModule, terrainModule);

                // Make sure there's a valid owner for the owner we saved (this should have been wiped if the code is
                // behaving correctly
                UserAccountHelpers.CreateUserWithInventory(scene2, objectOwner);

                scene2.RegionInfo.EstateSettings.EstateOwner = estateOwner;

                lock (this)
                {
                    scene2.EventManager.OnOarFileLoaded += LoadCompleted;
                    archiverModule.DearchiveRegion(archiveReadStream);
                }

                Assert.That(m_lastErrorMessage, Is.Null);

                SceneObjectGroup loadedSog = scene2.GetSceneObjectGroup(part1.Name);
                Assert.That(loadedSog.OwnerID, Is.EqualTo(estateOwner));
                Assert.That(loadedSog.LastOwnerID, Is.EqualTo(estateOwner));
            }
        }
Esempio n. 11
0
        public void TestInterRegionChatDistanceNorthSouth()
        {
            TestHelpers.InMethod();
            //            TestHelpers.EnableLogging();

            UUID sp1Uuid = TestHelpers.ParseTail(0x11);
            UUID sp2Uuid = TestHelpers.ParseTail(0x12);

            Vector3 sp1Position = new Vector3(128, 250, 20);
            Vector3 sp2Position = new Vector3(128, 6, 20);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneNorth = sh.SetupScene("sceneNorth", TestHelpers.ParseTail(0x1), 1000, 1000);            
            TestScene sceneSouth = sh.SetupScene("sceneSouth", TestHelpers.ParseTail(0x2), 1000, 1001);            

            SetupNeighbourRegions(sceneNorth, sceneSouth);

            ScenePresence sp1 = SceneHelpers.AddScenePresence(sceneNorth, sp1Uuid);
            TestClient sp1Client = (TestClient)sp1.ControllingClient;

            // If we don't set agents to flying, test will go wrong as they instantly fall to z = 0.
            // TODO: May need to create special complete no-op test physics module rather than basic physics, since
            // physics is irrelevant to this test.
            sp1.Flying = true;

            // When sp1 logs in to sceneEast, it sets up a child agent in sceneNorth and informs the sp2 client to 
            // make the connection.  For this test, will simplify this chain by making the connection directly.
            ScenePresence sp1Child = SceneHelpers.AddChildScenePresence(sceneSouth, sp1Uuid);
            TestClient sp1ChildClient = (TestClient)sp1Child.ControllingClient;

            sp1.AbsolutePosition = sp1Position;                

            ScenePresence sp2 = SceneHelpers.AddScenePresence(sceneSouth, sp2Uuid);
            TestClient sp2Client = (TestClient)sp2.ControllingClient;
            sp2.Flying = true;

            ScenePresence sp2Child = SceneHelpers.AddChildScenePresence(sceneNorth, sp2Uuid);
            TestClient sp2ChildClient = (TestClient)sp2Child.ControllingClient;

            sp2.AbsolutePosition = sp2Position;           

            // We must update the scenes in order to make the root new root agents trigger position updates in their
            // children.
            sceneNorth.Update(1);
            sceneSouth.Update(1);

            // Check child positions are correct.
            Assert.AreEqual(
                new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z), 
                sp1ChildClient.SceneAgent.AbsolutePosition);

            Assert.AreEqual(
                new Vector3(sp2Position.X, sp2Position.Y + sceneSouth.RegionInfo.RegionSizeY, sp2Position.Z), 
                sp2ChildClient.SceneAgent.AbsolutePosition);

            string receivedSp1ChatMessage = "";
            string receivedSp2ChatMessage = "";

            sp1ChildClient.OnReceivedChatMessage 
                += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp1ChatMessage = message;
            sp2ChildClient.OnReceivedChatMessage 
                += (message, type, fromPos, fromName, fromAgentID, ownerID, source, audible) => receivedSp2ChatMessage = message;

            TestUserInRange(sp1Client, "ello darling", ref receivedSp2ChatMessage);
            TestUserInRange(sp2Client, "fantastic cats", ref receivedSp1ChatMessage);

            sp1Position = new Vector3(30, 128, 20);
            sp1.AbsolutePosition = sp1Position;
            sceneNorth.Update(1);

            // Check child position is correct.
            Assert.AreEqual(
                new Vector3(sp1Position.X, sp1Position.Y - sceneNorth.RegionInfo.RegionSizeY, sp1Position.Z), 
                sp1ChildClient.SceneAgent.AbsolutePosition);

            TestUserOutOfRange(sp1Client, "beef", ref receivedSp2ChatMessage);
            TestUserOutOfRange(sp2Client, "lentils", ref receivedSp1ChatMessage);
        }
Esempio n. 12
0
        public void TestDeRezSceneObjectToAgents()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);

            // We need this so that the creation of the root client for userB in sceneB can trigger the creation of a child client in sceneA
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
            EntityTransferModule etmB = new EntityTransferModule();
            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmB.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);
            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneB, config, etmB);

            // We need this for derez
            SceneHelpers.SetupSceneModules(sceneA, new PermissionsModule());

            UserAccount uaA = UserAccountHelpers.CreateUserWithInventory(sceneA, "Andy", "AAA", 0x1, "");
            UserAccount uaB = UserAccountHelpers.CreateUserWithInventory(sceneA, "Brian", "BBB", 0x2, "");

            TestClient clientA = (TestClient)SceneHelpers.AddScenePresence(sceneA, uaA).ControllingClient;

            // This is the more long-winded route we have to take to get a child client created for userB in sceneA
            // rather than just calling AddScenePresence() as for userA
            AgentCircuitData acd = SceneHelpers.GenerateAgentData(uaB);
            TestClient clientB = new TestClient(acd, sceneB);
            List<TestClient> childClientsB = new List<TestClient>();
            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(clientB, childClientsB);

            SceneHelpers.AddScenePresence(sceneB, clientB, acd);

            SceneObjectGroup so = SceneHelpers.AddSceneObject(sceneA);
            uint soLocalId = so.LocalId;

            sceneA.DeleteSceneObject(so, false);

            Assert.That(clientA.ReceivedKills.Count, Is.EqualTo(1));
            Assert.That(clientA.ReceivedKills[0], Is.EqualTo(soLocalId));

            Assert.That(childClientsB[0].ReceivedKills.Count, Is.EqualTo(1));
            Assert.That(childClientsB[0].ReceivedKills[0], Is.EqualTo(soLocalId));
        }
        public void TestSameSimulatorNeighbouringRegionsV2()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt = new Vector3(20, 21, 22);

            AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
            TestClient tc = new TestClient(acd, sceneA);
            List<TestClient> destinationTestClients = new List<TestClient>();
            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

            ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
            beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);

            Assert.That(beforeSceneASp, Is.Not.Null);
            Assert.That(beforeSceneASp.IsChildAgent, Is.False);

            ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
            Assert.That(beforeSceneBSp, Is.Not.Null);
            Assert.That(beforeSceneBSp.IsChildAgent, Is.True);

            // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement().  This
            // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to
            // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt
            // Both these operations will occur on different threads and will wait for each other.
            // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1
            // test protocol, where we are trying to avoid unpredictable async operations in regression tests.
            tc.OnTestClientSendRegionTeleport 
                += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) 
                    => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null);

            sceneA.RequestTeleportLocation(
                beforeSceneASp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
            Assert.That(afterSceneASp, Is.Not.Null);
            Assert.That(afterSceneASp.IsChildAgent, Is.True);

            ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
            Assert.That(afterSceneBSp, Is.Not.Null);
            Assert.That(afterSceneBSp.IsChildAgent, Is.False);
            Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
            Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));

//            TestHelpers.DisableLogging();
        }
        public void TestSameSimulatorIsolatedRegionsV1()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);
            IConfig entityTransferConfig = config.AddConfig("EntityTransfer");

            // In order to run a single threaded regression test we do not want the entity transfer module waiting
            // for a callback from the destination scene before removing its avatar data.
            entityTransferConfig.Set("wait_for_callback", false);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);

            SceneHelpers.SetupSceneModules(sceneA, config, etmA);
            SceneHelpers.SetupSceneModules(sceneB, config, etmB);
            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);

            // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
            lscm.ServiceVersion = "SIMULATION/0.1";

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt = new Vector3(20, 21, 22);

            ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
            sp.AbsolutePosition = new Vector3(30, 31, 32);

            List<TestClient> destinationTestClients = new List<TestClient>();
            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(
                (TestClient)sp.ControllingClient, destinationTestClients);

            sceneA.RequestTeleportLocation(
                sp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            // SetupInformClientOfNeighbour() will have handled the callback into the target scene to setup the child
            // agent.  This call will now complete the movement of the user into the destination and upgrade the agent
            // from child to root.
            destinationTestClients[0].CompleteMovement();

            Assert.That(sceneA.GetScenePresence(userId), Is.Null);

            ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
            Assert.That(sceneBSp, Is.Not.Null);
            Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
            Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
        }
Esempio n. 15
0
        public void TestSameSimulatorNeighbouringRegionsTeleport()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            AttachmentsModule attModA = new AttachmentsModule();
            AttachmentsModule attModB = new AttachmentsModule();
            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);
            IConfig entityTransferConfig = config.AddConfig("EntityTransfer");

            // In order to run a single threaded regression test we do not want the entity transfer module waiting
            // for a callback from the destination scene before removing its avatar data.
            entityTransferConfig.Set("wait_for_callback", false);

            modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule");

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(
                sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule());
            SceneHelpers.SetupSceneModules(
                sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule());

            UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1);
            ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, ua1.PrincipalID, sh.SceneManager);
            beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);

            InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20);

            sceneA.AttachmentsModule.RezSingleAttachmentFromInventory(
                beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest);

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt = new Vector3(20, 21, 22);

            m_numberOfAttachEventsFired = 0;
            sceneA.RequestTeleportLocation(
                beforeTeleportSp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            ((TestClient)beforeTeleportSp.ControllingClient).CompleteTeleportClientSide();

            // Check attachments have made it into sceneB
            ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID);

            // This is appearance data, as opposed to actually rezzed attachments
            List<AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments();
            Assert.That(sceneBAttachments.Count, Is.EqualTo(1));
            Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
            Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID));
            Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
            Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));

            // This is the actual attachment
            List<SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments();
            Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1));
            SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0];
            Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name));
            Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest));

            Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1));

            // Check attachments have been removed from sceneA
            ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID);

            // Since this is appearance data, it is still present on the child avatar!
            List<AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments();
            Assert.That(sceneAAttachments.Count, Is.EqualTo(1));
            Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));

            // This is the actual attachment, which should no longer exist
            List<SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments();
            Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0));

            Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0));

            // Check events
            Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
        }
        public void TestSameSimulatorIsolatedRegions_DeniedOnCreateAgent()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);
            Vector3 preTeleportPosition = new Vector3(30, 31, 32);

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Modules");
            config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
            config.Configs["Modules"].Set("SimulationServices", lscm.Name);

            config.AddConfig("EntityTransfer");

            // In order to run a single threaded regression test we do not want the entity transfer module waiting
            // for a callback from the destination scene before removing its avatar data.
            config.Configs["EntityTransfer"].Set("wait_for_callback", false);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);

            SceneHelpers.SetupSceneModules(sceneA, config, etmA);
            SceneHelpers.SetupSceneModules(sceneB, config, etmB);

            // Shared scene modules
            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt = new Vector3(20, 21, 22);

            ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
            sp.AbsolutePosition = preTeleportPosition;

            // Make sceneB refuse CreateAgent
            sceneB.LoginsEnabled = false;

            sceneA.RequestTeleportLocation(
                sp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

//            ((TestClient)sp.ControllingClient).CompleteTeleportClientSide();

            Assert.That(sceneB.GetScenePresence(userId), Is.Null);

            ScenePresence sceneASp = sceneA.GetScenePresence(userId);
            Assert.That(sceneASp, Is.Not.Null);
            Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
            Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));

//            TestHelpers.DisableLogging();
        }
        public void TestCrossOnSameSimulatorPrimLimitsOkay()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);
            int sceneObjectIdTail = 0x2;

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
            LandManagementModule lmmA = new LandManagementModule();
            LandManagementModule lmmB = new LandManagementModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);

            IConfig permissionsConfig = config.AddConfig("Permissions");
            permissionsConfig.Set("permissionmodules", "PrimLimitsModule");

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(
                sceneA, config, etmA, lmmA, new PrimLimitsModule(), new PrimCountModule());
            SceneHelpers.SetupSceneModules(
                sceneB, config, etmB, lmmB, new PrimLimitsModule(), new PrimCountModule());

            // We must set up the parcel for this to work.  Normally this is taken care of by OpenSimulator startup
            // code which is not yet easily invoked by tests.
            lmmA.EventManagerOnNoLandDataFromStorage();
            lmmB.EventManagerOnNoLandDataFromStorage();

            SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
            UUID so1Id = so1.UUID;
            so1.AbsolutePosition = new Vector3(128, 10, 20);

            // Cross with a negative value.  We must make this call rather than setting AbsolutePosition directly
            // because only this will execute permission checks in the source region.
            sceneA.SceneGraph.UpdatePrimGroupPosition(so1.LocalId, new Vector3(128, -10, 20), userId);

            Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id));
            Assert.NotNull(sceneB.GetSceneObjectGroup(so1Id));
        }
        public void TestLoadWithNoParcels()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            SceneHelpers sh = new SceneHelpers();
            LandManagementModule lmm = new LandManagementModule();
            Scene scene = sh.SetupScene();            
            SceneHelpers.SetupSceneModules(scene, lmm);   

            scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID);

            ILandObject loAtCoord1 = lmm.GetLandObject(0, 0);
            Assert.That(loAtCoord1.LandData.LocalID, Is.Not.EqualTo(0));
            Assert.That(loAtCoord1.LandData.GlobalID, Is.Not.EqualTo(UUID.Zero));

            ILandObject loAtCoord2 = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1));
            Assert.That(loAtCoord2.LandData.LocalID, Is.EqualTo(loAtCoord1.LandData.LocalID));
            Assert.That(loAtCoord2.LandData.GlobalID, Is.EqualTo(loAtCoord1.LandData.GlobalID));
        }
        public void TestCrossOnSameSimulatorWithSittingAvatar()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);
            int sceneObjectIdTail = 0x2;
            Vector3 so1StartPos = new Vector3(128, 10, 20);

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);
            IConfig entityTransferConfig = config.AddConfig("EntityTransfer");

            // In order to run a single threaded regression test we do not want the entity transfer module waiting
            // for a callback from the destination scene before removing its avatar data.
            entityTransferConfig.Set("wait_for_callback", false);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);

            SceneObjectGroup so1 = SceneHelpers.AddSceneObject(sceneA, 1, userId, "", sceneObjectIdTail);
            UUID so1Id = so1.UUID;
            so1.AbsolutePosition = so1StartPos;

            AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
            TestClient tc = new TestClient(acd, sceneA);
            List<TestClient> destinationTestClients = new List<TestClient>();
            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

            ScenePresence sp1SceneA = SceneHelpers.AddScenePresence(sceneA, tc, acd);
            sp1SceneA.AbsolutePosition = so1StartPos;
            sp1SceneA.HandleAgentRequestSit(sp1SceneA.ControllingClient, sp1SceneA.UUID, so1.UUID, Vector3.Zero);

            // Cross
            sceneA.SceneGraph.UpdatePrimGroupPosition(
                so1.LocalId, new Vector3(so1StartPos.X, so1StartPos.Y - 20, so1StartPos.Z), userId);

            SceneObjectGroup so1PostCross;

            {
                ScenePresence sp1SceneAPostCross = sceneA.GetScenePresence(userId);
                Assert.IsTrue(sp1SceneAPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly false");

                ScenePresence sp1SceneBPostCross = sceneB.GetScenePresence(userId);
                TestClient sceneBTc = ((TestClient)sp1SceneBPostCross.ControllingClient);
                sceneBTc.CompleteMovement();

                Assert.IsFalse(sp1SceneBPostCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
                Assert.IsTrue(sp1SceneBPostCross.IsSatOnObject);

                Assert.IsNull(sceneA.GetSceneObjectGroup(so1Id), "uck");
                so1PostCross = sceneB.GetSceneObjectGroup(so1Id);
                Assert.NotNull(so1PostCross);
                Assert.AreEqual(1, so1PostCross.GetSittingAvatarsCount());
            }

            Vector3 so1PostCrossPos = so1PostCross.AbsolutePosition;

//            Console.WriteLine("CRISSCROSS");

            // Recross
            sceneB.SceneGraph.UpdatePrimGroupPosition(
                so1PostCross.LocalId, new Vector3(so1PostCrossPos.X, so1PostCrossPos.Y + 20, so1PostCrossPos.Z), userId);

            {
                ScenePresence sp1SceneBPostReCross = sceneB.GetScenePresence(userId);
                Assert.IsTrue(sp1SceneBPostReCross.IsChildAgent, "sp1SceneBPostReCross.IsChildAgent unexpectedly false");

                ScenePresence sp1SceneAPostReCross = sceneA.GetScenePresence(userId);
                TestClient sceneATc = ((TestClient)sp1SceneAPostReCross.ControllingClient);
                sceneATc.CompleteMovement();

                Assert.IsFalse(sp1SceneAPostReCross.IsChildAgent, "sp1SceneAPostCross.IsChildAgent unexpectedly true");
                Assert.IsTrue(sp1SceneAPostReCross.IsSatOnObject);

                Assert.IsNull(sceneB.GetSceneObjectGroup(so1Id), "uck2");
                SceneObjectGroup so1PostReCross = sceneA.GetSceneObjectGroup(so1Id);
                Assert.NotNull(so1PostReCross);
                Assert.AreEqual(1, so1PostReCross.GetSittingAvatarsCount());
            }
        }
Esempio n. 20
0
        public void TestScriptCrossOnSameSimulator()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);
            int sceneObjectIdTail = 0x2;

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();
            XEngine xEngineA = new XEngine();
            XEngine xEngineB = new XEngine();
            xEngineA.DebugLevel = 1;
            xEngineB.DebugLevel = 1;

            IConfigSource configSource = new IniConfigSource();

            IConfig startupConfig = configSource.AddConfig("Startup");
            startupConfig.Set("DefaultScriptEngine", "XEngine");
            startupConfig.Set("TrustBinaries", "true");

            IConfig xEngineConfig = configSource.AddConfig("XEngine");
            xEngineConfig.Set("Enabled", "true");
            xEngineConfig.Set("StartDelay", "0");

            // These tests will not run with AppDomainLoading = true, at least on mono.  For unknown reasons, the call
            // to AssemblyResolver.OnAssemblyResolve fails.
            xEngineConfig.Set("AppDomainLoading", "false");

            IConfig modulesConfig = configSource.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000, configSource);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999, configSource);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, configSource, lscm);
            SceneHelpers.SetupSceneModules(sceneA, configSource, etmA, xEngineA);
            SceneHelpers.SetupSceneModules(sceneB, configSource, etmB, xEngineB);
            sceneA.StartScripts();
            sceneB.StartScripts();

            SceneObjectGroup soSceneA = SceneHelpers.AddSceneObject(sceneA, 1, userId, "so1-", sceneObjectIdTail);
            soSceneA.AbsolutePosition = new Vector3(128, 10, 20);

            string soSceneAName = soSceneA.Name;
            string scriptItemSceneAName = "script1";

            // CREATE SCRIPT TODO
            InventoryItemBase scriptItemSceneA = new InventoryItemBase();
            //            itemTemplate.ID = itemId;
            scriptItemSceneA.Name = scriptItemSceneAName;
            scriptItemSceneA.Folder = soSceneA.UUID;
            scriptItemSceneA.InvType = (int)InventoryType.LSL;

            AutoResetEvent chatEvent = new AutoResetEvent(false);
            OSChatMessage messageReceived = null;
            sceneA.EventManager.OnChatFromWorld += (s, m) => { messageReceived = m; chatEvent.Set(); };

            sceneA.RezNewScript(userId, scriptItemSceneA, 
@"integer c = 0;

default
{    
    state_entry()
    {
        llSay(0, ""Script running"");
    }

    changed(integer change)
    {
        llSay(0, ""Changed"");
    }

    touch_start(integer n)
    {
        c = c + 1; 
        llSay(0, (string)c);
    }
}");

            chatEvent.WaitOne(60000);

            Assert.That(messageReceived, Is.Not.Null, "No chat message received.");
            Assert.That(messageReceived.Message, Is.EqualTo("Script running"));           

            {
                // XXX: Should not be doing this so directly.  Should call some variant of EventManager.touch() instead.
                DetectParams[] det = new DetectParams[1];
                det[0] = new DetectParams();
                det[0].Key = userId;
                det[0].Populate(sceneA);

                EventParams ep = new EventParams("touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, det);

                messageReceived = null;
                chatEvent.Reset();
                xEngineA.PostObjectEvent(soSceneA.LocalId, ep);
                chatEvent.WaitOne(60000);

                Assert.That(messageReceived.Message, Is.EqualTo("1")); 
            }

            AutoResetEvent chatEventB = new AutoResetEvent(false);
            sceneB.EventManager.OnChatFromWorld += (s, m) => { messageReceived = m; chatEventB.Set(); };

            messageReceived = null;
            chatEventB.Reset();
            // Cross with a negative value
            soSceneA.AbsolutePosition = new Vector3(128, -10, 20);

            chatEventB.WaitOne(60000);
            Assert.That(messageReceived, Is.Not.Null, "No Changed message received.");
            Assert.That(messageReceived.Message, Is.Not.Null, "Changed message without content");
            Assert.That(messageReceived.Message, Is.EqualTo("Changed")); 

            // TEST sending event to moved prim and output
            {
                SceneObjectGroup soSceneB = sceneB.GetSceneObjectGroup(soSceneAName);
                TaskInventoryItem scriptItemSceneB = soSceneB.RootPart.Inventory.GetInventoryItem(scriptItemSceneAName);

                // XXX: Should not be doing this so directly.  Should call some variant of EventManager.touch() instead.
                DetectParams[] det = new DetectParams[1];
                det[0] = new DetectParams();
                det[0].Key = userId;
                det[0].Populate(sceneB);

                EventParams ep = new EventParams("touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, det);

                Thread.Sleep(250); // wait for other change messages to pass
                messageReceived = null;
                chatEventB.Reset();
                xEngineB.PostObjectEvent(soSceneB.LocalId, ep);
                chatEventB.WaitOne(60000);

                Assert.That(messageReceived.Message, Is.EqualTo("2")); 
            }
        }
        public void TestSameSimulatorNeighbouringRegionsV1()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);
            IConfig entityTransferConfig = config.AddConfig("EntityTransfer");

            // In order to run a single threaded regression test we do not want the entity transfer module waiting
            // for a callback from the destination scene before removing its avatar data.
            entityTransferConfig.Set("wait_for_callback", false);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);

            // FIXME: Hack - this is here temporarily to revert back to older entity transfer behaviour
            lscm.ServiceVersion = "SIMULATION/0.1";

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt = new Vector3(20, 21, 22);

            AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
            TestClient tc = new TestClient(acd, sceneA);
            List<TestClient> destinationTestClients = new List<TestClient>();
            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

            ScenePresence beforeSceneASp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
            beforeSceneASp.AbsolutePosition = new Vector3(30, 31, 32);

            Assert.That(beforeSceneASp, Is.Not.Null);
            Assert.That(beforeSceneASp.IsChildAgent, Is.False);

            ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
            Assert.That(beforeSceneBSp, Is.Not.Null);
            Assert.That(beforeSceneBSp.IsChildAgent, Is.True);

            // In this case, we will not receieve a second InformClientOfNeighbour since the viewer already knows
            // about the neighbour region it is teleporting to.
            sceneA.RequestTeleportLocation(
                beforeSceneASp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            destinationTestClients[0].CompleteMovement();

            ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
            Assert.That(afterSceneASp, Is.Not.Null);
            Assert.That(afterSceneASp.IsChildAgent, Is.True);

            ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
            Assert.That(afterSceneBSp, Is.Not.Null);
            Assert.That(afterSceneBSp.IsChildAgent, Is.False);
            Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
            Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));

//            TestHelpers.DisableLogging();
        }
        public void TestCrossOnSameSimulator()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

//            TestEventQueueGetModule eqmA = new TestEventQueueGetModule();
            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);
//            IConfig entityTransferConfig = config.AddConfig("EntityTransfer");

            // In order to run a single threaded regression test we do not want the entity transfer module waiting
            // for a callback from the destination scene before removing its avatar data.
//            entityTransferConfig.Set("wait_for_callback", false);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
//            SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA, eqmA);
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);

            AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
            TestClient tc = new TestClient(acd, sceneA);
            List<TestClient> destinationTestClients = new List<TestClient>();
            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

            ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
            originalSp.AbsolutePosition = new Vector3(128, 32, 10);

//            originalSp.Flying = true;

//            Console.WriteLine("First pos {0}", originalSp.AbsolutePosition);

//            eqmA.ClearEvents();

            AgentUpdateArgs moveArgs = new AgentUpdateArgs();
            //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
            moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
            moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
            moveArgs.SessionID = acd.SessionID;

            originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);

            sceneA.Update(1);

//            Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);

            // FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
            // But really we want to do this in a more robust way.
            for (int i = 0; i < 100; i++)
            {
                sceneA.Update(1);
//                Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
            }

            // Need to sort processing of EnableSimulator message on adding scene presences before we can test eqm
            // messages
//            Dictionary<UUID, List<TestEventQueueGetModule.Event>> eqmEvents = eqmA.Events;
//
//            Assert.That(eqmEvents.Count, Is.EqualTo(1));
//            Assert.That(eqmEvents.ContainsKey(originalSp.UUID), Is.True);
//
//            List<TestEventQueueGetModule.Event> spEqmEvents = eqmEvents[originalSp.UUID];
//
//            Assert.That(spEqmEvents.Count, Is.EqualTo(1));
//            Assert.That(spEqmEvents[0].Name, Is.EqualTo("CrossRegion"));

            // sceneA should now only have a child agent
            ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
            Assert.That(spAfterCrossSceneA.IsChildAgent, Is.True);

            ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);

            // Agent remains a child until the client triggers complete movement
            Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);

            TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);

            int agentMovementCompleteReceived = 0;
            sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;

            sceneBTc.CompleteMovement();

            Assert.That(agentMovementCompleteReceived, Is.EqualTo(1));
            Assert.That(spAfterCrossSceneB.IsChildAgent, Is.False);
        }
        public void TestCreateChildScenePresence()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            LocalSimulationConnectorModule lsc = new LocalSimulationConnectorModule();

            IConfigSource configSource = new IniConfigSource();
            IConfig config = configSource.AddConfig("Modules");
            config.Set("SimulationServices", "LocalSimulationConnectorModule");

            SceneHelpers sceneHelpers = new SceneHelpers();
            TestScene scene = sceneHelpers.SetupScene();
            SceneHelpers.SetupSceneModules(scene, configSource, lsc);

            UUID agentId = TestHelpers.ParseTail(0x01);
            AgentCircuitData acd = SceneHelpers.GenerateAgentData(agentId);
            acd.child = true;

            GridRegion region = scene.GridService.GetRegionByName(UUID.Zero, scene.RegionInfo.RegionName);
            string reason;

            // *** This is the first stage, when a neighbouring region is told that a viewer is about to try and
            // establish a child scene presence.  We pass in the circuit code that the client has to connect with ***
            // XXX: ViaLogin may not be correct here.
            scene.SimulationService.CreateAgent(region, acd, (uint)TeleportFlags.ViaLogin, out reason);

            Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null);
            Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));

            // There's no scene presence yet since only an agent circuit has been established.
            Assert.That(scene.GetScenePresence(agentId), Is.Null);

            // *** This is the second stage, where the client established a child agent/scene presence using the
            // circuit code given to the scene in stage 1 ***
            TestClient client = new TestClient(acd, scene);
            scene.AddNewClient(client, PresenceType.User);

            Assert.That(scene.AuthenticateHandler.GetAgentCircuitData(agentId), Is.Not.Null);
            Assert.That(scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));

            ScenePresence sp = scene.GetScenePresence(agentId);
            Assert.That(sp, Is.Not.Null);
            Assert.That(sp.UUID, Is.EqualTo(agentId));
            Assert.That(sp.IsChildAgent, Is.True);
        }
        public void TestSameSimulatorIsolatedRegionsV2()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);

            SceneHelpers.SetupSceneModules(sceneA, config, etmA);
            SceneHelpers.SetupSceneModules(sceneB, config, etmB);
            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt = new Vector3(20, 21, 22);

            ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
            sp.AbsolutePosition = new Vector3(30, 31, 32);

            List<TestClient> destinationTestClients = new List<TestClient>();
            EntityTransferHelpers.SetupSendRegionTeleportTriggersDestinationClientCreateAndCompleteMovement(
                (TestClient)sp.ControllingClient, destinationTestClients);

            sceneA.RequestTeleportLocation(
                sp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            Assert.That(sceneA.GetScenePresence(userId), Is.Null);

            ScenePresence sceneBSp = sceneB.GetScenePresence(userId);
            Assert.That(sceneBSp, Is.Not.Null);
            Assert.That(sceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
            Assert.That(sceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));
        }
        public void TestLoad()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

            SceneHelpers sh = new SceneHelpers();
            LandManagementModule lmm = new LandManagementModule();
            Scene scene = sh.SetupScene();            
            SceneHelpers.SetupSceneModules(scene, lmm);   

            ILandObject originalLo1 = new LandObject(userId, false, scene);
            originalLo1.LandData.Name = "lo1";
            originalLo1.SetLandBitmap(
                originalLo1.GetSquareLandBitmap(0, 0, (int)Constants.RegionSize, (int)Constants.RegionSize / 2));

            sh.SimDataService.StoreLandObject(originalLo1);

            ILandObject originalLo2 = new LandObject(userId, false, scene);
            originalLo2.LandData.Name = "lo2";
            originalLo2.SetLandBitmap(
                originalLo2.GetSquareLandBitmap(0, (int)Constants.RegionSize / 2, (int)Constants.RegionSize, (int)Constants.RegionSize));

            sh.SimDataService.StoreLandObject(originalLo2);

            scene.loadAllLandObjectsFromStorage(scene.RegionInfo.RegionID);

            {
                ILandObject loAtCoord = lmm.GetLandObject(0, 0);
                Assert.That(loAtCoord.LandData.Name, Is.EqualTo(originalLo1.LandData.Name));
                Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(originalLo1.LandData.GlobalID));                          
            }

            {
                ILandObject loAtCoord = lmm.GetLandObject((int)Constants.RegionSize - 1, ((int)Constants.RegionSize - 1));
                Assert.That(loAtCoord.LandData.Name, Is.EqualTo(originalLo2.LandData.Name));
                Assert.That(loAtCoord.LandData.GlobalID, Is.EqualTo(originalLo2.LandData.GlobalID));
            }
        }
        public void TestSameSimulatorIsolatedRegions_DestinationDidNotProcessViewerConnection()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);
            Vector3 preTeleportPosition = new Vector3(30, 31, 32);

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();

            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            config.AddConfig("Modules");
            config.Configs["Modules"].Set("EntityTransferModule", etmA.Name);
            config.Configs["Modules"].Set("SimulationServices", lscm.Name);

            config.AddConfig("EntityTransfer");

            // In order to run a single threaded regression test we do not want the entity transfer module waiting
            // for a callback from the destination scene before removing its avatar data.
            config.Configs["EntityTransfer"].Set("wait_for_callback", false);

//            config.AddConfig("Startup");
//            config.Configs["Startup"].Set("serverside_object_permissions", true);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1002, 1000);

            SceneHelpers.SetupSceneModules(sceneA, config, etmA );

            // We need to set up the permisions module on scene B so that our later use of agent limit to deny
            // QueryAccess won't succeed anyway because administrators are always allowed in and the default
            // IsAdministrator if no permissions module is present is true.
            SceneHelpers.SetupSceneModules(sceneB, config, new object[] { new DefaultPermissionsModule(), etmB });

            // Shared scene modules
            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt = new Vector3(20, 21, 22);

            ScenePresence sp = SceneHelpers.AddScenePresence(sceneA, userId);
            sp.AbsolutePosition = preTeleportPosition;

            sceneA.RequestTeleportLocation(
                sp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            // FIXME: Not setting up InformClientOfNeighbour on the TestClient means that it does not initiate 
            // communication with the destination region.  But this is a very non-obvious way of doing it - really we
            // should be forced to expicitly set this up.

            Assert.That(sceneB.GetScenePresence(userId), Is.Null);

            ScenePresence sceneASp = sceneA.GetScenePresence(userId);
            Assert.That(sceneASp, Is.Not.Null);
            Assert.That(sceneASp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneA.RegionInfo.RegionName));
            Assert.That(sceneASp.AbsolutePosition, Is.EqualTo(preTeleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));

//            TestHelpers.DisableLogging();
        }
        public void TestCrossOnSameSimulatorNoRootDestPerm()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1000, 999);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);

            // We need to set up the permisions module on scene B so that our later use of agent limit to deny
            // QueryAccess won't succeed anyway because administrators are always allowed in and the default
            // IsAdministrator if no permissions module is present is true.
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), new DefaultPermissionsModule(), etmB);

            AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);
            TestClient tc = new TestClient(acd, sceneA);
            List<TestClient> destinationTestClients = new List<TestClient>();
            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

            // Make sure sceneB will not accept this avatar.
            sceneB.RegionInfo.EstateSettings.PublicAccess = false;

            ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
            originalSp.AbsolutePosition = new Vector3(128, 32, 10);

            AgentUpdateArgs moveArgs = new AgentUpdateArgs();
            //moveArgs.BodyRotation = Quaternion.CreateFromEulers(Vector3.Zero);
            moveArgs.BodyRotation = Quaternion.CreateFromEulers(new Vector3(0, 0, (float)-(Math.PI / 2)));
            moveArgs.ControlFlags = (uint)AgentManager.ControlFlags.AGENT_CONTROL_AT_POS;
            moveArgs.SessionID = acd.SessionID;

            originalSp.HandleAgentUpdate(originalSp.ControllingClient, moveArgs);

            sceneA.Update(1);

//            Console.WriteLine("Second pos {0}", originalSp.AbsolutePosition);

            // FIXME: This is a sufficient number of updates to for the presence to reach the northern border.
            // But really we want to do this in a more robust way.
            for (int i = 0; i < 100; i++)
            {
                sceneA.Update(1);
//                Console.WriteLine("Pos {0}", originalSp.AbsolutePosition);
            }

            // sceneA agent should still be root
            ScenePresence spAfterCrossSceneA = sceneA.GetScenePresence(originalSp.UUID);
            Assert.That(spAfterCrossSceneA.IsChildAgent, Is.False);

            ScenePresence spAfterCrossSceneB = sceneB.GetScenePresence(originalSp.UUID);

            // sceneB agent should still be child
            Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);

            // sceneB should ignore unauthorized attempt to upgrade agent to root
            TestClient sceneBTc = ((TestClient)spAfterCrossSceneB.ControllingClient);

            int agentMovementCompleteReceived = 0;
            sceneBTc.OnReceivedMoveAgentIntoRegion += (ri, pos, look) => agentMovementCompleteReceived++;

            sceneBTc.CompleteMovement();

            Assert.That(agentMovementCompleteReceived, Is.EqualTo(0));
            Assert.That(spAfterCrossSceneB.IsChildAgent, Is.True);
        }
Esempio n. 28
0
        public void TestSameSimulatorNeighbouringRegionsTeleportV2()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            BaseHttpServer httpServer = new BaseHttpServer(99999);
            MainServer.AddHttpServer(httpServer);
            MainServer.Instance = httpServer;

            AttachmentsModule attModA = new AttachmentsModule();
            AttachmentsModule attModB = new AttachmentsModule();
            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);

            modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule");

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(
                sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule());
            SceneHelpers.SetupSceneModules(
                sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule());

            UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1);

            AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);
            TestClient tc = new TestClient(acd, sceneA);
            List<TestClient> destinationTestClients = new List<TestClient>();
            EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients);

            ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd);
            beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32);

            Assert.That(destinationTestClients.Count, Is.EqualTo(1));
            Assert.That(destinationTestClients[0], Is.Not.Null);

            InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20);

            sceneA.AttachmentsModule.RezSingleAttachmentFromInventory(
                beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest);

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt = new Vector3(20, 21, 22);

            // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement().  This
            // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to
            // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt
            // Both these operations will occur on different threads and will wait for each other.
            // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1
            // test protocol, where we are trying to avoid unpredictable async operations in regression tests.
            tc.OnTestClientSendRegionTeleport 
                += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) 
                    => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null);

            m_numberOfAttachEventsFired = 0;
            sceneA.RequestTeleportLocation(
                beforeTeleportSp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            // Check attachments have made it into sceneB
            ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID);

            // This is appearance data, as opposed to actually rezzed attachments
            List<AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments();
            Assert.That(sceneBAttachments.Count, Is.EqualTo(1));
            Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
            Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID));
            Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
            Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));

            // This is the actual attachment
            List<SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments();
            Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1));
            SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0];
            Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name));
            Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest));
            Assert.IsFalse(actualSceneBAtt.Backup);

            Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1));

            // Check attachments have been removed from sceneA
            ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID);

            // Since this is appearance data, it is still present on the child avatar!
            List<AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments();
            Assert.That(sceneAAttachments.Count, Is.EqualTo(1));
            Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));

            // This is the actual attachment, which should no longer exist
            List<SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments();
            Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0));

            Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0));

            // Check events
            Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
        }
        public void TestSameSimulatorNeighbouringRegionsTeleport()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            UUID userId = TestHelpers.ParseTail(0x1);

            EntityTransferModule etmA = new EntityTransferModule();
            EntityTransferModule etmB = new EntityTransferModule();
            LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule();

            IConfigSource config = new IniConfigSource();
            IConfig modulesConfig = config.AddConfig("Modules");
            modulesConfig.Set("EntityTransferModule", etmA.Name);
            modulesConfig.Set("SimulationServices", lscm.Name);
            IConfig entityTransferConfig = config.AddConfig("EntityTransfer");

            // In order to run a single threaded regression test we do not want the entity transfer module waiting
            // for a callback from the destination scene before removing its avatar data.
            entityTransferConfig.Set("wait_for_callback", false);

            SceneHelpers sh = new SceneHelpers();
            TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000);
            TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000);

            SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm);
            SceneHelpers.SetupSceneModules(sceneA, config, new CapabilitiesModule(), etmA);
            SceneHelpers.SetupSceneModules(sceneB, config, new CapabilitiesModule(), etmB);

            Vector3 teleportPosition = new Vector3(10, 11, 12);
            Vector3 teleportLookAt = new Vector3(20, 21, 22);

            ScenePresence originalSp = SceneHelpers.AddScenePresence(sceneA, userId, sh.SceneManager);
            originalSp.AbsolutePosition = new Vector3(30, 31, 32);

            ScenePresence beforeSceneASp = sceneA.GetScenePresence(userId);
            Assert.That(beforeSceneASp, Is.Not.Null);
            Assert.That(beforeSceneASp.IsChildAgent, Is.False);

            ScenePresence beforeSceneBSp = sceneB.GetScenePresence(userId);
            Assert.That(beforeSceneBSp, Is.Not.Null);
            Assert.That(beforeSceneBSp.IsChildAgent, Is.True);

            // XXX: A very nasty hack to tell the client about the destination scene without having to crank the whole
            // UDP stack (?)
//            ((TestClient)beforeSceneASp.ControllingClient).TeleportTargetScene = sceneB;

            sceneA.RequestTeleportLocation(
                beforeSceneASp.ControllingClient,
                sceneB.RegionInfo.RegionHandle,
                teleportPosition,
                teleportLookAt,
                (uint)TeleportFlags.ViaLocation);

            ((TestClient)beforeSceneASp.ControllingClient).CompleteTeleportClientSide();

            ScenePresence afterSceneASp = sceneA.GetScenePresence(userId);
            Assert.That(afterSceneASp, Is.Not.Null);
            Assert.That(afterSceneASp.IsChildAgent, Is.True);

            ScenePresence afterSceneBSp = sceneB.GetScenePresence(userId);
            Assert.That(afterSceneBSp, Is.Not.Null);
            Assert.That(afterSceneBSp.IsChildAgent, Is.False);
            Assert.That(afterSceneBSp.Scene.RegionInfo.RegionName, Is.EqualTo(sceneB.RegionInfo.RegionName));
            Assert.That(afterSceneBSp.AbsolutePosition, Is.EqualTo(teleportPosition));

            Assert.That(sceneA.GetRootAgentCount(), Is.EqualTo(0));
            Assert.That(sceneA.GetChildAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetRootAgentCount(), Is.EqualTo(1));
            Assert.That(sceneB.GetChildAgentCount(), Is.EqualTo(0));

            // TODO: Add assertions to check correct circuit details in both scenes.

            // Lookat is sent to the client only - sp.Lookat does not yield the same thing (calculation from camera
            // position instead).
//            Assert.That(sp.Lookat, Is.EqualTo(teleportLookAt));

//            TestHelpers.DisableLogging();
        }