diff --git a/neo.UnitTests/UT_FifoSet.cs b/neo.UnitTests/UT_FifoSet.cs new file mode 100644 index 0000000000..218aeefde2 --- /dev/null +++ b/neo.UnitTests/UT_FifoSet.cs @@ -0,0 +1,32 @@ +using Microsoft.VisualStudio.TestTools.UnitTesting; +using Neo.IO.Caching; +using System.Linq; + +namespace Neo.UnitTests +{ + [TestClass] + public class UT_FifoSet + { + [TestMethod] + public void FifoSetTest() + { + var a = UInt256.Zero; + var b = new UInt256(); + var c = new UInt256(new byte[32] { + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, + 0x01, 0x01 + }); + + var set = new FIFOSet(3); + + Assert.IsTrue(set.Add(a)); + Assert.IsFalse(set.Add(a)); + Assert.IsFalse(set.Add(b)); + Assert.IsTrue(set.Add(c)); + + CollectionAssert.AreEqual(set.ToArray(), new UInt256[] { a, c }); + } + } +} diff --git a/neo/IO/Caching/FIFOSet.cs b/neo/IO/Caching/FIFOSet.cs index 6dd52dbccf..7769cb5ad5 100644 --- a/neo/IO/Caching/FIFOSet.cs +++ b/neo/IO/Caching/FIFOSet.cs @@ -51,7 +51,7 @@ public void ExceptWith(IEnumerable hashes) public IEnumerator GetEnumerator() { - var entries = dictionary.Values.Cast().ToArray(); + var entries = dictionary.Keys.Cast().ToArray(); foreach (var entry in entries) yield return entry; }