mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-02-14 19:29:36 +01:00
* WebSocket-based data transfer system * Move resource downloads/uploads to the new transfer system Should drastically increase the permitted practical size * Transfer impl for Lidgren * Async impl for receive stream * Use unbounded channel for Lidgren * Add metrics * More comments * Add serverside stream limit to avoid being a DoS vector * Fix tests * Oops forgot to actually implement sequence channels in NetMessage * Doc comment for NetMessage.SequenceChannel * Release notes
93 lines
3.6 KiB
C#
93 lines
3.6 KiB
C#
using System;
|
|
using System.IO;
|
|
using Moq;
|
|
using NUnit.Framework;
|
|
using Robust.Server;
|
|
using Robust.Server.Configuration;
|
|
using Robust.Server.Network.Transfer;
|
|
using Robust.Server.Player;
|
|
using Robust.Server.Reflection;
|
|
using Robust.Server.Serialization;
|
|
using Robust.Server.ServerStatus;
|
|
using Robust.Shared.Asynchronous;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.ContentPack;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Log;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Network.Transfer;
|
|
using Robust.Shared.Profiling;
|
|
using Robust.Shared.Reflection;
|
|
using Robust.Shared.Replays;
|
|
using Robust.Shared.Serialization;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Robust.UnitTesting.Shared.GameObjects
|
|
{
|
|
[TestFixture, Serializable]
|
|
sealed class EntityState_Tests
|
|
{
|
|
/// <summary>
|
|
/// Used to measure the size of <see cref="object"/>s in bytes. This is not actually a test,
|
|
/// but a useful benchmark tool, so i'm leaving it here.
|
|
/// </summary>
|
|
[Test]
|
|
public void ComponentChangedSerialized()
|
|
{
|
|
var container = new DependencyCollection();
|
|
container.Register<ILogManager, LogManager>();
|
|
container.Register<IConfigurationManager, ServerNetConfigurationManager>();
|
|
container.Register<IConfigurationManagerInternal, ServerNetConfigurationManager>();
|
|
container.Register<INetManager, NetManager>();
|
|
container.Register<IHWId, DummyHWId>();
|
|
container.Register<IReflectionManager, ServerReflectionManager>();
|
|
container.Register<IRobustSerializer, ServerRobustSerializer>();
|
|
container.Register<IRobustMappedStringSerializer, RobustMappedStringSerializer>();
|
|
container.Register<IAuthManager, AuthManager>();
|
|
container.Register<IGameTiming, GameTiming>();
|
|
container.Register<ProfManager, ProfManager>();
|
|
container.RegisterInstance<ITransferManager>(Mock.Of<ITransferManager>());
|
|
container.Register<HttpClientHolder>();
|
|
container.RegisterInstance<IReplayRecordingManager>(new Mock<IReplayRecordingManager>().Object);
|
|
container.BuildGraph();
|
|
|
|
var cfg = container.Resolve<IConfigurationManagerInternal>();
|
|
cfg.Initialize(true);
|
|
cfg.LoadCVarsFromAssembly(typeof(IConfigurationManager).Assembly);
|
|
|
|
container.Resolve<IReflectionManager>().LoadAssemblies(AppDomain.CurrentDomain.GetAssemblyByName("Robust.Shared"));
|
|
|
|
IoCManager.InitThread(container, replaceExisting: true);
|
|
|
|
cfg.LoadCVarsFromAssembly(typeof(IConfigurationManager).Assembly); // Robust.Shared
|
|
|
|
container.Resolve<INetManager>().Initialize(true);
|
|
|
|
var serializer = container.Resolve<IRobustSerializer>();
|
|
serializer.Initialize();
|
|
IoCManager.Resolve<IRobustMappedStringSerializer>().LockStrings();
|
|
|
|
byte[] array;
|
|
using(var stream = new MemoryStream())
|
|
{
|
|
var payload = new EntityState(
|
|
new NetEntity(64),
|
|
new []
|
|
{
|
|
new ComponentChange(0, new MapGridComponentDeltaState(16, chunkData: null, default), default)
|
|
}, default);
|
|
|
|
serializer.Serialize(stream, payload);
|
|
array = stream.ToArray();
|
|
}
|
|
|
|
IoCManager.Clear();
|
|
|
|
Assert.Pass($"Size in Bytes: {array.Length.ToString()}");
|
|
}
|
|
}
|
|
}
|