Exemple #1
0
 private bool TestFilter(BloomFilter filter, Transaction tx)
 {
     if (filter.Check(tx.Hash.ToArray()))
     {
         return(true);
     }
     if (tx.Outputs.Any(p => filter.Check(p.ScriptHash.ToArray())))
     {
         return(true);
     }
     if (tx.Inputs.Any(p => filter.Check(p.ToArray())))
     {
         return(true);
     }
     if (tx.Scripts.Any(p => filter.Check(p.RedeemScript.ToScriptHash().ToArray())))
     {
         return(true);
     }
     if (tx.Type == TransactionType.RegisterTransaction)
     {
         RegisterTransaction asset = (RegisterTransaction)tx;
         if (filter.Check(asset.Admin.ToArray()))
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #2
0
        private bool TestFilter(BloomFilter filter, Transaction tx)
        {
            if (filter.Check(tx.Hash.ToArray()))
            {
                return(true);
            }
            if (tx.Outputs.Any(p => filter.Check(p.ScriptHash.ToArray())))
            {
                return(true);
            }
            if (tx.Inputs.Any(p => filter.Check(p.ToArray())))
            {
                return(true);
            }
            if (tx.Scripts.Any(p => filter.Check(p.VerificationScript.ToScriptHash().ToArray())))
            {
                return(true);
            }
            if (tx.Type == TransactionType.RegisterTransaction)
            {
#pragma warning disable CS0612
                RegisterTransaction asset = (RegisterTransaction)tx;
                if (filter.Check(asset.Admin.ToArray()))
                {
                    return(true);
                }
#pragma warning restore CS0612
            }
            return(false);
        }
 internal static bool Test(this BloomFilter filter, Transaction tx)
 {
     if (filter.Check(tx.Hash.ToArray()))
     {
         return(true);
     }
     if (tx.Outputs.Any(p => filter.Check(p.ScriptHash.ToArray())))
     {
         return(true);
     }
     if (tx.Inputs.Any(p => filter.Check(p.ToArray())))
     {
         return(true);
     }
     if (tx.Witnesses.Any(p => filter.Check(p.ScriptHash.ToArray())))
     {
         return(true);
     }
     if (tx is RegisterTransaction asset)
     {
         if (filter.Check(asset.Admin.ToArray()))
         {
             return(true);
         }
     }
     return(false);
 }
        public void TestAddCheck()
        {
            int  m = 7, n = 10;
            uint nTweak = 123456;

            byte[]      elements = { 0, 1, 2, 3, 4 };
            BloomFilter filter   = new BloomFilter(m, n, nTweak);

            filter.Add(elements);
            filter.Check(elements).Should().BeTrue();
            byte[] anotherElements = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 };
            filter.Check(anotherElements).Should().BeFalse();
        }
Exemple #5
0
        public void TestCheckFunction()
        {
            //Arrange
            BloomFilter MockFilter = new BloomFilter(32);

            //Act
            MockFilter.Add("Test");
            bool contains = MockFilter.Check("Test");

            //Assert
            Assert.IsTrue(contains);
        }
Exemple #6
0
        public void Check()
        {
            // Arrange
            var bloomfilter = new BloomFilter(256, 2, 1);

            byte[] element1 = { 0x01, 0x02, 0x03, 0x04 };
            byte[] element2 = { 0xDE, 0xAD, 0xBE, 0xEF };

            // Act
            bloomfilter.Add(element1);
            var result = bloomfilter.Check(element2);

            // Assert
            Assert.IsFalse(result);
        }
Exemple #7
0
 public void ItStoresTheString()
 {
     Assert.True(Subject.Check("foo"));
 }
Exemple #8
0
 public void ItHasNoStrings(string s)
 {
     Assert.False(Subject.Check(s));
 }
Exemple #9
0
 public void ItStoresTheStrings(string s)
 {
     Assert.True(Subject.Check(s));
 }