fix: Exempts localhost from IPLimiter. Preps testing for io_uring (#2316)

### Summary
* Exempts localhost from IPLimiter
* Updates tests to have proper sequential testing with packets
* Updates tests to clean up NetState
This commit is contained in:
Kamron Batman 2026-01-20 08:54:15 -08:00 committed by GitHub
parent 8133983b64
commit 1e4c32c809
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
77 changed files with 4612 additions and 4616 deletions

View file

@ -2,6 +2,7 @@ using System;
using System.Reflection;
using Server.Items;
using Server.Misc;
using Server.Tests.Maps;
using Xunit;
namespace Server.Tests;

View file

@ -5,6 +5,7 @@ using Xunit;
namespace UOContent.Tests;
[Collection("Sequential Server Tests")]
public class ChatPacketTests
{
[Theory]
@ -14,7 +15,7 @@ public class ChatPacketTests
{
var expected = new ChatMessagePacket(lang, number, param1, param2).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendChatMessage(lang, number, param1, param2);
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -6,6 +6,7 @@ using Xunit;
namespace UOContent.Tests;
[Collection("Sequential UOContent Tests")]
public class TestHelpTopicPacket
{
[Theory]
@ -15,7 +16,7 @@ public class TestHelpTopicPacket
{
var expected = new DisplayHelpTopic(topic, display).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendDisplayHelpTopic(topic, display);
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -5,6 +5,7 @@ using Xunit;
namespace Server.Engines.MLQuests;
[Collection("Sequential UOContent Tests")]
public class MLQuestPacketTests
{
private class MockedRace : Race
@ -69,7 +70,7 @@ public class MLQuestPacketTests
var expected = new RaceChanger(female, race).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendRaceChanger(female, race);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -81,7 +82,7 @@ public class MLQuestPacketTests
{
var expected = new CloseRaceChanger().Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendCloseRaceChanger();
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -16,7 +16,7 @@ public class PartyPacketTests
var expected = new PartyEmptyList(m).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendPartyRemoveMember(m);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -37,7 +37,7 @@ public class PartyPacketTests
var expected = new PartyRemoveMember(member.Serial, p).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendPartyRemoveMember(member.Serial, p);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -58,7 +58,7 @@ public class PartyPacketTests
var expected = new PartyMemberList(p).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendPartyMemberList(p);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -75,7 +75,7 @@ public class PartyPacketTests
var expected = new PartyTextMessage(toAll, serial, text).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendPartyTextMessage(serial, text, toAll);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -89,7 +89,7 @@ public class PartyPacketTests
var expected = new PartyInvitation(m).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendPartyInvitation(m);
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -7,6 +7,7 @@ using Xunit;
namespace UOContent.Tests;
[Collection("Sequential Server Tests")]
public class CharacterStatuePacketTests
{
[Theory]
@ -15,7 +16,7 @@ public class CharacterStatuePacketTests
{
var expected = new UpdateStatueAnimation((Serial)s, status, anim, frame).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendStatueAnimation((Serial)s, status, anim, frame);
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -47,7 +47,7 @@ public class BookPacketTests
var expected = new BookHeader(m, book).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendBookCover(m, book);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -84,7 +84,7 @@ public class BookPacketTests
var expected = new BookPageDetails(book).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendBookContent(book);
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -20,7 +20,7 @@ public class BulletinBoardPacketTests
var expected = new BBDisplayBoard(bb).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendBBDisplayBoard(bb);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -47,7 +47,7 @@ public class BulletinBoardPacketTests
var expected = (content ?
(Packet)new BBMessageContent(bb, msg) : new BBMessageHeader(bb, msg)).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendBBMessage(bb, msg, content);
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -16,7 +16,7 @@ public class MahjongPacketTests
var expected = new MahjongJoinGame(game).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendMahjongJoinGame(game);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -36,7 +36,7 @@ public class MahjongPacketTests
var expected = new MahjongPlayersInfo(game, m).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendMahjongPlayersInfo(game, m);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -54,7 +54,7 @@ public class MahjongPacketTests
var expected = new MahjongGeneralInfo(game).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendMahjongGeneralInfo(game);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -74,7 +74,7 @@ public class MahjongPacketTests
var expected = new MahjongTilesInfo(game, m).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendMahjongTilesInfo(game, m);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -94,7 +94,7 @@ public class MahjongPacketTests
var expected = new MahjongTileInfo(game.Tiles[0], m).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendMahjongTileInfo(game.Tiles[0], m);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -108,7 +108,7 @@ public class MahjongPacketTests
var expected = new MahjongRelieve(game).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendMahjongRelieve(game);
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -17,7 +17,7 @@ public class TestMapItemPackets
{
var mapItem = new MapItem(Map.Trammel);
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.ProtocolChanges = changes;
var expected = (ns.NewCharacterList ?
@ -39,7 +39,7 @@ public class TestMapItemPackets
var expected = new MapCommand(mapItem, command, number, x, y).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendMapCommand(mapItem, command, x, y, number > 0);
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -23,7 +23,7 @@ public class CorpsePacketTests
var expected = new CorpseEquip(m, c).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendCorpseEquip(m, c);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -43,7 +43,7 @@ public class CorpsePacketTests
var c = new Corpse(m, m.Items);
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.ProtocolChanges = changes;
var expected = (ns.ContainerGridLines ? (Packet)new CorpseContent6017(m, c) : new CorpseContent(m, c)).Compile();

View file

@ -5,6 +5,7 @@ using Xunit;
namespace UOContent.Tests;
[Collection("Sequential UOContent Tests")]
public class WeaponAbilityPacketTests
{
[Theory]
@ -16,7 +17,7 @@ public class WeaponAbilityPacketTests
{
var expected = new ToggleSpecialAbility(abilityId, active).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendToggleSpecialAbility(abilityId, active);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -28,7 +29,7 @@ public class WeaponAbilityPacketTests
{
var expected = new ClearWeaponAbility().Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendClearWeaponAbility();
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -53,7 +53,7 @@ public class BoatPacketTests
beholder.CanSeeEntities.Add(boat);
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.ProtocolChanges = ProtocolChanges.HighSeas;
var expected = new MoveBoatHS(beholder, boat, d, speed, list, xOffset, yOffset).Compile();
@ -96,7 +96,7 @@ public class BoatPacketTests
beholder.CanSeeEntities.Add(boat);
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.ProtocolChanges = ProtocolChanges.HighSeas;
var expected = new DisplayBoatHS(beholder, boat).Compile();

View file

@ -8,6 +8,7 @@ using Xunit;
namespace UOContent.Tests;
[Collection("Sequential UOContent Tests")]
public class HousePacketTests
{
[Theory]
@ -16,7 +17,7 @@ public class HousePacketTests
{
var expected = new BeginHouseCustomization((Serial)serial).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendBeginHouseCustomization((Serial)serial);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -29,7 +30,7 @@ public class HousePacketTests
{
var expected = new EndHouseCustomization((Serial)serial).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendEndHouseCustomization((Serial)serial);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -43,7 +44,7 @@ public class HousePacketTests
{
var expected = new DesignStateGeneral((Serial)serial, revision).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendDesignStateGeneral((Serial)serial, revision);
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -3,6 +3,7 @@ using Xunit;
namespace Server.Tests.Network;
[Collection("Sequential UOContent Tests")]
public class ArrowPacketTests
{
[Fact]
@ -10,7 +11,7 @@ public class ArrowPacketTests
{
var expected = new CancelArrow().Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendCancelArrow(0, 0, Serial.Zero);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -25,7 +26,7 @@ public class ArrowPacketTests
{
var expected = new SetArrow(x, y).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendSetArrow(x, y, Serial.Zero);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -42,7 +43,7 @@ public class ArrowPacketTests
var expected = new CancelArrowHS(x, y, serial).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.ProtocolChanges = ProtocolChanges.HighSeas;
ns.SendCancelArrow(x, y, serial);
@ -60,7 +61,7 @@ public class ArrowPacketTests
var expected = new SetArrowHS(x, y, serial).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.ProtocolChanges = ProtocolChanges.HighSeas;
ns.SendSetArrow(x, y, serial);

View file

@ -8,6 +8,7 @@ using Xunit;
namespace UOContent.Tests;
[Collection("Sequential UOContent Tests")]
public class BuffIconPacketTests
{
[Theory]
@ -20,7 +21,7 @@ public class BuffIconPacketTests
(Serial)mob, iconID, titleCliloc, secondaryCliloc, args, timeSpan
).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendAddBuffPacket((Serial)mob, iconID, titleCliloc, secondaryCliloc, args, (int)timeSpan.TotalMilliseconds);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -34,7 +35,7 @@ public class BuffIconPacketTests
var buffIcon = BuffIcon.Disguised;
var expected = new RemoveBuffPacket(m, buffIcon).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendRemoveBuffPacket(m, buffIcon);
var result = ns.SendPipe.Reader.AvailableToRead();

View file

@ -24,7 +24,7 @@ public class SkillPacketsTests
var expected = new SkillChange(skill).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendSkillChange(skill);
var result = ns.SendPipe.Reader.AvailableToRead();
@ -42,7 +42,7 @@ public class SkillPacketsTests
var expected = new SkillUpdate(skills).Compile();
var ns = PacketTestUtilities.CreateTestNetState();
using var ns = PacketTestUtilities.CreateTestNetState();
ns.SendSkillsUpdate(skills);
var result = ns.SendPipe.Reader.AvailableToRead();