diff --git a/apitest/src/test/java/bisq/apitest/method/CreatePaymentAccountTest.java b/apitest/src/test/java/bisq/apitest/method/CreatePaymentAccountTest.java
new file mode 100644
index 0000000000..661205c74d
--- /dev/null
+++ b/apitest/src/test/java/bisq/apitest/method/CreatePaymentAccountTest.java
@@ -0,0 +1,98 @@
+/*
+ * This file is part of Bisq.
+ *
+ * Bisq is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or (at
+ * your option) any later version.
+ *
+ * Bisq is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with Bisq. If not, see .
+ */
+
+package bisq.apitest.method;
+
+import bisq.proto.grpc.GetPaymentAccountsRequest;
+
+import protobuf.PaymentAccount;
+import protobuf.PerfectMoneyAccountPayload;
+
+import java.util.List;
+import java.util.stream.Collectors;
+
+import lombok.extern.slf4j.Slf4j;
+
+import org.junit.jupiter.api.AfterAll;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Order;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.TestMethodOrder;
+
+import static bisq.apitest.Scaffold.BitcoinCoreApp.bitcoind;
+import static bisq.apitest.config.BisqAppConfig.alicedaemon;
+import static java.util.Comparator.comparing;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.fail;
+import static org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
+
+
+@Slf4j
+@TestMethodOrder(OrderAnnotation.class)
+public class CreatePaymentAccountTest extends MethodTest {
+
+ static final String PERFECT_MONEY_ACCT_NAME = "Perfect Money USD";
+ static final String PERFECT_MONEY_ACCT_NUMBER = "0123456789";
+
+ @BeforeAll
+ public static void setUp() {
+ try {
+ setUpScaffold(bitcoind, alicedaemon);
+ } catch (Exception ex) {
+ fail(ex);
+ }
+ }
+
+ @Test
+ @Order(1)
+ public void testCreatePerfectMoneyUSDPaymentAccount() {
+ var perfectMoneyPaymentAccountRequest = createCreatePerfectMoneyPaymentAccountRequest(
+ PERFECT_MONEY_ACCT_NAME,
+ PERFECT_MONEY_ACCT_NUMBER,
+ "USD");
+ //noinspection ResultOfMethodCallIgnored
+ grpcStubs(alicedaemon).paymentAccountsService.createPaymentAccount(perfectMoneyPaymentAccountRequest);
+
+ var getPaymentAccountsRequest = GetPaymentAccountsRequest.newBuilder().build();
+ var reply = grpcStubs(alicedaemon).paymentAccountsService.getPaymentAccounts(getPaymentAccountsRequest);
+
+ // The daemon is running against the regtest/dao setup files, and was set up with
+ // two dummy accounts ("PerfectMoney dummy", "ETH dummy") before any tests ran.
+ // We just added 1 test account, making 3 total.
+ assertEquals(3, reply.getPaymentAccountsCount());
+
+ // Sort the returned list by creation date; the last item in the sorted
+ // list will be the payment acct we just created.
+ List paymentAccountList = reply.getPaymentAccountsList().stream()
+ .sorted(comparing(PaymentAccount::getCreationDate))
+ .collect(Collectors.toList());
+ PaymentAccount paymentAccount = paymentAccountList.get(2);
+ PerfectMoneyAccountPayload perfectMoneyAccount = paymentAccount
+ .getPaymentAccountPayload()
+ .getPerfectMoneyAccountPayload();
+
+ assertEquals(PERFECT_MONEY_ACCT_NAME, paymentAccount.getAccountName());
+ assertEquals("USD",
+ paymentAccount.getSelectedTradeCurrency().getFiatCurrency().getCurrency().getCurrencyCode());
+ assertEquals(PERFECT_MONEY_ACCT_NUMBER, perfectMoneyAccount.getAccountNr());
+ }
+
+ @AfterAll
+ public static void tearDown() {
+ tearDownScaffold();
+ }
+}
diff --git a/apitest/src/test/java/bisq/apitest/method/MethodTest.java b/apitest/src/test/java/bisq/apitest/method/MethodTest.java
index 6b85fb00a6..de713ae186 100644
--- a/apitest/src/test/java/bisq/apitest/method/MethodTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/MethodTest.java
@@ -17,6 +17,7 @@
package bisq.apitest.method;
+import bisq.proto.grpc.CreatePaymentAccountRequest;
import bisq.proto.grpc.GetBalanceRequest;
import bisq.proto.grpc.GetFundingAddressesRequest;
import bisq.proto.grpc.LockWalletRequest;
@@ -26,6 +27,7 @@ import bisq.proto.grpc.SetWalletPasswordRequest;
import bisq.proto.grpc.UnlockWalletRequest;
import static bisq.common.app.DevEnv.DEV_PRIVILEGE_PRIV_KEY;
+import static bisq.core.payment.payload.PaymentMethod.PERFECT_MONEY;
import static bisq.core.support.dispute.agent.DisputeAgent.DisputeAgentType.MEDIATOR;
import static bisq.core.support.dispute.agent.DisputeAgent.DisputeAgentType.REFUNDAGENT;
@@ -66,12 +68,6 @@ public class MethodTest extends ApiTestCase {
return GetFundingAddressesRequest.newBuilder().build();
}
- protected final RegisterDisputeAgentRequest createRegisterDisputeAgentRequest(String disputeAgentType) {
- return RegisterDisputeAgentRequest.newBuilder()
- .setDisputeAgentType(disputeAgentType.toLowerCase())
- .setRegistrationKey(DEV_PRIVILEGE_PRIV_KEY).build();
- }
-
// Convenience methods for calling frequently used & thoroughly tested gRPC services.
protected final long getBalance(BisqAppConfig bisqAppConfig) {
@@ -99,10 +95,30 @@ public class MethodTest extends ApiTestCase {
.getAddress();
}
+ // Static conveniences for test methods and test case fixture setups.
+
+ protected static final RegisterDisputeAgentRequest createRegisterDisputeAgentRequest(String disputeAgentType) {
+ return RegisterDisputeAgentRequest.newBuilder()
+ .setDisputeAgentType(disputeAgentType.toLowerCase())
+ .setRegistrationKey(DEV_PRIVILEGE_PRIV_KEY).build();
+ }
+
@SuppressWarnings("ResultOfMethodCallIgnored")
- protected final void registerDisputeAgents(BisqAppConfig bisqAppConfig) {
+ protected static final void registerDisputeAgents(BisqAppConfig bisqAppConfig) {
var disputeAgentsService = grpcStubs(bisqAppConfig).disputeAgentsService;
disputeAgentsService.registerDisputeAgent(createRegisterDisputeAgentRequest(MEDIATOR.name()));
disputeAgentsService.registerDisputeAgent(createRegisterDisputeAgentRequest(REFUNDAGENT.name()));
}
+
+ protected static final CreatePaymentAccountRequest createCreatePerfectMoneyPaymentAccountRequest(
+ String accountName,
+ String accountNumber,
+ String currencyCode) {
+ return CreatePaymentAccountRequest.newBuilder()
+ .setPaymentMethodId(PERFECT_MONEY.getId())
+ .setAccountName(accountName)
+ .setAccountNumber(accountNumber)
+ .setCurrencyCode(currencyCode)
+ .build();
+ }
}