Implementing test of the CreateHtlcOperation class byte serialization

develop
Nelson R. Perez 2019-07-11 16:42:37 -05:00
parent bf346f25bf
commit bb4fd5ce5d
1 changed files with 4 additions and 2 deletions

View File

@ -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);
}
}