Пример #1
0
        public void testBinaryParsing()
        {
            /*
             * TransactionType
             * Sequence
             * Amount
             * Fee
             * SigningPubKey
             * Account
             * Destination
             * */
            string expectedSerialization = "120000240000000561D4C44364C5BB000000000000000000000000000055534"
                                           + "40000000000B5F762798A53D543A014CAF8B297CFF8F2F937E8684000000000"
                                           + "00000F73210330E7FC9D56BB25D6893BA3F317AE5BCF33B3291BD63DB32654A"
                                           + "313222F7FD0208114B5F762798A53D543A014CAF8B297CFF8F2F937E88314FD"
                                           + "94A75318DE40B1D513E6764ECBCB6F1E7056ED";

            BinaryParser binaryParser = new BinaryParser(expectedSerialization);
            Field        field;

            field = binaryParser.ReadField();
            Assert.AreEqual(Field.TransactionType, field);
            Assert.AreEqual(Field.TransactionType, UInt16.TransactionType.GetField());
            UInt16 uInt16 = UInt16.OutTranslate.FromParser(binaryParser);

            Assert.AreEqual(0, uInt16.IntValue());

            field = binaryParser.ReadField();
            Assert.AreEqual(Field.Sequence, field);
            UInt32 sequence = UInt32.OutTranslate.FromParser(binaryParser);

            Assert.AreEqual(5, sequence.IntValue());

            field = binaryParser.ReadField();
            Assert.AreEqual(Field.Amount, field);

            binaryParser = new BinaryParser(expectedSerialization);
            StObject so = StObject.OutTranslate.FromParser(binaryParser);

            Assert.AreEqual(expectedSerialization, so.ToHex());
        }