@Test public void testWalletAndConfig() throws IOException, InvalidCipherTextException { DefaultConfig config = new DefaultConfig(); Wallet wallet = new Wallet(config); Path path = Paths.get(config.getKeyPath()); String keyPath = path.getParent().toString(); String keyName = path.getFileName().toString(); log.debug("walletKeyPath: " + wallet.getKeyPath()); log.debug("walletKeyName: " + wallet.getKeyName()); log.debug("configKeyPath: " + keyPath); log.debug("configKeyName: " + keyName); assertEquals(wallet.getKeyPath(), keyPath); assertEquals(wallet.getKeyName(), keyName); } }
@Test public void testKeySave() throws IOException, InvalidCipherTextException { // generate key & save a file Wallet wt = new Wallet(null, "/tmp/", "nodePri.key", "Password1234!"); byte[] encData = FileUtil.readFile(wt.getKeyPath(), wt.getKeyName()); log.debug("path:" + wt.getKeyPath() + wt.getKeyName()); log.debug("encData:" + Hex.toHexString(encData)); log.debug("pubKey:" + Hex.toHexString(wt.getPubicKey())); // load key Wallet wt2 = new Wallet("/tmp/", wt.getKeyName(), "Password1234!"); log.debug("pubKey2:" + Hex.toHexString(wt2.getPubicKey())); assertArrayEquals(wt.getPubicKey(), wt2.getPubicKey()); }