Adding a simple key to address derivation test

develop
Nelson R. Perez 2017-11-02 11:38:39 -05:00
parent 3e96bbc9b3
commit e34596d0b4
1 changed files with 25 additions and 0 deletions

View File

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