@Test public void loadAccounts() throws Exception { KeyStoreImpl keyStore = new KeyStoreImpl(new FakeStore(), new FakeBackupRestore()); KeyPair account1 = keyStore.newAccount(); KeyPair account2 = keyStore.newAccount(); List<KeyPair> accounts = keyStore.loadAccounts(); KeyPair actualAccount1 = accounts.get(0); KeyPair actualAccount2 = accounts.get(1); assertEquals(String.valueOf(account1.getSecretSeed()), String.valueOf(actualAccount1.getSecretSeed())); assertEquals(String.valueOf(account2.getSecretSeed()), String.valueOf(actualAccount2.getSecretSeed())); }
@NonNull @Override public List<KeyPair> loadAccounts() throws LoadAccountException { ArrayList<KeyPair> accounts = new ArrayList<>(); try { JSONArray jsonArray = loadJsonArray(); if (jsonArray != null) { for (int i = 0; i < jsonArray.length(); i++) { JSONObject accountJson = jsonArray.getJSONObject(i); String seed = accountJson.getString(JSON_KEY_ENCRYPTED_SEED); accounts.add(KeyPair.fromSecretSeed(seed)); } } } catch (JSONException e) { throw new LoadAccountException(e.getMessage(), e); } return accounts; }
KeyStoreImpl implements KeyStore { @NonNull @Override public List<KeyPair> loadAccounts() throws LoadAccountException { ArrayList<KeyPair> accounts = new ArrayList<>(); try { JSONArray jsonArray = loadJsonArray(); if (jsonArray != null) { for (int i = 0; i < jsonArray.length(); i++) { JSONObject accountJson = jsonArray.getJSONObject(i); String seed = accountJson.getString(JSON_KEY_ENCRYPTED_SEED); accounts.add(KeyPair.fromSecretSeed(seed)); } } } catch (JSONException e) { throw new LoadAccountException(e.getMessage(), e); } return accounts; } }
KeyStoreImpl implements KeyStore { @NonNull @Override public List<KeyPair> loadAccounts() throws LoadAccountException { ArrayList<KeyPair> accounts = new ArrayList<>(); try { JSONArray jsonArray = loadJsonArray(); if (jsonArray != null) { for (int i = 0; i < jsonArray.length(); i++) { JSONObject accountJson = jsonArray.getJSONObject(i); String seed = accountJson.getString(JSON_KEY_ENCRYPTED_SEED); accounts.add(KeyPair.fromSecretSeed(seed)); } } } catch (JSONException e) { throw new LoadAccountException(e.getMessage(), e); } return accounts; } KeyStoreImpl(@NonNull Store store, @NonNull BackupRestore backupRestore); }
KeyStoreImpl implements KeyStore { @NonNull @Override public List<KeyPair> loadAccounts() throws LoadAccountException { ArrayList<KeyPair> accounts = new ArrayList<>(); try { JSONArray jsonArray = loadJsonArray(); if (jsonArray != null) { for (int i = 0; i < jsonArray.length(); i++) { JSONObject accountJson = jsonArray.getJSONObject(i); String seed = accountJson.getString(JSON_KEY_ENCRYPTED_SEED); accounts.add(KeyPair.fromSecretSeed(seed)); } } } catch (JSONException e) { throw new LoadAccountException(e.getMessage(), e); } return accounts; } KeyStoreImpl(@NonNull Store store, @NonNull BackupRestore backupRestore); @NonNull @Override List<KeyPair> loadAccounts(); @Override void deleteAccount(String publicAddress); @Override KeyPair newAccount(); @Override KeyPair importAccount(@NonNull String json, @NonNull String passphrase); @Override void clearAllAccounts(); }
KeyStoreImpl implements KeyStore { @NonNull @Override public List<KeyPair> loadAccounts() throws LoadAccountException { ArrayList<KeyPair> accounts = new ArrayList<>(); try { JSONArray jsonArray = loadJsonArray(); if (jsonArray != null) { for (int i = 0; i < jsonArray.length(); i++) { JSONObject accountJson = jsonArray.getJSONObject(i); String seed = accountJson.getString(JSON_KEY_ENCRYPTED_SEED); accounts.add(KeyPair.fromSecretSeed(seed)); } } } catch (JSONException e) { throw new LoadAccountException(e.getMessage(), e); } return accounts; } KeyStoreImpl(@NonNull Store store, @NonNull BackupRestore backupRestore); @NonNull @Override List<KeyPair> loadAccounts(); @Override void deleteAccount(String publicAddress); @Override KeyPair newAccount(); @Override KeyPair importAccount(@NonNull String json, @NonNull String passphrase); @Override void clearAllAccounts();  }