From bb4fd5ce5da9b938e8bd4119b9422000310406f7 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Thu, 11 Jul 2019 16:42:37 -0500 Subject: [PATCH] Implementing test of the CreateHtlcOperation class byte serialization --- .../graphenej/operations/CreateHtlcOperationTest.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/graphenej/src/test/java/cy/agorise/graphenej/operations/CreateHtlcOperationTest.java b/graphenej/src/test/java/cy/agorise/graphenej/operations/CreateHtlcOperationTest.java index 888a498..f33bc7b 100644 --- a/graphenej/src/test/java/cy/agorise/graphenej/operations/CreateHtlcOperationTest.java +++ b/graphenej/src/test/java/cy/agorise/graphenej/operations/CreateHtlcOperationTest.java @@ -15,7 +15,7 @@ import cy.agorise.graphenej.UserAccount; import cy.agorise.graphenej.Util; public class CreateHtlcOperationTest { - private final String SERIALIZED_OP = "f68585abf4dce7c8045701310000000000000000007b7c80241100000000000000a06e327ea7388c18e4740e350ed4e60f2e04fc41c80078000000000001"; + private final String SERIALIZED_OP = "0000000000000000007b7c80241100000000000000a06e327ea7388c18e4740e350ed4e60f2e04fc41c8007800000000"; private final String PREIMAGE_HEX = "666f6f626172"; private final String HASH_RIPEMD160 = "a06e327ea7388c18e4740e350ed4e60f2e04fc41"; private final String HASH_SHA1 = "8843d7f92416211de9ebb963ff4ce28125932878"; @@ -56,7 +56,7 @@ public class CreateHtlcOperationTest { } } - //TODO: Implement operation test + @Test public void testOperationSerialization() throws NoSuchAlgorithmException { UserAccount from = new UserAccount("1.2.123"); UserAccount to = new UserAccount("1.2.124"); @@ -65,5 +65,7 @@ public class CreateHtlcOperationTest { byte[] hashBytes = Util.htlcHash("foobar".getBytes(), HtlcHashType.RIPEMD160); HtlcHash preimageHash = new HtlcHash(HtlcHashType.RIPEMD160, hashBytes); CreateHtlcOperation operation = new CreateHtlcOperation(fee, from, to, amount, preimageHash, (short) 200, 120); + byte[] opBytes = operation.toBytes(); + Assert.assertArrayEquals(Util.hexToBytes(SERIALIZED_OP), opBytes); } }