ImportKeystorePresenter extends BasePresenter<ImportKeystoreContract.View> implements ImportKeystoreContract.Presenter { @Override public void importKeystore(String keystore, String name, String password) { if (isExists(name)) { return; } showLoadingDialog(); new Thread() { @Override public void run() { int code = WalletManager.getInstance().importKeystore(keystore, name, password); switch (code) { case WalletManager.CODE_OK: mHandler.sendEmptyMessage(MSG_OK); break; case WalletManager.CODE_ERROR_KEYSTORE: mHandler.sendEmptyMessage(MSG_KEYSTORE_ERROR); break; case WalletManager.CODE_ERROR_NAME: break; case WalletManager.CODE_ERROR_PASSWORD: mHandler.sendEmptyMessage(MSG_PASSWORD_FAILED); break; case WalletManager.CODE_ERROR_WALLET_EXISTS: mHandler.sendEmptyMessage(MSG_WALLET_EXISTS); break; case WalletManager.CODE_ERROR_UNKNOW: mHandler.sendEmptyMessage(MSG_PASSWORD_FAILED); break; default: break; } } }.start(); }  @Override void init(); @Override void checkPaste(); @Override void parseQRCode(String QRCode); @Override void importKeystore(String keystore, String name, String password); @Override boolean isExists(String walletName); @Override void loadDBWalletNumber();  }
@Test public void importKeystore(){ String keystore = "{\"address\":{\"mainnet\":\"lat1x8z5nfgjnaryutayxxkzzkrfzenpwl7k6r2a8z\",\"testnet\":\"lax1x8z5nfgjnaryutayxxkzzkrfzenpwl7k4xcjfd\"},\"id\":\"054f3f85-c00f-4f76-b707-05d8d5c81ce6\",\"version\":3,\"crypto\":{\"cipher\":\"aes-128-ctr\",\"cipherparams\":{\"iv\":\"44c541ccc02edfb61f51eeddc1c010f8\"},\"ciphertext\":\"eb5b975d540f19469b191b44405a1bddc58355562a529264140a467fedff77ca\",\"kdf\":\"scrypt\",\"kdfparams\":{\"dklen\":32,\"n\":16384,\"p\":1,\"r\":8,\"salt\":\"c2b94a06c2ededad04cb4ba68c57eb86eba6b7f52ba14849b1538a84fe8bf9f1\"},\"mac\":\"9c81f37af1921a90f98a41655866e6d7b8139fa6c844b2724c260fbf45cc8f28\"}}\n"; String name = "Ella"; String password = "qq123456"; presenter.importKeystore(keystore,name,password); }