public static AccountState FromBytes(byte[] bytes) { var cursor = new CursorBuffer(bytes); var authenticationKeyLen = cursor.Read32(); var authenticationKey = cursor.ReadXBytes((int)authenticationKeyLen); var balance = cursor.Read64(); var delegatedKeyRotationCapability = cursor.ReadBool(); var delegatedWithdrawalCapability = cursor.ReadBool(); var receivedEventsCount = cursor.Read32(); cursor.Read32(); // skip struct attribute sequence number var receivedEventsKeyLen = cursor.Read32(); var receivedEventsKey = cursor.ReadXBytes((int)receivedEventsKeyLen); var sentEventsCount = cursor.Read32(); cursor.Read32(); // skip struct attribute sequence number var sentEventsKeyLen = cursor.Read32(); var sentEventsKey = cursor.ReadXBytes((int)sentEventsKeyLen); var sequenceNumber = cursor.Read64(); var receivedEvents = new EventHandle(receivedEventsKey, receivedEventsCount); var sentEvents = new EventHandle(sentEventsKey, sentEventsCount); return(new AccountState(authenticationKey, balance, receivedEvents, sentEvents, sequenceNumber, delegatedWithdrawalCapability, delegatedKeyRotationCapability)); }
public void Read64_LittleEndian() { 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, true); var actual = cursor.Read64(); actual = cursor.Read64(); var expected = 1157159078456920585UL; Assert.Equal(actual, expected); }
public void Read64() { 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, false); var actual = cursor.Read64(); actual = cursor.Read64(); var expected = 651345242494996240UL; Assert.Equal(actual, expected); }
public static AccountState FromBytes(byte[] bytes) { var cursor = new CursorBuffer(bytes); var authenticationKeyLen = cursor.Read32(); var authenticationKey = cursor.ReadXBytes((int)authenticationKeyLen); var balance = cursor.Read64(); var delegatedWithdrawalCapability = cursor.ReadBool(); var receivedEventsCount = cursor.Read64(); var sentEventsCount = cursor.Read64(); var sequenceNumber = cursor.Read64(); return(new AccountState(authenticationKey, balance, receivedEventsCount, sentEventsCount, sequenceNumber, delegatedWithdrawalCapability)); }