예제 #1
0
        public void HelloMustConsumeAll()
        {
            const string devuniq = "mdz-hwswmc-udp-bare-zynq"; // mdz hybrid hardware-software-mining-contraption
            var          binuniq = AsciiBlob(devuniq);
            var          devspec = new byte[] {                // this is basically arbitrary, the parsing is defined by devuniq (mostly), but can further refine
                0xFA,                                          // device-specific-format: next parse is versions
                0, 1, 2, 3,                                    // hardware revision
                4, 5, 6, 7                                     // firmware/software revision version
            };
            var hdr = new byte[] {
                (byte)binuniq.Length,
                (byte)devspec.Length
            };
            var fake       = hdr.Concat(binuniq).Concat(devspec).Concat(new byte[] { 1 }).ToArray();
            var pretending = Dummy;

            Assert.Throws <System.ArgumentException>(() => EventInstantiator.Hello(pretending, fake));
        }
예제 #2
0
        public void HelloLoadsCorrectly()
        {
            const string devuniq = "mdz-hwswmc-udp-bare-zynq"; // mdz hybrid hardware-software-mining-contraption
            var          binuniq = AsciiBlob(devuniq);
            var          devspec = new byte[] {                // this is basically arbitrary, the parsing is defined by devuniq (mostly), but can further refine
                0xFA,                                          // device-specific-format: next parse is versions
                0, 1, 2, 3,                                    // hardware revision
                4, 5, 6, 7                                     // firmware/software revision version
            };
            var hdr = new byte[] {
                (byte)binuniq.Length,
                (byte)devspec.Length
            };
            var fake       = hdr.Concat(binuniq).Concat(devspec).ToArray();
            var pretending = Dummy;
            var magic      = EventInstantiator.Hello(pretending, fake);

            Assert.Same(pretending, magic.originator);
            Assert.Equal(binuniq, magic.identificator);
            Assert.Equal(devspec, magic.deviceSpecific);
        }