Small changes in tests

master
Nelson R. Perez 2016-12-05 20:29:46 -05:00
parent 16f2a26479
commit 67eb4953d0
2 changed files with 21 additions and 19 deletions

View File

@ -7,20 +7,20 @@ import java.io.IOException;
public class Main {
// Brain key from Nelson's app referencing the bilthon-83 account
public static final String BRAIN_KEY = "PUMPER ISOTOME SERE STAINER CLINGER MOONLIT CHAETA UPBRIM AEDILIC BERTHER NIT SHAP SAID SHADING JUNCOUS CHOUGH";
public static final String BILTHON_83_BRAIN_KEY = "PUMPER ISOTOME SERE STAINER CLINGER MOONLIT CHAETA UPBRIM AEDILIC BERTHER NIT SHAP SAID SHADING JUNCOUS CHOUGH";
public static final String BILTHON_5_BRAIN_KEY = "UNMATE AURIGAL NAVET WAVICLE REWOVE ABBOTCY COWHERB OUTKICK STOPPER JUSSORY BEAMLET WIRY";
public static final String BILTHON_7_BRAIN_KEY = "VENIN QUOTHA OBESELY TORIC OSMATIC SPOKEN DIACOPE CUBICA TABULA REDDING APONIA TARTAR";
//public static final String BRAIN_KEY = "TWIXT SERMO TRILLI AUDIO PARDED PLUMET BIWA REHUNG MAUDLE VALVULA OUTBURN FEWNESS ALIENER UNTRACE PRICH TROKER";
//public static final String BRAIN_KEY = "SIVER TIKKER FOGO HOMINAL PRAYER LUTEIN SMALLY ACARID MEROPIA TRANCE BOGONG IDDAT HICKORY SOUTANE MOOD DOWSER";
//public static final String BILTHON_83_BRAIN_KEY = "TWIXT SERMO TRILLI AUDIO PARDED PLUMET BIWA REHUNG MAUDLE VALVULA OUTBURN FEWNESS ALIENER UNTRACE PRICH TROKER";
//public static final String BILTHON_83_BRAIN_KEY = "SIVER TIKKER FOGO HOMINAL PRAYER LUTEIN SMALLY ACARID MEROPIA TRANCE BOGONG IDDAT HICKORY SOUTANE MOOD DOWSER";
public static final String BIP39_KEY = "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about";
// WIF from Nelson's app referencing the bilthon-83 account
// public static final String WIF = "5J96pne45qWM1WpektoeazN6k9Mt93jQ7LyueRxFfEMTiy6yxjM";
// Brain key from an empty account created by the cli_wallet
// public static final String BRAIN_KEY = "TWIXT SERMO TRILLI AUDIO PARDED PLUMET BIWA REHUNG MAUDLE VALVULA OUTBURN FEWNESS ALIENER UNTRACE PRICH TROKER";
// public static final String BILTHON_83_BRAIN_KEY = "TWIXT SERMO TRILLI AUDIO PARDED PLUMET BIWA REHUNG MAUDLE VALVULA OUTBURN FEWNESS ALIENER UNTRACE PRICH TROKER";
// WIF from an empty account created by the cli_wallet
public static final String WIF = "5KMzB2GqGhnh7ufhgddmz1eKPHS72uTLeL9hHjSvPb1UywWknF5";
@ -57,7 +57,7 @@ public class Main {
// test.testGetAccountByName();
// test.testGetRequiredFees();
// test.testRandomNumberGeneration();
// test.testBrainKeyOperations(true);
test.testBrainKeyOperations(false);
// test.testBip39Opertion();
// test.testAccountNamebyAddress();
// test.testAccountNameById();
@ -66,7 +66,7 @@ public class Main {
// test.testCompression();
// test.testAccountUpdateSerialization();
// test.testAccountUpdateOperationBroadcast();
test.testCreateBinFile();
test.testImportBinFile();
// test.testCreateBinFile();
// test.testImportBinFile();
}
}

View File

@ -17,7 +17,6 @@ import org.spongycastle.crypto.digests.RIPEMD160Digest;
import javax.net.ssl.SSLContext;
import java.io.*;
import java.lang.reflect.Type;
import java.math.BigInteger;
import java.security.NoSuchAlgorithmException;
import java.util.*;
import java.util.logging.Level;
@ -181,7 +180,7 @@ public class Test {
AssetAmount amount = new AssetAmount(UnsignedLong.valueOf(100), new Asset("1.3.120"));
AssetAmount fee = new AssetAmount(UnsignedLong.valueOf(264174), new Asset("1.3.0"));
operations.add(new TransferOperation(from, to, amount, fee));
BrainKey brainKey = new BrainKey(Main.BRAIN_KEY, 0);
BrainKey brainKey = new BrainKey(Main.BILTHON_83_BRAIN_KEY, 0);
this.transaction = new Transaction(brainKey.getWalletImportFormat(), blockData, operations);
byte[] serializedTransaction = this.transaction.toBytes();
System.out.println("Serialized transaction");
@ -334,7 +333,7 @@ public class Test {
}
public void testPrivateKeyManipulations() {
String brainKeyWords = "UNMATE AURIGAL NAVET WAVICLE REWOVE ABBOTCY COWHERB OUTKICK STOPPER JUSSORY BEAMLET WIRY";
String brainKeyWords = "PUMPER ISOTOME SERE STAINER CLINGER MOONLIT CHAETA UPBRIM AEDILIC BERTHER NIT SHAP SAID SHADING JUNCOUS CHOUGH";
BrainKey brainKey = new BrainKey(brainKeyWords, 0);
ECKey privateKey = DumpedPrivateKey.fromBase58(null, brainKey.getWalletImportFormat()).getKey();
@ -400,7 +399,7 @@ public class Test {
/**
* The final purpose of this test is to convert the plain brainkey at
* Main.BRAIN_KEY into the WIF at Main.WIF
* Main.BILTHON_83_BRAIN_KEY into the WIF at Main.WIF
*/
public void testBrainKeyOperations(boolean random) {
try {
@ -415,7 +414,9 @@ public class Test {
String suggestion = BrainKey.suggest(words);
brainKey = new BrainKey(suggestion, 0);
} else {
brainKey = new BrainKey(Main.BILTHON_5_BRAIN_KEY, 0);
System.out.println("Using brain key: "+Main.BILTHON_5_BRAIN_KEY);
// brainKey = new BrainKey(Main.BILTHON_83_BRAIN_KEY, 0);
brainKey = new BrainKey("CYNEBOT LUFBERY DAUNTER TOO SALOOP HOPOFF DIAULOS REV AES TORPOR RECTRIX DEVILRY", 0);
}
ECKey key = brainKey.getPrivateKey();
System.out.println("Private key..................: "+Util.bytesToHex(key.getSecretBytes()));
@ -423,15 +424,16 @@ public class Test {
System.out.println("Wif Compressed...............: " + wif);
String wif2 = key.decompress().getPrivateKeyAsWiF(NetworkParameters.fromID(NetworkParameters.ID_MAINNET));
System.out.println("Wif Decompressed.............: " + wif2);
System.out.println("Wif from BrainKey............: "+ brainKey.getWalletImportFormat());
byte[] pubKey1 = key.decompress().getPubKey();
byte[] pubKey2 = key.getPubKey();
byte[] uncompressedPubKey = key.decompress().getPubKey();
byte[] compressedPubKey = key.getPubKey();
System.out.println("Public Key Decompressed........: " + Util.bytesToHex(pubKey1));
System.out.println("Public Key Compressed..........: " + Util.bytesToHex(pubKey2));
System.out.println("Public Key Decompressed......: " + Util.bytesToHex(uncompressedPubKey));
System.out.println("Public Key Compressed........: " + Util.bytesToHex(compressedPubKey));
// Address generation test
Address address = new Address(key);
Address address = new Address(ECKey.fromPublicOnly(key.getPubKey()));
System.out.println("Block explorer's address.....: " + address);
} catch (FileNotFoundException e) {
System.out.println("FileNotFoundException. Msg: " + e.getMessage());
@ -467,7 +469,7 @@ public class Test {
}
};
BrainKey brainKey = new BrainKey(Main.BRAIN_KEY, 0);
BrainKey brainKey = new BrainKey(Main.BILTHON_83_BRAIN_KEY, 0);
Address address = new Address(brainKey.getPrivateKey());
try {
// Create a custom SSL context.
@ -555,7 +557,7 @@ public class Test {
}
public void testCreateBinFile() {
byte[] fileOutput = FileBin.getBytesFromBrainKey(Main.BRAIN_KEY, "123456", "bithon-83");
byte[] fileOutput = FileBin.getBytesFromBrainKey(Main.BILTHON_83_BRAIN_KEY, "123456", "bithon-83");
///String stringFile = "02f9f3eb0f61a0a96134975d86048bf92e114d6a1ce286140cad3a96c33e697282bc0a8a24d1ad0c7bc084a79816ce38e36bd2d624aa8bf686f53fb4c7e25e3974da9b40e0b17e9d0b5b82793a04b19646169c49c58cd67f4950aee7d275141dd24f52baaaee772995a9bd6a6562a7a38aae08951236d3f612aecef7aedd720a91eacbab3a792ca3ebe0105838fe11f6e9d0e83e5d77eb82f17c7ba85c670e69294a8bcf8365cfeca487a60093498496bbec394c729e3fda9f32fdccdea56288b36fb14a26aa309b548a6dd9c1d616d22167348f8d580f9dc7361b4457d2dc6d75ec985d8e2d3dcdff89cd425d9f14037ac961eb10ac5f92bab356ccecd8cf018ec05ab40d915b628a75ae32cfa4005634f08b24c0dc8c5a7636ed70cbd86a7f0c4f6236d74310470fafe3af8b5346c8cb61957f7292b468d276498f9e806399588b0afd5777e6ee5fe7cd3a6691d9b5486cb5c7adbd5ad0b17588dd32d82b01d49ecf0f2bf24ee54a490ee620e8ab049047ffa416b5efa8f1f0155d8f1be866a10d0d62ae44a3a8ecc0121c08837c2ee1a25f8b6dd7266273c41f4b9a5e3d600e3fb4de870f99ab1a7196d93f222595f92e97a2480f58b61b62639154a374b987664fd317622aaad156f831b03f2d9606537b65b3b1fcfb1fb6be39560ad2c301dd1fc25cee755e61b49ebfe42ca7e64b4b0fc4aa347b48a85c0b585a3499fe278e25cb2141f8009b9afc875fa2a2c439bf6cdec4b5190a6deb7f9390f072beb24749a8a2114cc1870c07be079abb3ee0ebc827f9b53e158a529bc6552eba280f05edf5f7ae1911de7acb4888150a509d029ec7c9da6de8adabbca6773a0a293a0a42de8278c82e88b9390b42b56f58bd8633fb97130e799a47a744e2e8958fd5";
//fileOutput = new BigInteger(stringFile, 16).toByteArray();
System.out.println(FileBin.getBrainkeyFromByte(fileOutput, "123456"));