From e34596d0b4854afd2b264918135e06ea3c2c36b0 Mon Sep 17 00:00:00 2001 From: "Nelson R. Perez" Date: Thu, 2 Nov 2017 11:38:39 -0500 Subject: [PATCH] Adding a simple key to address derivation test --- .../java/cy/agorise/graphenej/KeyTest.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 graphenej/src/test/java/cy/agorise/graphenej/KeyTest.java diff --git a/graphenej/src/test/java/cy/agorise/graphenej/KeyTest.java b/graphenej/src/test/java/cy/agorise/graphenej/KeyTest.java new file mode 100644 index 0000000..ba5836f --- /dev/null +++ b/graphenej/src/test/java/cy/agorise/graphenej/KeyTest.java @@ -0,0 +1,25 @@ +package cy.agorise.graphenej; + +import junit.framework.Assert; + +import org.bitcoinj.core.DumpedPrivateKey; +import org.bitcoinj.core.ECKey; +import org.junit.Test; + +/** + * Created by nelson on 11/2/17. + */ + +public class KeyTest { + + /** + * Testing key to address derivation + */ + @Test + public void testKeyToAddress(){ + String wif = "5J96pne45qWM1WpektoeazN6k9Mt93jQ7LyueRxFfEMTiy6yxjM"; + ECKey sourcePrivate = DumpedPrivateKey.fromBase58(null, wif).getKey(); + Address address = new Address(ECKey.fromPublicOnly(sourcePrivate.getPubKey())); + Assert.assertEquals("Generated address matches expected one", address.toString(), "BTS8RiFgs8HkcVPVobHLKEv6yL3iXcC9SWjbPVS15dDAXLG9GYhnY"); + } +}