@Test
  public void getCannotReturnClosedWallet() {
    // Arrange:
    final TestContext context = new TestContext();

    // Act:
    context.walletServices.open(context.pair);
    context.walletServices.close(context.pair.getName());

    // Act:
    ExceptionAssert.assertThrowsNccException(
        v -> context.walletServices.get(context.pair.getName()),
        NccException.Code.WALLET_IS_NOT_OPEN);
  }
  @Test
  public void openFailsIfCachedWalletPasswordIsIncorrect() {
    // Arrange:
    final TestContext context = new TestContext();
    context.walletServices.open(context.pair); // cache the wallet
    Mockito.when(context.repository.load(context.descriptor))
        .thenThrow(
            new WalletStorageException(WalletStorageException.Code.WALLET_PASSWORD_INCORRECT));

    // Act:
    ExceptionAssert.assertThrowsWalletStorageException(
        v -> context.walletServices.open(context.pair),
        WalletStorageException.Code.WALLET_PASSWORD_INCORRECT);
  }
  @Test
  public void renamedWalletIsNotAccessibleByOldName() {
    // Arrange:
    final WalletNamePasswordPair pair2 = createPair("n2", "p");
    final WalletDescriptor descriptor2 = createDescriptor("n2");
    final TestContext context = new TestContext();
    Mockito.when(context.descriptorFactory.createNew(pair2, FILE_EXTENSION))
        .thenReturn(descriptor2);

    // Act:
    context.walletServices.open(context.pair);
    context.walletServices.move(context.pair, pair2);

    // Assert:
    Assert.assertThat(context.walletServices.get(new WalletName("n2")), IsNull.notNullValue());
    ExceptionAssert.assertThrowsNccException(
        v -> context.walletServices.get(new WalletName("n")), NccException.Code.WALLET_IS_NOT_OPEN);
  }