public void TestBuilderTimeBounds() { // GBPMKIRA2OQW2XZZQUCQILI5TMVZ6JNRKM423BSAISDM7ZFWQ6KWEBC4 var source = KeyPair.FromSecretSeed("SCH27VUZZ6UAKB67BDNF6FA42YMBMQCBKXWGMFD5TZ6S5ZZCZFLRXKHS"); var destination = KeyPair.FromAccountId("GDW6AUTBXTOC7FIKUO5BOO3OGLK4SF7ZPOBLMQHMZDI45J2Z6VXRB5NR"); var account = new Account(source.AccountId, 2908908335136768L); var transaction = new TransactionBuilder(account) .AddOperation(new CreateAccountOperation.Builder(destination, "2000").Build()) .AddTimeBounds(new TimeBounds(42, 1337)) .AddMemo(Memo.Hash("abcdef")) .Build(); transaction.Sign(source); // Convert transaction to binary XDR and back again to make sure timebounds are correctly de/serialized. var decodedTransaction = transaction.ToEnvelopeXdr().V1.Tx; Assert.AreEqual(decodedTransaction.TimeBounds.MinTime.InnerValue.InnerValue, 42U); Assert.AreEqual(decodedTransaction.TimeBounds.MaxTime.InnerValue.InnerValue, 1337U); var transaction2 = Transaction.FromEnvelopeXdr(transaction.ToEnvelopeXdr()); Assert.AreEqual(transaction.SourceAccount.AccountId, transaction2.SourceAccount.AccountId); Assert.AreEqual(transaction.SequenceNumber, transaction2.SequenceNumber); Assert.AreEqual(transaction.Memo, transaction2.Memo); Assert.AreEqual(transaction.TimeBounds, transaction2.TimeBounds); Assert.AreEqual(transaction.Fee, transaction2.Fee); Assert.AreEqual( ((CreateAccountOperation)transaction.Operations[0]).StartingBalance, ((CreateAccountOperation)transaction2.Operations[0]).StartingBalance ); }
public void TestMemoHashBytesSuccess() { var bytes = Enumerable.Repeat((byte)'A', 10).ToArray(); var memo = Memo.Hash(bytes); Assert.AreEqual(sdkxdr.MemoType.MemoTypeEnum.MEMO_HASH, memo.ToXdr().Discriminant.InnerValue); Assert.AreEqual("AAAAAAAAAA", Util.PaddedByteArrayToString(memo.MemoBytes)); Assert.AreEqual("4141414141414141414100000000000000000000000000000000000000000000", memo.GetHexValue()); Assert.AreEqual("41414141414141414141", memo.GetTrimmedHexValue()); }
public void TestMemoHashSuccess() { var memo = Memo.Hash("4142434445464748494a4b4c"); Assert.AreEqual(sdkxdr.MemoType.MemoTypeEnum.MEMO_HASH, memo.ToXdr().Discriminant.InnerValue); var test = "ABCDEFGHIJKL"; Assert.AreEqual(test, Util.PaddedByteArrayToString(memo.MemoBytes)); Assert.AreEqual("4142434445464748494a4b4c", memo.GetTrimmedHexValue()); }
public void TestMemoHashInvalidHex() { try { Memo.Hash("test"); Assert.Fail(); } catch (FormatException) { } }
public void TestMemoHashTooLong() { var longer = Enumerable.Repeat((byte)0, 33).ToArray(); try { Memo.Hash(longer); Assert.Fail(); } catch (MemoTooLongException exception) { Assert.IsTrue(exception.Message.Contains("MEMO_HASH can contain 32 bytes at max.")); } }