diff --git a/ArchiSteamFarm.Tests/Trading.cs b/ArchiSteamFarm.Tests/Trading.cs index a2ee00fb2..ca2006c9c 100644 --- a/ArchiSteamFarm.Tests/Trading.cs +++ b/ArchiSteamFarm.Tests/Trading.cs @@ -52,6 +52,30 @@ public sealed class Trading { Assert.IsFalse(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive)); } + [TestMethod] + public void Issue3203() { + HashSet inventory = [ + CreateItem(1, amount: 2), + CreateItem(2, amount: 6), + CreateItem(3), + CreateItem(4) + ]; + + HashSet itemsToGive = [ + CreateItem(1), + CreateItem(2, amount: 2) + ]; + + HashSet itemsToReceive = [ + CreateItem(5), + CreateItem(6), + CreateItem(7) + ]; + + Assert.IsTrue(IsFairExchange(itemsToGive, itemsToReceive)); + Assert.IsTrue(IsTradeNeutralOrBetter(inventory, itemsToGive, itemsToReceive)); + } + [TestMethod] public void MismatchRarityIsNotFair() { HashSet itemsToGive = [ diff --git a/ArchiSteamFarm/Steam/Exchange/Trading.cs b/ArchiSteamFarm/Steam/Exchange/Trading.cs index ec134f9d4..3157115e4 100644 --- a/ArchiSteamFarm/Steam/Exchange/Trading.cs +++ b/ArchiSteamFarm/Steam/Exchange/Trading.cs @@ -178,7 +178,9 @@ public sealed class Trading : IDisposable { } // Otherwise, fill the missing holes in our data if needed, since we actually had zeros there - for (byte i = 0; i < afterAmounts.Count - beforeAmounts.Count; i++) { + byte missingAmounts = (byte) (afterAmounts.Count - beforeAmounts.Count); + + for (byte i = 0; i < missingAmounts; i++) { beforeAmounts.Insert(0, 0); }