Example #1
0
        private static Wallet.AccountState DecodeAccountStateBlob(AccountStateBlob blob)
        {
            var cursor  = new CursorBuffer(blob.Blob.ToByteArray());
            var blobLen = cursor.Read32();

            var state = new Dictionary <string, byte[]>();

            for (int i = 0; i < blobLen; i++)
            {
                var keyLen    = cursor.Read32();
                var keyBuffer = new byte[keyLen];
                for (int j = 0; j < keyLen; j++)
                {
                    keyBuffer[j] = cursor.Read8();
                }

                var valueLen    = cursor.Read32();
                var valueBuffer = new byte[valueLen];
                for (int k = 0; k < valueLen; k++)
                {
                    valueBuffer[k] = cursor.Read8();
                }

                state[keyBuffer.ToHexString()] = valueBuffer;
            }

            return(Wallet.AccountState.FromBytes(state[Constant.PathValues.AccountStatePath]));
        }
Example #2
0
        public void Read8()
        {
            var bytes  = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
            var cursor = new CursorBuffer(bytes);
            var actual = cursor.Read8();

            actual = cursor.Read8();
            actual = cursor.Read8();
            var expected = 3;

            Assert.Equal(actual, expected);
        }