예제 #1
0
        public void FoundNonceMustConsumeAll()
        {
            var bin = new byte[] {
                0x01, 0x23, 0x45, 0x67,
                0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77,
                1, // one extra uint given
                0xA0, 0xB1, 0xC2, 0xD3,
                0x4E, 0x5F, 0x60, 0x71
            };

            Assert.Throws <System.ArgumentException>(() => EventInstantiator.FoundNonce(bin));
        }
예제 #2
0
        public void FoundNonceLoadsCorrectly()
        {
            var bin = new byte[] {
                0x01, 0x23, 0x45, 0x67,                         // original workid, big endian
                0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, // increment wrt original base-nonce
                2,                                              // this hash produces 2 uints (weird, but it's just a test) - max is 255 uints, unlikely but I guess 192 might be a thing.
                0xA0, 0xB1, 0xC2, 0xD3,
                0x4E, 0x5F, 0x60, 0x71                          // the format of the hash is a function of the algorithm header format
            };
            var magic = EventInstantiator.FoundNonce(bin);

            Assert.Equal(0x67452301u, magic.workid);
            Assert.Equal(0x7766554433221100ul, magic.increment);
        }