diff --git a/apitest/src/test/java/bisq/apitest/ApiTestCase.java b/apitest/src/test/java/bisq/apitest/ApiTestCase.java
index 6c7a9f82866..fea32d2e75d 100644
--- a/apitest/src/test/java/bisq/apitest/ApiTestCase.java
+++ b/apitest/src/test/java/bisq/apitest/ApiTestCase.java
@@ -17,26 +17,27 @@
package bisq.apitest;
-import java.net.InetAddress;
-
import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
import java.util.concurrent.ExecutionException;
import java.util.stream.Collectors;
+import javax.annotation.Nullable;
+
import org.junit.jupiter.api.TestInfo;
+import static bisq.apitest.config.BisqAppConfig.alicedaemon;
+import static bisq.apitest.config.BisqAppConfig.arbdaemon;
+import static bisq.apitest.config.BisqAppConfig.bobdaemon;
+import static java.net.InetAddress.getLoopbackAddress;
import static java.util.Arrays.stream;
import static java.util.concurrent.TimeUnit.MILLISECONDS;
import bisq.apitest.config.ApiTestConfig;
-import bisq.apitest.config.BisqAppConfig;
import bisq.apitest.method.BitcoinCliHelper;
-import bisq.cli.GrpcStubs;
+import bisq.cli.GrpcClient;
/**
* Base class for all test types: 'method', 'scenario' and 'e2e'.
@@ -50,8 +51,8 @@
*
* Those documents contain information about the configurations used by this test harness:
* bitcoin-core's bitcoin.conf and blocknotify values, bisq instance options, the DAO genesis
- * transaction id, initial BSQ and BTC balances for Bob & Alice accounts, and default
- * PerfectMoney dummy payment accounts (USD) for Bob and Alice.
+ * transaction id, initial BSQ and BTC balances for Bob & Alice accounts, and Bob and
+ * Alice's default payment accounts.
*
* During a build, the
* dao-setup.zip
@@ -69,8 +70,12 @@ public class ApiTestCase {
protected static ApiTestConfig config;
protected static BitcoinCliHelper bitcoinCli;
- // gRPC service stubs are used by method & scenario tests, but not e2e tests.
- private static final Map grpcStubsCache = new HashMap<>();
+ @Nullable
+ protected static GrpcClient arbClient;
+ @Nullable
+ protected static GrpcClient aliceClient;
+ @Nullable
+ protected static GrpcClient bobClient;
public static void setUpScaffold(Enum>... supportingApps)
throws InterruptedException, ExecutionException, IOException {
@@ -79,6 +84,7 @@ public static void setUpScaffold(Enum>... supportingApps)
.setUp();
config = scaffold.config;
bitcoinCli = new BitcoinCliHelper((config));
+ createGrpcClients();
}
public static void setUpScaffold(String[] params)
@@ -90,24 +96,28 @@ public static void setUpScaffold(String[] params)
scaffold = new Scaffold(params).setUp();
config = scaffold.config;
bitcoinCli = new BitcoinCliHelper((config));
+ createGrpcClients();
}
public static void tearDownScaffold() {
scaffold.tearDown();
}
- protected static String getEnumArrayAsString(Enum>[] supportingApps) {
- return stream(supportingApps).map(Enum::name).collect(Collectors.joining(","));
- }
-
- protected static GrpcStubs grpcStubs(BisqAppConfig bisqAppConfig) {
- if (grpcStubsCache.containsKey(bisqAppConfig)) {
- return grpcStubsCache.get(bisqAppConfig);
- } else {
- GrpcStubs stubs = new GrpcStubs(InetAddress.getLoopbackAddress().getHostAddress(),
- bisqAppConfig.apiPort, config.apiPassword);
- grpcStubsCache.put(bisqAppConfig, stubs);
- return stubs;
+ protected static void createGrpcClients() {
+ if (config.supportingApps.contains(alicedaemon.name())) {
+ aliceClient = new GrpcClient(getLoopbackAddress().getHostAddress(),
+ alicedaemon.apiPort,
+ config.apiPassword);
+ }
+ if (config.supportingApps.contains(bobdaemon.name())) {
+ bobClient = new GrpcClient(getLoopbackAddress().getHostAddress(),
+ bobdaemon.apiPort,
+ config.apiPassword);
+ }
+ if (config.supportingApps.contains(arbdaemon.name())) {
+ arbClient = new GrpcClient(getLoopbackAddress().getHostAddress(),
+ arbdaemon.apiPort,
+ config.apiPassword);
}
}
diff --git a/apitest/src/test/java/bisq/apitest/method/GetMethodHelpTest.java b/apitest/src/test/java/bisq/apitest/method/GetMethodHelpTest.java
index 99e7b4873f2..4e426be660d 100644
--- a/apitest/src/test/java/bisq/apitest/method/GetMethodHelpTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/GetMethodHelpTest.java
@@ -17,8 +17,6 @@
package bisq.apitest.method;
-import bisq.proto.grpc.GetMethodHelpRequest;
-
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterAll;
@@ -51,10 +49,7 @@ public static void setUp() {
@Test
@Order(1)
public void testGetCreateOfferHelp() {
- var help = grpcStubs(alicedaemon).helpService
- .getMethodHelp(GetMethodHelpRequest.newBuilder()
- .setMethodName(createoffer.name()).build())
- .getMethodHelp();
+ var help = aliceClient.getMethodHelp(createoffer);
assertNotNull(help);
}
diff --git a/apitest/src/test/java/bisq/apitest/method/GetVersionTest.java b/apitest/src/test/java/bisq/apitest/method/GetVersionTest.java
index 212eb5ca438..6b84b6ccd72 100644
--- a/apitest/src/test/java/bisq/apitest/method/GetVersionTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/GetVersionTest.java
@@ -17,8 +17,6 @@
package bisq.apitest.method;
-import bisq.proto.grpc.GetVersionRequest;
-
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterAll;
@@ -51,8 +49,7 @@ public static void setUp() {
@Test
@Order(1)
public void testGetVersion() {
- var version = grpcStubs(alicedaemon).versionService
- .getVersion(GetVersionRequest.newBuilder().build()).getVersion();
+ var version = aliceClient.getVersion();
assertEquals(VERSION, version);
}
diff --git a/apitest/src/test/java/bisq/apitest/method/MethodTest.java b/apitest/src/test/java/bisq/apitest/method/MethodTest.java
index 26fa8c422cb..84f5eed6941 100644
--- a/apitest/src/test/java/bisq/apitest/method/MethodTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/MethodTest.java
@@ -18,76 +18,27 @@
package bisq.apitest.method;
import bisq.core.api.model.PaymentAccountForm;
-import bisq.core.api.model.TxFeeRateInfo;
import bisq.core.payment.F2FAccount;
import bisq.core.proto.CoreProtoResolver;
import bisq.common.util.Utilities;
-import bisq.proto.grpc.AddressBalanceInfo;
-import bisq.proto.grpc.BalancesInfo;
-import bisq.proto.grpc.BsqBalanceInfo;
-import bisq.proto.grpc.BtcBalanceInfo;
-import bisq.proto.grpc.CancelOfferRequest;
-import bisq.proto.grpc.ConfirmPaymentReceivedRequest;
-import bisq.proto.grpc.ConfirmPaymentStartedRequest;
-import bisq.proto.grpc.CreatePaymentAccountRequest;
-import bisq.proto.grpc.GetAddressBalanceRequest;
-import bisq.proto.grpc.GetBalancesRequest;
-import bisq.proto.grpc.GetFundingAddressesRequest;
-import bisq.proto.grpc.GetMethodHelpRequest;
-import bisq.proto.grpc.GetMyOfferRequest;
-import bisq.proto.grpc.GetOfferRequest;
-import bisq.proto.grpc.GetPaymentAccountFormRequest;
-import bisq.proto.grpc.GetPaymentAccountsRequest;
-import bisq.proto.grpc.GetPaymentMethodsRequest;
-import bisq.proto.grpc.GetTradeRequest;
-import bisq.proto.grpc.GetTransactionRequest;
-import bisq.proto.grpc.GetTxFeeRateRequest;
-import bisq.proto.grpc.GetUnusedBsqAddressRequest;
-import bisq.proto.grpc.KeepFundsRequest;
-import bisq.proto.grpc.LockWalletRequest;
-import bisq.proto.grpc.MarketPriceRequest;
-import bisq.proto.grpc.OfferInfo;
-import bisq.proto.grpc.RegisterDisputeAgentRequest;
-import bisq.proto.grpc.RemoveWalletPasswordRequest;
-import bisq.proto.grpc.SendBsqRequest;
-import bisq.proto.grpc.SendBtcRequest;
-import bisq.proto.grpc.SetTxFeeRatePreferenceRequest;
-import bisq.proto.grpc.SetWalletPasswordRequest;
-import bisq.proto.grpc.TakeOfferRequest;
-import bisq.proto.grpc.TradeInfo;
-import bisq.proto.grpc.TxInfo;
-import bisq.proto.grpc.UnlockWalletRequest;
-import bisq.proto.grpc.UnsetTxFeeRatePreferenceRequest;
-import bisq.proto.grpc.WithdrawFundsRequest;
-
-import protobuf.PaymentAccount;
-import protobuf.PaymentMethod;
-
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
-import java.util.List;
import java.util.function.Function;
import java.util.stream.Collectors;
-import static bisq.apitest.config.BisqAppConfig.alicedaemon;
-import static bisq.apitest.config.BisqAppConfig.arbdaemon;
-import static bisq.apitest.config.BisqAppConfig.bobdaemon;
import static bisq.common.app.DevEnv.DEV_PRIVILEGE_PRIV_KEY;
import static java.nio.charset.StandardCharsets.UTF_8;
import static java.util.Arrays.stream;
-import static java.util.Comparator.comparing;
-import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
import bisq.apitest.ApiTestCase;
-import bisq.apitest.config.BisqAppConfig;
-import bisq.cli.GrpcStubs;
+import bisq.cli.GrpcClient;
public class MethodTest extends ApiTestCase {
@@ -95,13 +46,7 @@ public class MethodTest extends ApiTestCase {
protected static final String MEDIATOR = "mediator";
protected static final String REFUND_AGENT = "refundagent";
- protected static GrpcStubs aliceStubs;
- protected static GrpcStubs bobStubs;
-
- protected static PaymentAccount alicesDummyAcct;
- protected static PaymentAccount bobsDummyAcct;
-
- private static final CoreProtoResolver CORE_PROTO_RESOLVER = new CoreProtoResolver();
+ protected static final CoreProtoResolver CORE_PROTO_RESOLVER = new CoreProtoResolver();
private static final Function[], String> toNameList = (enums) ->
stream(enums).map(Enum::name).collect(Collectors.joining(","));
@@ -116,7 +61,7 @@ public static void startSupportingApps(File callRateMeteringConfigFile,
"--callRateMeteringConfigPath", callRateMeteringConfigFile.getAbsolutePath(),
"--enableBisqDebugging", "false"
});
- doPostStartup(registerDisputeAgents, generateBtcBlock, supportingApps);
+ doPostStartup(registerDisputeAgents, generateBtcBlock);
} catch (Exception ex) {
fail(ex);
}
@@ -130,27 +75,16 @@ public static void startSupportingApps(boolean registerDisputeAgents,
"--supportingApps", toNameList.apply(supportingApps),
"--enableBisqDebugging", "false"
});
- doPostStartup(registerDisputeAgents, generateBtcBlock, supportingApps);
+ doPostStartup(registerDisputeAgents, generateBtcBlock);
} catch (Exception ex) {
fail(ex);
}
}
protected static void doPostStartup(boolean registerDisputeAgents,
- boolean generateBtcBlock,
- Enum>... supportingApps) {
+ boolean generateBtcBlock) {
if (registerDisputeAgents) {
- registerDisputeAgents(arbdaemon);
- }
-
- if (stream(supportingApps).map(Enum::name).anyMatch(name -> name.equals(alicedaemon.name()))) {
- aliceStubs = grpcStubs(alicedaemon);
- alicesDummyAcct = getDefaultPerfectDummyPaymentAccount(alicedaemon);
- }
-
- if (stream(supportingApps).map(Enum::name).anyMatch(name -> name.equals(bobdaemon.name()))) {
- bobStubs = grpcStubs(bobdaemon);
- bobsDummyAcct = getDefaultPerfectDummyPaymentAccount(bobdaemon);
+ registerDisputeAgents();
}
// Generate 1 regtest block for alice's and/or bob's wallet to
@@ -159,212 +93,11 @@ protected static void doPostStartup(boolean registerDisputeAgents,
genBtcBlocksThenWait(1, 1500);
}
- // Convenience methods for building gRPC request objects
- protected final GetBalancesRequest createGetBalancesRequest(String currencyCode) {
- return GetBalancesRequest.newBuilder().setCurrencyCode(currencyCode).build();
- }
-
- protected final GetAddressBalanceRequest createGetAddressBalanceRequest(String address) {
- return GetAddressBalanceRequest.newBuilder().setAddress(address).build();
- }
-
- protected final SetWalletPasswordRequest createSetWalletPasswordRequest(String password) {
- return SetWalletPasswordRequest.newBuilder().setPassword(password).build();
- }
-
- protected final SetWalletPasswordRequest createSetWalletPasswordRequest(String oldPassword, String newPassword) {
- return SetWalletPasswordRequest.newBuilder().setPassword(oldPassword).setNewPassword(newPassword).build();
- }
-
- protected final RemoveWalletPasswordRequest createRemoveWalletPasswordRequest(String password) {
- return RemoveWalletPasswordRequest.newBuilder().setPassword(password).build();
- }
-
- protected final UnlockWalletRequest createUnlockWalletRequest(String password, long timeout) {
- return UnlockWalletRequest.newBuilder().setPassword(password).setTimeout(timeout).build();
- }
-
- protected final LockWalletRequest createLockWalletRequest() {
- return LockWalletRequest.newBuilder().build();
- }
-
- protected final GetUnusedBsqAddressRequest createGetUnusedBsqAddressRequest() {
- return GetUnusedBsqAddressRequest.newBuilder().build();
- }
-
- protected final SendBsqRequest createSendBsqRequest(String address,
- String amount,
- String txFeeRate) {
- return SendBsqRequest.newBuilder()
- .setAddress(address)
- .setAmount(amount)
- .setTxFeeRate(txFeeRate)
- .build();
- }
-
- protected final SendBtcRequest createSendBtcRequest(String address,
- String amount,
- String txFeeRate,
- String memo) {
- return SendBtcRequest.newBuilder()
- .setAddress(address)
- .setAmount(amount)
- .setTxFeeRate(txFeeRate)
- .setMemo(memo)
- .build();
- }
-
- protected final GetFundingAddressesRequest createGetFundingAddressesRequest() {
- return GetFundingAddressesRequest.newBuilder().build();
- }
-
- protected final MarketPriceRequest createMarketPriceRequest(String currencyCode) {
- return MarketPriceRequest.newBuilder().setCurrencyCode(currencyCode).build();
- }
-
- protected final GetOfferRequest createGetOfferRequest(String offerId) {
- return GetOfferRequest.newBuilder().setId(offerId).build();
- }
-
- protected final GetMyOfferRequest createGetMyOfferRequest(String offerId) {
- return GetMyOfferRequest.newBuilder().setId(offerId).build();
- }
-
- protected final CancelOfferRequest createCancelOfferRequest(String offerId) {
- return CancelOfferRequest.newBuilder().setId(offerId).build();
- }
-
- protected final TakeOfferRequest createTakeOfferRequest(String offerId,
- String paymentAccountId,
- String takerFeeCurrencyCode) {
- return TakeOfferRequest.newBuilder()
- .setOfferId(offerId)
- .setPaymentAccountId(paymentAccountId)
- .setTakerFeeCurrencyCode(takerFeeCurrencyCode)
- .build();
- }
-
- protected final GetTradeRequest createGetTradeRequest(String tradeId) {
- return GetTradeRequest.newBuilder().setTradeId(tradeId).build();
- }
-
- protected final ConfirmPaymentStartedRequest createConfirmPaymentStartedRequest(String tradeId) {
- return ConfirmPaymentStartedRequest.newBuilder().setTradeId(tradeId).build();
- }
-
- protected final ConfirmPaymentReceivedRequest createConfirmPaymentReceivedRequest(String tradeId) {
- return ConfirmPaymentReceivedRequest.newBuilder().setTradeId(tradeId).build();
- }
-
- protected final KeepFundsRequest createKeepFundsRequest(String tradeId) {
- return KeepFundsRequest.newBuilder()
- .setTradeId(tradeId)
- .build();
- }
-
- protected final WithdrawFundsRequest createWithdrawFundsRequest(String tradeId,
- String address,
- String memo) {
- return WithdrawFundsRequest.newBuilder()
- .setTradeId(tradeId)
- .setAddress(address)
- .setMemo(memo)
- .build();
- }
-
- protected final GetMethodHelpRequest createGetMethodHelpRequest(String methodName) {
- return GetMethodHelpRequest.newBuilder().setMethodName(methodName).build();
- }
-
- // Convenience methods for calling frequently used & thoroughly tested gRPC services.
- protected final BalancesInfo getBalances(BisqAppConfig bisqAppConfig, String currencyCode) {
- return grpcStubs(bisqAppConfig).walletsService.getBalances(
- createGetBalancesRequest(currencyCode)).getBalances();
- }
-
- protected final BsqBalanceInfo getBsqBalances(BisqAppConfig bisqAppConfig) {
- return getBalances(bisqAppConfig, "bsq").getBsq();
- }
-
- protected final BtcBalanceInfo getBtcBalances(BisqAppConfig bisqAppConfig) {
- return getBalances(bisqAppConfig, "btc").getBtc();
- }
-
- protected final AddressBalanceInfo getAddressBalance(BisqAppConfig bisqAppConfig, String address) {
- return grpcStubs(bisqAppConfig).walletsService.getAddressBalance(createGetAddressBalanceRequest(address)).getAddressBalanceInfo();
- }
-
- protected final void unlockWallet(BisqAppConfig bisqAppConfig, String password, long timeout) {
- //noinspection ResultOfMethodCallIgnored
- grpcStubs(bisqAppConfig).walletsService.unlockWallet(createUnlockWalletRequest(password, timeout));
- }
-
- protected final void lockWallet(BisqAppConfig bisqAppConfig) {
- //noinspection ResultOfMethodCallIgnored
- grpcStubs(bisqAppConfig).walletsService.lockWallet(createLockWalletRequest());
- }
-
- protected final String getUnusedBsqAddress(BisqAppConfig bisqAppConfig) {
- return grpcStubs(bisqAppConfig).walletsService.getUnusedBsqAddress(createGetUnusedBsqAddressRequest()).getAddress();
- }
-
- protected final TxInfo sendBsq(BisqAppConfig bisqAppConfig,
- String address,
- String amount) {
- return sendBsq(bisqAppConfig, address, amount, "");
- }
-
- protected final TxInfo sendBsq(BisqAppConfig bisqAppConfig,
- String address,
- String amount,
- String txFeeRate) {
- //noinspection ResultOfMethodCallIgnored
- return grpcStubs(bisqAppConfig).walletsService.sendBsq(createSendBsqRequest(address,
- amount,
- txFeeRate))
- .getTxInfo();
- }
-
- protected final TxInfo sendBtc(BisqAppConfig bisqAppConfig, String address, String amount) {
- return sendBtc(bisqAppConfig, address, amount, "", "");
- }
-
- protected final TxInfo sendBtc(BisqAppConfig bisqAppConfig,
- String address,
- String amount,
- String txFeeRate,
- String memo) {
- //noinspection ResultOfMethodCallIgnored
- return grpcStubs(bisqAppConfig).walletsService.sendBtc(
- createSendBtcRequest(address, amount, txFeeRate, memo))
- .getTxInfo();
- }
-
- protected final String getUnusedBtcAddress(BisqAppConfig bisqAppConfig) {
- //noinspection OptionalGetWithoutIsPresent
- return grpcStubs(bisqAppConfig).walletsService.getFundingAddresses(createGetFundingAddressesRequest())
- .getAddressBalanceInfoList()
- .stream()
- .filter(a -> a.getBalance() == 0 && a.getNumConfirmations() == 0)
- .findFirst()
- .get()
- .getAddress();
- }
-
- protected final List getPaymentMethods(BisqAppConfig bisqAppConfig) {
- var req = GetPaymentMethodsRequest.newBuilder().build();
- return grpcStubs(bisqAppConfig).paymentAccountsService.getPaymentMethods(req).getPaymentMethodsList();
- }
-
- protected final File getPaymentAccountForm(BisqAppConfig bisqAppConfig, String paymentMethodId) {
+ protected final File getPaymentAccountForm(GrpcClient grpcClient, String paymentMethodId) {
// We take seemingly unnecessary steps to get a File object, but the point is to
// test the API, and we do not directly ask bisq.core.api.model.PaymentAccountForm
// for an empty json form (file).
- var req = GetPaymentAccountFormRequest.newBuilder()
- .setPaymentMethodId(paymentMethodId)
- .build();
- String jsonString = grpcStubs(bisqAppConfig).paymentAccountsService.getPaymentAccountForm(req)
- .getPaymentAccountFormJson();
+ String jsonString = grpcClient.getPaymentAcctFormAsJson(paymentMethodId);
// Write the json string to a file here in the test case.
File jsonFile = PaymentAccountForm.getTmpJsonFile(paymentMethodId);
try (PrintWriter out = new PrintWriter(jsonFile, UTF_8)) {
@@ -375,113 +108,9 @@ protected final File getPaymentAccountForm(BisqAppConfig bisqAppConfig, String p
return jsonFile;
}
- protected final bisq.core.payment.PaymentAccount createPaymentAccount(BisqAppConfig bisqAppConfig,
- String jsonString) {
- var req = CreatePaymentAccountRequest.newBuilder()
- .setPaymentAccountForm(jsonString)
- .build();
- var paymentAccountsService = grpcStubs(bisqAppConfig).paymentAccountsService;
- // Normally, we can do asserts on the protos from the gRPC service, but in this
- // case we need to return a bisq.core.payment.PaymentAccount so it can be cast
- // to its sub type.
- return fromProto(paymentAccountsService.createPaymentAccount(req).getPaymentAccount());
- }
-
- protected static List getPaymentAccounts(BisqAppConfig bisqAppConfig) {
- var req = GetPaymentAccountsRequest.newBuilder().build();
- return grpcStubs(bisqAppConfig).paymentAccountsService.getPaymentAccounts(req)
- .getPaymentAccountsList()
- .stream()
- .sorted(comparing(PaymentAccount::getCreationDate))
- .collect(Collectors.toList());
- }
-
- protected static PaymentAccount getDefaultPerfectDummyPaymentAccount(BisqAppConfig bisqAppConfig) {
- PaymentAccount paymentAccount = getPaymentAccounts(bisqAppConfig).get(0);
- assertEquals("PerfectMoney dummy", paymentAccount.getAccountName());
- return paymentAccount;
- }
-
- protected final double getMarketPrice(BisqAppConfig bisqAppConfig, String currencyCode) {
- var req = createMarketPriceRequest(currencyCode);
- return grpcStubs(bisqAppConfig).priceService.getMarketPrice(req).getPrice();
- }
-
- protected final OfferInfo getOffer(BisqAppConfig bisqAppConfig, String offerId) {
- var req = createGetOfferRequest(offerId);
- return grpcStubs(bisqAppConfig).offersService.getOffer(req).getOffer();
- }
-
- protected final OfferInfo getMyOffer(BisqAppConfig bisqAppConfig, String offerId) {
- var req = createGetMyOfferRequest(offerId);
- return grpcStubs(bisqAppConfig).offersService.getMyOffer(req).getOffer();
- }
-
- @SuppressWarnings("ResultOfMethodCallIgnored")
- protected final void cancelOffer(BisqAppConfig bisqAppConfig, String offerId) {
- var req = createCancelOfferRequest(offerId);
- grpcStubs(bisqAppConfig).offersService.cancelOffer(req);
- }
-
- protected final TradeInfo getTrade(BisqAppConfig bisqAppConfig, String tradeId) {
- var req = createGetTradeRequest(tradeId);
- return grpcStubs(bisqAppConfig).tradesService.getTrade(req).getTrade();
- }
-
- @SuppressWarnings("ResultOfMethodCallIgnored")
- protected final void confirmPaymentStarted(BisqAppConfig bisqAppConfig, String tradeId) {
- var req = createConfirmPaymentStartedRequest(tradeId);
- grpcStubs(bisqAppConfig).tradesService.confirmPaymentStarted(req);
- }
-
- @SuppressWarnings("ResultOfMethodCallIgnored")
- protected final void confirmPaymentReceived(BisqAppConfig bisqAppConfig, String tradeId) {
- var req = createConfirmPaymentReceivedRequest(tradeId);
- grpcStubs(bisqAppConfig).tradesService.confirmPaymentReceived(req);
- }
-
- @SuppressWarnings("ResultOfMethodCallIgnored")
- protected final void keepFunds(BisqAppConfig bisqAppConfig, String tradeId) {
- var req = createKeepFundsRequest(tradeId);
- grpcStubs(bisqAppConfig).tradesService.keepFunds(req);
- }
-
- @SuppressWarnings("ResultOfMethodCallIgnored")
- protected final void withdrawFunds(BisqAppConfig bisqAppConfig,
- String tradeId,
- String address,
- String memo) {
- var req = createWithdrawFundsRequest(tradeId, address, memo);
- grpcStubs(bisqAppConfig).tradesService.withdrawFunds(req);
- }
-
- protected final TxFeeRateInfo getTxFeeRate(BisqAppConfig bisqAppConfig) {
- var req = GetTxFeeRateRequest.newBuilder().build();
- return TxFeeRateInfo.fromProto(
- grpcStubs(bisqAppConfig).walletsService.getTxFeeRate(req).getTxFeeRateInfo());
- }
-
- protected final TxFeeRateInfo setTxFeeRate(BisqAppConfig bisqAppConfig, long feeRate) {
- var req = SetTxFeeRatePreferenceRequest.newBuilder()
- .setTxFeeRatePreference(feeRate)
- .build();
- return TxFeeRateInfo.fromProto(
- grpcStubs(bisqAppConfig).walletsService.setTxFeeRatePreference(req).getTxFeeRateInfo());
- }
-
- protected final TxFeeRateInfo unsetTxFeeRate(BisqAppConfig bisqAppConfig) {
- var req = UnsetTxFeeRatePreferenceRequest.newBuilder().build();
- return TxFeeRateInfo.fromProto(
- grpcStubs(bisqAppConfig).walletsService.unsetTxFeeRatePreference(req).getTxFeeRateInfo());
- }
-
- protected final TxInfo getTransaction(BisqAppConfig bisqAppConfig, String txId) {
- var req = GetTransactionRequest.newBuilder().setTxId(txId).build();
- return grpcStubs(bisqAppConfig).walletsService.getTransaction(req).getTxInfo();
- }
- public bisq.core.payment.PaymentAccount createDummyF2FAccount(BisqAppConfig bisqAppConfig,
- String countryCode) {
+ protected bisq.core.payment.PaymentAccount createDummyF2FAccount(GrpcClient grpcClient,
+ String countryCode) {
String f2fAccountJsonString = "{\n" +
" \"_COMMENTS_\": \"This is a dummy account.\",\n" +
" \"paymentMethodId\": \"F2F\",\n" +
@@ -491,35 +120,26 @@ public bisq.core.payment.PaymentAccount createDummyF2FAccount(BisqAppConfig bisq
" \"country\": \"" + countryCode.toUpperCase() + "\",\n" +
" \"extraInfo\": \"Salt Lick #213\"\n" +
"}\n";
- F2FAccount f2FAccount = (F2FAccount) createPaymentAccount(bisqAppConfig, f2fAccountJsonString);
+ F2FAccount f2FAccount = (F2FAccount) createPaymentAccount(grpcClient, f2fAccountJsonString);
return f2FAccount;
}
- protected final String getMethodHelp(BisqAppConfig bisqAppConfig, String methodName) {
- var req = createGetMethodHelpRequest(methodName);
- return grpcStubs(bisqAppConfig).helpService.getMethodHelp(req).getMethodHelp();
+ protected final bisq.core.payment.PaymentAccount createPaymentAccount(GrpcClient grpcClient, String jsonString) {
+ // Normally, we do asserts on the protos from the gRPC service, but in this
+ // case we need a bisq.core.payment.PaymentAccount so it can be cast to its
+ // sub type.
+ var paymentAccount = grpcClient.createPaymentAccount(jsonString);
+ return bisq.core.payment.PaymentAccount.fromProto(paymentAccount, CORE_PROTO_RESOLVER);
}
// Static conveniences for test methods and test case fixture setups.
- protected static RegisterDisputeAgentRequest createRegisterDisputeAgentRequest(String disputeAgentType) {
- return RegisterDisputeAgentRequest.newBuilder()
- .setDisputeAgentType(disputeAgentType.toLowerCase())
- .setRegistrationKey(DEV_PRIVILEGE_PRIV_KEY).build();
- }
-
- @SuppressWarnings({"ResultOfMethodCallIgnored", "SameParameterValue"})
- protected static void registerDisputeAgents(BisqAppConfig bisqAppConfig) {
- var disputeAgentsService = grpcStubs(bisqAppConfig).disputeAgentsService;
- disputeAgentsService.registerDisputeAgent(createRegisterDisputeAgentRequest(MEDIATOR));
- disputeAgentsService.registerDisputeAgent(createRegisterDisputeAgentRequest(REFUND_AGENT));
+ protected static void registerDisputeAgents() {
+ arbClient.registerDisputeAgent(MEDIATOR, DEV_PRIVILEGE_PRIV_KEY);
+ arbClient.registerDisputeAgent(REFUND_AGENT, DEV_PRIVILEGE_PRIV_KEY);
}
protected static String encodeToHex(String s) {
return Utilities.bytesAsHexString(s.getBytes(UTF_8));
}
-
- private bisq.core.payment.PaymentAccount fromProto(PaymentAccount proto) {
- return bisq.core.payment.PaymentAccount.fromProto(proto, CORE_PROTO_RESOLVER);
- }
}
diff --git a/apitest/src/test/java/bisq/apitest/method/RegisterDisputeAgentsTest.java b/apitest/src/test/java/bisq/apitest/method/RegisterDisputeAgentsTest.java
index 746c851b4d5..9b3a2e5f0b4 100644
--- a/apitest/src/test/java/bisq/apitest/method/RegisterDisputeAgentsTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/RegisterDisputeAgentsTest.java
@@ -17,8 +17,6 @@
package bisq.apitest.method;
-import bisq.proto.grpc.RegisterDisputeAgentRequest;
-
import io.grpc.StatusRuntimeException;
import lombok.extern.slf4j.Slf4j;
@@ -58,9 +56,8 @@ public static void setUp() {
@Test
@Order(1)
public void testRegisterArbitratorShouldThrowException() {
- var req = createRegisterDisputeAgentRequest(ARBITRATOR);
Throwable exception = assertThrows(StatusRuntimeException.class, () ->
- grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req));
+ arbClient.registerDisputeAgent(ARBITRATOR, DEV_PRIVILEGE_PRIV_KEY));
assertEquals("INVALID_ARGUMENT: arbitrators must be registered in a Bisq UI",
exception.getMessage());
}
@@ -68,9 +65,8 @@ public void testRegisterArbitratorShouldThrowException() {
@Test
@Order(2)
public void testInvalidDisputeAgentTypeArgShouldThrowException() {
- var req = createRegisterDisputeAgentRequest("badagent");
Throwable exception = assertThrows(StatusRuntimeException.class, () ->
- grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req));
+ arbClient.registerDisputeAgent("badagent", DEV_PRIVILEGE_PRIV_KEY));
assertEquals("INVALID_ARGUMENT: unknown dispute agent type 'badagent'",
exception.getMessage());
}
@@ -78,11 +74,8 @@ public void testInvalidDisputeAgentTypeArgShouldThrowException() {
@Test
@Order(3)
public void testInvalidRegistrationKeyArgShouldThrowException() {
- var req = RegisterDisputeAgentRequest.newBuilder()
- .setDisputeAgentType(REFUND_AGENT)
- .setRegistrationKey("invalid" + DEV_PRIVILEGE_PRIV_KEY).build();
Throwable exception = assertThrows(StatusRuntimeException.class, () ->
- grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req));
+ arbClient.registerDisputeAgent(REFUND_AGENT, "invalid" + DEV_PRIVILEGE_PRIV_KEY));
assertEquals("INVALID_ARGUMENT: invalid registration key",
exception.getMessage());
}
@@ -90,15 +83,13 @@ public void testInvalidRegistrationKeyArgShouldThrowException() {
@Test
@Order(4)
public void testRegisterMediator() {
- var req = createRegisterDisputeAgentRequest(MEDIATOR);
- grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req);
+ arbClient.registerDisputeAgent(MEDIATOR, DEV_PRIVILEGE_PRIV_KEY);
}
@Test
@Order(5)
public void testRegisterRefundAgent() {
- var req = createRegisterDisputeAgentRequest(REFUND_AGENT);
- grpcStubs(arbdaemon).disputeAgentsService.registerDisputeAgent(req);
+ arbClient.registerDisputeAgent(REFUND_AGENT, DEV_PRIVILEGE_PRIV_KEY);
}
@AfterAll
diff --git a/apitest/src/test/java/bisq/apitest/method/offer/AbstractOfferTest.java b/apitest/src/test/java/bisq/apitest/method/offer/AbstractOfferTest.java
index 84242c10871..095e4f0d1dc 100644
--- a/apitest/src/test/java/bisq/apitest/method/offer/AbstractOfferTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/offer/AbstractOfferTest.java
@@ -18,20 +18,11 @@
package bisq.apitest.method.offer;
import bisq.core.monetary.Altcoin;
-import bisq.core.payment.PaymentAccount;
-
-import bisq.proto.grpc.CreateOfferRequest;
-import bisq.proto.grpc.GetMyOffersRequest;
-import bisq.proto.grpc.GetOffersRequest;
-import bisq.proto.grpc.OfferInfo;
import org.bitcoinj.utils.Fiat;
import java.math.BigDecimal;
-import java.util.List;
-import java.util.stream.Collectors;
-
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterAll;
@@ -44,17 +35,12 @@
import static bisq.apitest.config.BisqAppConfig.seednode;
import static bisq.common.util.MathUtils.roundDouble;
import static bisq.common.util.MathUtils.scaleDownByPowerOf10;
-import static bisq.core.btc.wallet.Restrictions.getDefaultBuyerSecurityDepositAsPercent;
import static bisq.core.locale.CurrencyUtil.isCryptoCurrency;
-import static java.lang.String.format;
import static java.math.RoundingMode.HALF_UP;
-import static java.util.Comparator.comparing;
-import static org.junit.jupiter.api.Assertions.fail;
import bisq.apitest.method.MethodTest;
-import bisq.cli.GrpcStubs;
@Slf4j
public abstract class AbstractOfferTest extends MethodTest {
@@ -70,109 +56,11 @@ public static void setUp() {
bobdaemon);
}
- protected final OfferInfo createAliceOffer(PaymentAccount paymentAccount,
- String direction,
- String currencyCode,
- long amount,
- String makerFeeCurrencyCode) {
- return createMarketBasedPricedOffer(aliceStubs,
- paymentAccount,
- direction,
- currencyCode,
- amount,
- makerFeeCurrencyCode);
- }
-
- protected final OfferInfo createBobOffer(PaymentAccount paymentAccount,
- String direction,
- String currencyCode,
- long amount,
- String makerFeeCurrencyCode) {
- return createMarketBasedPricedOffer(bobStubs,
- paymentAccount,
- direction,
- currencyCode,
- amount,
- makerFeeCurrencyCode);
- }
-
- protected final OfferInfo createMarketBasedPricedOffer(GrpcStubs grpcStubs,
- PaymentAccount paymentAccount,
- String direction,
- String currencyCode,
- long amount,
- String makerFeeCurrencyCode) {
- var req = CreateOfferRequest.newBuilder()
- .setPaymentAccountId(paymentAccount.getId())
- .setDirection(direction)
- .setCurrencyCode(currencyCode)
- .setAmount(amount)
- .setMinAmount(amount)
- .setUseMarketBasedPrice(true)
- .setMarketPriceMargin(0.00)
- .setPrice("0")
- .setBuyerSecurityDeposit(getDefaultBuyerSecurityDepositAsPercent())
- .setMakerFeeCurrencyCode(makerFeeCurrencyCode)
- .build();
- return grpcStubs.offersService.createOffer(req).getOffer();
- }
-
- protected final OfferInfo getOffer(String offerId) {
- return aliceStubs.offersService.getOffer(createGetOfferRequest(offerId)).getOffer();
- }
-
- protected final OfferInfo getMyOffer(String offerId) {
- return aliceStubs.offersService.getMyOffer(createGetMyOfferRequest(offerId)).getOffer();
- }
-
- @SuppressWarnings("ResultOfMethodCallIgnored")
- protected final void cancelOffer(GrpcStubs grpcStubs, String offerId) {
- grpcStubs.offersService.cancelOffer(createCancelOfferRequest(offerId));
- }
-
- protected final OfferInfo getMostRecentOffer(GrpcStubs grpcStubs, String direction, String currencyCode) {
- List offerInfoList = getOffersSortedByDate(grpcStubs, direction, currencyCode);
- if (offerInfoList.isEmpty())
- fail(format("No %s offers found for currency %s", direction, currencyCode));
-
- return offerInfoList.get(offerInfoList.size() - 1);
- }
-
- protected final List getOffersSortedByDate(GrpcStubs grpcStubs,
- String direction,
- String currencyCode) {
- var req = GetOffersRequest.newBuilder()
- .setDirection(direction)
- .setCurrencyCode(currencyCode).build();
- var reply = grpcStubs.offersService.getOffers(req);
- return sortOffersByDate(reply.getOffersList());
- }
-
- protected final List getMyOffersSortedByDate(GrpcStubs grpcStubs,
- String direction,
- String currencyCode) {
- var req = GetMyOffersRequest.newBuilder()
- .setDirection(direction)
- .setCurrencyCode(currencyCode).build();
- var reply = grpcStubs.offersService.getMyOffers(req);
- return sortOffersByDate(reply.getOffersList());
- }
-
- protected final List sortOffersByDate(List offerInfoList) {
- return offerInfoList.stream()
- .sorted(comparing(OfferInfo::getDate))
- .collect(Collectors.toList());
- }
-
protected double getScaledOfferPrice(double offerPrice, String currencyCode) {
int precision = isCryptoCurrency(currencyCode) ? Altcoin.SMALLEST_UNIT_EXPONENT : Fiat.SMALLEST_UNIT_EXPONENT;
return scaleDownByPowerOf10(offerPrice, precision);
}
- protected final double getMarketPrice(String currencyCode) {
- return getMarketPrice(alicedaemon, currencyCode);
- }
-
protected final double getPercentageDifference(double price1, double price2) {
return BigDecimal.valueOf(roundDouble((1 - (price1 / price2)), 5))
.setScale(4, HALF_UP)
diff --git a/apitest/src/test/java/bisq/apitest/method/offer/CancelOfferTest.java b/apitest/src/test/java/bisq/apitest/method/offer/CancelOfferTest.java
index 9be112e16be..166d853c901 100644
--- a/apitest/src/test/java/bisq/apitest/method/offer/CancelOfferTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/offer/CancelOfferTest.java
@@ -17,13 +17,12 @@
package bisq.apitest.method.offer;
-import bisq.core.btc.wallet.Restrictions;
import bisq.core.payment.PaymentAccount;
-import bisq.proto.grpc.CreateOfferRequest;
import bisq.proto.grpc.OfferInfo;
import java.util.List;
+import java.util.function.Consumer;
import lombok.extern.slf4j.Slf4j;
@@ -33,7 +32,7 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
-import static bisq.apitest.config.BisqAppConfig.alicedaemon;
+import static bisq.core.btc.wallet.Restrictions.getDefaultBuyerSecurityDepositAsPercent;
import static org.junit.jupiter.api.Assertions.assertEquals;
@Disabled
@@ -45,45 +44,43 @@ public class CancelOfferTest extends AbstractOfferTest {
private static final String CURRENCY_CODE = "cad";
private static final int MAX_OFFERS = 3;
+ private final Consumer createOfferToCancel = (paymentAccountId) -> {
+ aliceClient.createMarketBasedPricedOffer(DIRECTION,
+ CURRENCY_CODE,
+ 10000000L,
+ 10000000L,
+ 0.00,
+ getDefaultBuyerSecurityDepositAsPercent(),
+ paymentAccountId,
+ "bsq");
+ };
+
@Test
@Order(1)
public void testCancelOffer() {
- PaymentAccount cadAccount = createDummyF2FAccount(alicedaemon, "CA");
- var req = CreateOfferRequest.newBuilder()
- .setPaymentAccountId(cadAccount.getId())
- .setDirection(DIRECTION)
- .setCurrencyCode(CURRENCY_CODE)
- .setAmount(10000000)
- .setMinAmount(10000000)
- .setUseMarketBasedPrice(true)
- .setMarketPriceMargin(0.00)
- .setPrice("0")
- .setBuyerSecurityDeposit(Restrictions.getDefaultBuyerSecurityDepositAsPercent())
- .setMakerFeeCurrencyCode("bsq")
- .build();
+ PaymentAccount cadAccount = createDummyF2FAccount(aliceClient, "CA");
// Create some offers.
for (int i = 1; i <= MAX_OFFERS; i++) {
- //noinspection ResultOfMethodCallIgnored
- aliceStubs.offersService.createOffer(req);
+ createOfferToCancel.accept(cadAccount.getId());
// Wait for Alice's AddToOfferBook task.
// Wait times vary; my logs show >= 2 second delay.
sleep(2500);
}
- List offers = getMyOffersSortedByDate(aliceStubs, DIRECTION, CURRENCY_CODE);
+ List offers = aliceClient.getMyOffersSortedByDate(DIRECTION, CURRENCY_CODE);
assertEquals(MAX_OFFERS, offers.size());
// Cancel the offers, checking the open offer count after each offer removal.
for (int i = 1; i <= MAX_OFFERS; i++) {
- cancelOffer(aliceStubs, offers.remove(0).getId());
- offers = getMyOffersSortedByDate(aliceStubs, DIRECTION, CURRENCY_CODE);
+ aliceClient.cancelOffer(offers.remove(0).getId());
+ offers = aliceClient.getMyOffersSortedByDate(DIRECTION, CURRENCY_CODE);
assertEquals(MAX_OFFERS - i, offers.size());
}
sleep(1000); // wait for offer removal
- offers = getMyOffersSortedByDate(aliceStubs, DIRECTION, CURRENCY_CODE);
+ offers = aliceClient.getMyOffersSortedByDate(DIRECTION, CURRENCY_CODE);
assertEquals(0, offers.size());
}
}
diff --git a/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingFixedPriceTest.java b/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingFixedPriceTest.java
index 8f43660914c..2e8b2962b2a 100644
--- a/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingFixedPriceTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingFixedPriceTest.java
@@ -19,8 +19,6 @@
import bisq.core.payment.PaymentAccount;
-import bisq.proto.grpc.CreateOfferRequest;
-
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Disabled;
@@ -29,7 +27,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
-import static bisq.apitest.config.BisqAppConfig.alicedaemon;
import static bisq.core.btc.wallet.Restrictions.getDefaultBuyerSecurityDepositAsPercent;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -45,20 +42,15 @@ public class CreateOfferUsingFixedPriceTest extends AbstractOfferTest {
@Test
@Order(1)
public void testCreateAUDBTCBuyOfferUsingFixedPrice16000() {
- PaymentAccount audAccount = createDummyF2FAccount(alicedaemon, "AU");
- var req = CreateOfferRequest.newBuilder()
- .setPaymentAccountId(audAccount.getId())
- .setDirection("buy")
- .setCurrencyCode("aud")
- .setAmount(10000000)
- .setMinAmount(10000000)
- .setUseMarketBasedPrice(false)
- .setMarketPriceMargin(0.00)
- .setPrice("36000")
- .setBuyerSecurityDeposit(getDefaultBuyerSecurityDepositAsPercent())
- .setMakerFeeCurrencyCode(MAKER_FEE_CURRENCY_CODE)
- .build();
- var newOffer = aliceStubs.offersService.createOffer(req).getOffer();
+ PaymentAccount audAccount = createDummyF2FAccount(aliceClient, "AU");
+ var newOffer = aliceClient.createFixedPricedOffer("buy",
+ "aud",
+ 10000000L,
+ 10000000L,
+ "36000",
+ getDefaultBuyerSecurityDepositAsPercent(),
+ audAccount.getId(),
+ MAKER_FEE_CURRENCY_CODE);
String newOfferId = newOffer.getId();
assertNotEquals("", newOfferId);
assertEquals("BUY", newOffer.getDirection());
@@ -72,7 +64,7 @@ public void testCreateAUDBTCBuyOfferUsingFixedPrice16000() {
assertEquals("AUD", newOffer.getCounterCurrencyCode());
assertFalse(newOffer.getIsCurrencyForMakerFeeBtc());
- newOffer = getMyOffer(newOfferId);
+ newOffer = aliceClient.getMyOffer(newOfferId);
assertEquals(newOfferId, newOffer.getId());
assertEquals("BUY", newOffer.getDirection());
assertFalse(newOffer.getUseMarketBasedPrice());
@@ -89,20 +81,15 @@ public void testCreateAUDBTCBuyOfferUsingFixedPrice16000() {
@Test
@Order(2)
public void testCreateUSDBTCBuyOfferUsingFixedPrice100001234() {
- PaymentAccount usdAccount = createDummyF2FAccount(alicedaemon, "US");
- var req = CreateOfferRequest.newBuilder()
- .setPaymentAccountId(usdAccount.getId())
- .setDirection("buy")
- .setCurrencyCode("usd")
- .setAmount(10000000)
- .setMinAmount(10000000)
- .setUseMarketBasedPrice(false)
- .setMarketPriceMargin(0.00)
- .setPrice("30000.1234")
- .setBuyerSecurityDeposit(getDefaultBuyerSecurityDepositAsPercent())
- .setMakerFeeCurrencyCode(MAKER_FEE_CURRENCY_CODE)
- .build();
- var newOffer = aliceStubs.offersService.createOffer(req).getOffer();
+ PaymentAccount usdAccount = createDummyF2FAccount(aliceClient, "US");
+ var newOffer = aliceClient.createFixedPricedOffer("buy",
+ "usd",
+ 10000000L,
+ 10000000L,
+ "30000.1234",
+ getDefaultBuyerSecurityDepositAsPercent(),
+ usdAccount.getId(),
+ MAKER_FEE_CURRENCY_CODE);
String newOfferId = newOffer.getId();
assertNotEquals("", newOfferId);
assertEquals("BUY", newOffer.getDirection());
@@ -116,7 +103,7 @@ public void testCreateUSDBTCBuyOfferUsingFixedPrice100001234() {
assertEquals("USD", newOffer.getCounterCurrencyCode());
assertFalse(newOffer.getIsCurrencyForMakerFeeBtc());
- newOffer = getMyOffer(newOfferId);
+ newOffer = aliceClient.getMyOffer(newOfferId);
assertEquals(newOfferId, newOffer.getId());
assertEquals("BUY", newOffer.getDirection());
assertFalse(newOffer.getUseMarketBasedPrice());
@@ -133,20 +120,15 @@ public void testCreateUSDBTCBuyOfferUsingFixedPrice100001234() {
@Test
@Order(3)
public void testCreateEURBTCSellOfferUsingFixedPrice95001234() {
- PaymentAccount eurAccount = createDummyF2FAccount(alicedaemon, "FR");
- var req = CreateOfferRequest.newBuilder()
- .setPaymentAccountId(eurAccount.getId())
- .setDirection("sell")
- .setCurrencyCode("eur")
- .setAmount(10000000)
- .setMinAmount(10000000)
- .setUseMarketBasedPrice(false)
- .setMarketPriceMargin(0.00)
- .setPrice("29500.1234")
- .setBuyerSecurityDeposit(getDefaultBuyerSecurityDepositAsPercent())
- .setMakerFeeCurrencyCode(MAKER_FEE_CURRENCY_CODE)
- .build();
- var newOffer = aliceStubs.offersService.createOffer(req).getOffer();
+ PaymentAccount eurAccount = createDummyF2FAccount(aliceClient, "FR");
+ var newOffer = aliceClient.createFixedPricedOffer("sell",
+ "eur",
+ 10000000L,
+ 10000000L,
+ "29500.1234",
+ getDefaultBuyerSecurityDepositAsPercent(),
+ eurAccount.getId(),
+ MAKER_FEE_CURRENCY_CODE);
String newOfferId = newOffer.getId();
assertNotEquals("", newOfferId);
assertEquals("SELL", newOffer.getDirection());
@@ -160,7 +142,7 @@ public void testCreateEURBTCSellOfferUsingFixedPrice95001234() {
assertEquals("EUR", newOffer.getCounterCurrencyCode());
assertFalse(newOffer.getIsCurrencyForMakerFeeBtc());
- newOffer = getMyOffer(newOfferId);
+ newOffer = aliceClient.getMyOffer(newOfferId);
assertEquals(newOfferId, newOffer.getId());
assertEquals("SELL", newOffer.getDirection());
assertFalse(newOffer.getUseMarketBasedPrice());
diff --git a/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingMarketPriceMarginTest.java b/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingMarketPriceMarginTest.java
index 30dfaca4ac3..4dad4152e12 100644
--- a/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingMarketPriceMarginTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/offer/CreateOfferUsingMarketPriceMarginTest.java
@@ -19,7 +19,6 @@
import bisq.core.payment.PaymentAccount;
-import bisq.proto.grpc.CreateOfferRequest;
import bisq.proto.grpc.OfferInfo;
import java.text.DecimalFormat;
@@ -32,7 +31,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
-import static bisq.apitest.config.BisqAppConfig.alicedaemon;
import static bisq.common.util.MathUtils.scaleDownByPowerOf10;
import static bisq.common.util.MathUtils.scaleUpByPowerOf10;
import static bisq.core.btc.wallet.Restrictions.getDefaultBuyerSecurityDepositAsPercent;
@@ -57,21 +55,16 @@ public class CreateOfferUsingMarketPriceMarginTest extends AbstractOfferTest {
@Test
@Order(1)
public void testCreateUSDBTCBuyOffer5PctPriceMargin() {
- PaymentAccount usdAccount = createDummyF2FAccount(alicedaemon, "US");
+ PaymentAccount usdAccount = createDummyF2FAccount(aliceClient, "US");
double priceMarginPctInput = 5.00;
- var req = CreateOfferRequest.newBuilder()
- .setPaymentAccountId(usdAccount.getId())
- .setDirection("buy")
- .setCurrencyCode("usd")
- .setAmount(10000000)
- .setMinAmount(10000000)
- .setUseMarketBasedPrice(true)
- .setMarketPriceMargin(priceMarginPctInput)
- .setPrice("0")
- .setBuyerSecurityDeposit(getDefaultBuyerSecurityDepositAsPercent())
- .setMakerFeeCurrencyCode(MAKER_FEE_CURRENCY_CODE)
- .build();
- var newOffer = aliceStubs.offersService.createOffer(req).getOffer();
+ var newOffer = aliceClient.createMarketBasedPricedOffer("buy",
+ "usd",
+ 10000000L,
+ 10000000L,
+ priceMarginPctInput,
+ getDefaultBuyerSecurityDepositAsPercent(),
+ usdAccount.getId(),
+ MAKER_FEE_CURRENCY_CODE);
String newOfferId = newOffer.getId();
assertNotEquals("", newOfferId);
assertEquals("BUY", newOffer.getDirection());
@@ -84,7 +77,7 @@ public void testCreateUSDBTCBuyOffer5PctPriceMargin() {
assertEquals("USD", newOffer.getCounterCurrencyCode());
assertTrue(newOffer.getIsCurrencyForMakerFeeBtc());
- newOffer = getMyOffer(newOfferId);
+ newOffer = aliceClient.getMyOffer(newOfferId);
assertEquals(newOfferId, newOffer.getId());
assertEquals("BUY", newOffer.getDirection());
assertTrue(newOffer.getUseMarketBasedPrice());
@@ -102,8 +95,9 @@ public void testCreateUSDBTCBuyOffer5PctPriceMargin() {
@Test
@Order(2)
public void testCreateNZDBTCBuyOfferMinus2PctPriceMargin() {
- PaymentAccount nzdAccount = createDummyF2FAccount(alicedaemon, "NZ");
+ PaymentAccount nzdAccount = createDummyF2FAccount(aliceClient, "NZ");
double priceMarginPctInput = -2.00;
+ /*
var req = CreateOfferRequest.newBuilder()
.setPaymentAccountId(nzdAccount.getId())
.setDirection("buy")
@@ -117,6 +111,16 @@ public void testCreateNZDBTCBuyOfferMinus2PctPriceMargin() {
.setMakerFeeCurrencyCode(MAKER_FEE_CURRENCY_CODE)
.build();
var newOffer = aliceStubs.offersService.createOffer(req).getOffer();
+
+ */
+ var newOffer = aliceClient.createMarketBasedPricedOffer("buy",
+ "nzd",
+ 10000000L,
+ 10000000L,
+ priceMarginPctInput,
+ getDefaultBuyerSecurityDepositAsPercent(),
+ nzdAccount.getId(),
+ MAKER_FEE_CURRENCY_CODE);
String newOfferId = newOffer.getId();
assertNotEquals("", newOfferId);
assertEquals("BUY", newOffer.getDirection());
@@ -129,7 +133,7 @@ public void testCreateNZDBTCBuyOfferMinus2PctPriceMargin() {
assertEquals("NZD", newOffer.getCounterCurrencyCode());
assertTrue(newOffer.getIsCurrencyForMakerFeeBtc());
- newOffer = getMyOffer(newOfferId);
+ newOffer = aliceClient.getMyOffer(newOfferId);
assertEquals(newOfferId, newOffer.getId());
assertEquals("BUY", newOffer.getDirection());
assertTrue(newOffer.getUseMarketBasedPrice());
@@ -147,22 +151,16 @@ public void testCreateNZDBTCBuyOfferMinus2PctPriceMargin() {
@Test
@Order(3)
public void testCreateGBPBTCSellOfferMinus1Point5PctPriceMargin() {
- PaymentAccount gbpAccount = createDummyF2FAccount(alicedaemon, "GB");
+ PaymentAccount gbpAccount = createDummyF2FAccount(aliceClient, "GB");
double priceMarginPctInput = -1.5;
- var req = CreateOfferRequest.newBuilder()
- .setPaymentAccountId(gbpAccount.getId())
- .setDirection("sell")
- .setCurrencyCode("gbp")
- .setAmount(10000000)
- .setMinAmount(10000000)
- .setUseMarketBasedPrice(true)
- .setMarketPriceMargin(priceMarginPctInput)
- .setPrice("0")
- .setBuyerSecurityDeposit(getDefaultBuyerSecurityDepositAsPercent())
- .setMakerFeeCurrencyCode(MAKER_FEE_CURRENCY_CODE)
- .build();
- var newOffer = aliceStubs.offersService.createOffer(req).getOffer();
-
+ var newOffer = aliceClient.createMarketBasedPricedOffer("sell",
+ "gbp",
+ 10000000L,
+ 10000000L,
+ priceMarginPctInput,
+ getDefaultBuyerSecurityDepositAsPercent(),
+ gbpAccount.getId(),
+ MAKER_FEE_CURRENCY_CODE);
String newOfferId = newOffer.getId();
assertNotEquals("", newOfferId);
assertEquals("SELL", newOffer.getDirection());
@@ -175,7 +173,7 @@ public void testCreateGBPBTCSellOfferMinus1Point5PctPriceMargin() {
assertEquals("GBP", newOffer.getCounterCurrencyCode());
assertTrue(newOffer.getIsCurrencyForMakerFeeBtc());
- newOffer = getMyOffer(newOfferId);
+ newOffer = aliceClient.getMyOffer(newOfferId);
assertEquals(newOfferId, newOffer.getId());
assertEquals("SELL", newOffer.getDirection());
assertTrue(newOffer.getUseMarketBasedPrice());
@@ -193,22 +191,16 @@ public void testCreateGBPBTCSellOfferMinus1Point5PctPriceMargin() {
@Test
@Order(4)
public void testCreateBRLBTCSellOffer6Point55PctPriceMargin() {
- PaymentAccount brlAccount = createDummyF2FAccount(alicedaemon, "BR");
+ PaymentAccount brlAccount = createDummyF2FAccount(aliceClient, "BR");
double priceMarginPctInput = 6.55;
- var req = CreateOfferRequest.newBuilder()
- .setPaymentAccountId(brlAccount.getId())
- .setDirection("sell")
- .setCurrencyCode("brl")
- .setAmount(10000000)
- .setMinAmount(10000000)
- .setUseMarketBasedPrice(true)
- .setMarketPriceMargin(priceMarginPctInput)
- .setPrice("0")
- .setBuyerSecurityDeposit(getDefaultBuyerSecurityDepositAsPercent())
- .setMakerFeeCurrencyCode(MAKER_FEE_CURRENCY_CODE)
- .build();
- var newOffer = aliceStubs.offersService.createOffer(req).getOffer();
-
+ var newOffer = aliceClient.createMarketBasedPricedOffer("sell",
+ "brl",
+ 10000000L,
+ 10000000L,
+ priceMarginPctInput,
+ getDefaultBuyerSecurityDepositAsPercent(),
+ brlAccount.getId(),
+ MAKER_FEE_CURRENCY_CODE);
String newOfferId = newOffer.getId();
assertNotEquals("", newOfferId);
assertEquals("SELL", newOffer.getDirection());
@@ -221,7 +213,7 @@ public void testCreateBRLBTCSellOffer6Point55PctPriceMargin() {
assertEquals("BRL", newOffer.getCounterCurrencyCode());
assertTrue(newOffer.getIsCurrencyForMakerFeeBtc());
- newOffer = getMyOffer(newOfferId);
+ newOffer = aliceClient.getMyOffer(newOfferId);
assertEquals(newOfferId, newOffer.getId());
assertEquals("SELL", newOffer.getDirection());
assertTrue(newOffer.getUseMarketBasedPrice());
@@ -239,7 +231,7 @@ public void testCreateBRLBTCSellOffer6Point55PctPriceMargin() {
private void assertCalculatedPriceIsCorrect(OfferInfo offer, double priceMarginPctInput) {
assertTrue(() -> {
String counterCurrencyCode = offer.getCounterCurrencyCode();
- double mktPrice = getMarketPrice(counterCurrencyCode);
+ double mktPrice = aliceClient.getBtcPrice(counterCurrencyCode);
double scaledOfferPrice = getScaledOfferPrice(offer.getPrice(), counterCurrencyCode);
double expectedDiffPct = scaleDownByPowerOf10(priceMarginPctInput, 2);
double actualDiffPct = offer.getDirection().equals(BUY.name())
diff --git a/apitest/src/test/java/bisq/apitest/method/offer/ValidateCreateOfferTest.java b/apitest/src/test/java/bisq/apitest/method/offer/ValidateCreateOfferTest.java
index 14b935abe40..a979b7bf239 100644
--- a/apitest/src/test/java/bisq/apitest/method/offer/ValidateCreateOfferTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/offer/ValidateCreateOfferTest.java
@@ -19,8 +19,6 @@
import bisq.core.payment.PaymentAccount;
-import bisq.proto.grpc.CreateOfferRequest;
-
import io.grpc.StatusRuntimeException;
import lombok.extern.slf4j.Slf4j;
@@ -31,7 +29,6 @@
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
-import static bisq.apitest.config.BisqAppConfig.alicedaemon;
import static bisq.core.btc.wallet.Restrictions.getDefaultBuyerSecurityDepositAsPercent;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
@@ -44,22 +41,17 @@ public class ValidateCreateOfferTest extends AbstractOfferTest {
@Test
@Order(1)
public void testAmtTooLargeShouldThrowException() {
- PaymentAccount usdAccount = createDummyF2FAccount(alicedaemon, "US");
- var req = CreateOfferRequest.newBuilder()
- .setPaymentAccountId(usdAccount.getId())
- .setDirection("buy")
- .setCurrencyCode("usd")
- .setAmount(100000000000L)
- .setMinAmount(100000000000L)
- .setUseMarketBasedPrice(false)
- .setMarketPriceMargin(0.00)
- .setPrice("10000.0000")
- .setBuyerSecurityDeposit(getDefaultBuyerSecurityDepositAsPercent())
- .setMakerFeeCurrencyCode("bsq")
- .build();
+ PaymentAccount usdAccount = createDummyF2FAccount(aliceClient, "US");
@SuppressWarnings("ResultOfMethodCallIgnored")
Throwable exception = assertThrows(StatusRuntimeException.class, () ->
- aliceStubs.offersService.createOffer(req).getOffer());
+ aliceClient.createFixedPricedOffer("buy",
+ "usd",
+ 100000000000L, // exceeds amount limit
+ 100000000000L,
+ "10000.0000",
+ getDefaultBuyerSecurityDepositAsPercent(),
+ usdAccount.getId(),
+ "bsq"));
assertEquals("UNKNOWN: An error occurred at task: ValidateOffer",
exception.getMessage());
}
diff --git a/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java b/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java
index c31daec51d4..44c56f08a05 100644
--- a/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/payment/AbstractPaymentAccountTest.java
@@ -5,8 +5,6 @@
import bisq.core.locale.TradeCurrency;
import bisq.core.payment.PaymentAccount;
-import bisq.proto.grpc.GetPaymentAccountsRequest;
-
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.stream.JsonWriter;
@@ -29,7 +27,6 @@
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestInfo;
-import static bisq.apitest.config.BisqAppConfig.alicedaemon;
import static java.lang.String.format;
import static java.lang.System.getProperty;
import static java.nio.charset.StandardCharsets.UTF_8;
@@ -38,6 +35,7 @@
import bisq.apitest.method.MethodTest;
+import bisq.cli.GrpcClient;
@Slf4j
public class AbstractPaymentAccountTest extends MethodTest {
@@ -110,7 +108,7 @@ protected final File getEmptyForm(TestInfo testInfo, String paymentMethodId) {
// would be skipped.
COMPLETED_FORM_MAP.clear();
- File emptyForm = getPaymentAccountForm(alicedaemon, paymentMethodId);
+ File emptyForm = getPaymentAccountForm(aliceClient, paymentMethodId);
// A short cut over the API:
// File emptyForm = PAYMENT_ACCOUNT_FORM.getPaymentAccountForm(paymentMethodId);
log.debug("{} Empty form saved to {}",
@@ -153,11 +151,10 @@ protected final void verifyAccountTradeCurrencies(List expectedTr
assertArrayEquals(expectedTradeCurrencies.toArray(), paymentAccount.getTradeCurrencies().toArray());
}
- protected final void verifyUserPayloadHasPaymentAccountWithId(String paymentAccountId) {
- var getPaymentAccountsRequest = GetPaymentAccountsRequest.newBuilder().build();
- var reply = grpcStubs(alicedaemon)
- .paymentAccountsService.getPaymentAccounts(getPaymentAccountsRequest);
- Optional paymentAccount = reply.getPaymentAccountsList().stream()
+ protected final void verifyUserPayloadHasPaymentAccountWithId(GrpcClient grpcClient,
+ String paymentAccountId) {
+ Optional paymentAccount = grpcClient.getPaymentAccounts()
+ .stream()
.filter(a -> a.getId().equals(paymentAccountId))
.findFirst();
assertTrue(paymentAccount.isPresent());
diff --git a/apitest/src/test/java/bisq/apitest/method/payment/CreatePaymentAccountTest.java b/apitest/src/test/java/bisq/apitest/method/payment/CreatePaymentAccountTest.java
index fe9daf27df0..a194c4aa1f9 100644
--- a/apitest/src/test/java/bisq/apitest/method/payment/CreatePaymentAccountTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/payment/CreatePaymentAccountTest.java
@@ -99,8 +99,8 @@ public void testCreateAdvancedCashAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NR, "0000 1111 2222");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Advanced Cash Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- AdvancedCashAccount paymentAccount = (AdvancedCashAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ AdvancedCashAccount paymentAccount = (AdvancedCashAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllAdvancedCashCurrencies(), paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_ACCOUNT_NR), paymentAccount.getAccountNr());
@@ -119,8 +119,8 @@ public void testCreateAliPayAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NR, "2222 3333 4444");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- AliPayAccount paymentAccount = (AliPayAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ AliPayAccount paymentAccount = (AliPayAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("CNY", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_ACCOUNT_NR), paymentAccount.getAccountNr());
@@ -139,8 +139,8 @@ public void testCreateAustraliaPayidAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_BANK_ACCOUNT_NAME, "Credit Union Australia");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Australia Pay ID Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- AustraliaPayid paymentAccount = (AustraliaPayid) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ AustraliaPayid paymentAccount = (AustraliaPayid) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("AUD", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_PAY_ID), paymentAccount.getPayid());
@@ -180,8 +180,8 @@ public void testCreateCashDepositAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_REQUIREMENTS, "Requirements...");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- CashDepositAccount paymentAccount = (CashDepositAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ CashDepositAccount paymentAccount = (CashDepositAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("EUR", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_COUNTRY),
@@ -226,8 +226,8 @@ public void testCreateBrazilNationalBankAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_NATIONAL_ACCOUNT_ID, "123456789");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Banco do Brasil Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- NationalBankAccount paymentAccount = (NationalBankAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ NationalBankAccount paymentAccount = (NationalBankAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("BRL", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_COUNTRY),
@@ -259,8 +259,8 @@ public void testCreateChaseQuickPayAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_HOLDER_NAME, "John Doe");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- ChaseQuickPayAccount paymentAccount = (ChaseQuickPayAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ ChaseQuickPayAccount paymentAccount = (ChaseQuickPayAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("USD", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_EMAIL), paymentAccount.getEmail());
@@ -281,8 +281,8 @@ public void testCreateClearXChangeAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_HOLDER_NAME, "Jane Doe");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Zelle Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- ClearXchangeAccount paymentAccount = (ClearXchangeAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ ClearXchangeAccount paymentAccount = (ClearXchangeAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("USD", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_EMAIL_OR_MOBILE_NR), paymentAccount.getEmailOrMobileNr());
@@ -308,8 +308,8 @@ public void testCreateF2FAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_EXTRA_INFO, "So fim de semana");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- F2FAccount paymentAccount = (F2FAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ F2FAccount paymentAccount = (F2FAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("BRL", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_COUNTRY),
@@ -333,8 +333,8 @@ public void testCreateFasterPaymentsAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SORT_CODE, "3127");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Faster Payments Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- FasterPaymentsAccount paymentAccount = (FasterPaymentsAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ FasterPaymentsAccount paymentAccount = (FasterPaymentsAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("GBP", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_ACCOUNT_NR), paymentAccount.getAccountNr());
@@ -354,8 +354,8 @@ public void testCreateHalCashAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_MOBILE_NR, "798 123 456");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- HalCashAccount paymentAccount = (HalCashAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ HalCashAccount paymentAccount = (HalCashAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("EUR", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_MOBILE_NR), paymentAccount.getMobileNr());
@@ -379,8 +379,8 @@ public void testCreateInteracETransferAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ANSWER, "Fido");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Interac Transfer Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- InteracETransferAccount paymentAccount = (InteracETransferAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ InteracETransferAccount paymentAccount = (InteracETransferAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("CAD", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_HOLDER_NAME), paymentAccount.getHolderName());
@@ -414,8 +414,8 @@ public void testCreateJapanBankAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_BANK_ACCOUNT_NUMBER, "8100-8727-0000");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- JapanBankAccount paymentAccount = (JapanBankAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ JapanBankAccount paymentAccount = (JapanBankAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("JPY", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_BANK_CODE), paymentAccount.getBankCode());
@@ -439,8 +439,8 @@ public void testCreateMoneyBeamAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_ID, "MB 0000 1111");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Money Beam Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- MoneyBeamAccount paymentAccount = (MoneyBeamAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ MoneyBeamAccount paymentAccount = (MoneyBeamAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("EUR", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_ACCOUNT_ID), paymentAccount.getAccountId());
@@ -465,8 +465,8 @@ public void testCreateMoneyGramAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_STATE, "NY");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- MoneyGramAccount paymentAccount = (MoneyGramAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ MoneyGramAccount paymentAccount = (MoneyGramAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllMoneyGramCurrencies(), paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_HOLDER_NAME), paymentAccount.getFullName());
@@ -488,8 +488,8 @@ public void testCreatePerfectMoneyAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NR, "PM 0000 1111");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Perfect Money Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- PerfectMoneyAccount paymentAccount = (PerfectMoneyAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ PerfectMoneyAccount paymentAccount = (PerfectMoneyAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("USD", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_ACCOUNT_NR), paymentAccount.getAccountNr());
@@ -510,8 +510,8 @@ public void testCreatePopmoneyAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_HOLDER_NAME, "Jane Doe");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- PopmoneyAccount paymentAccount = (PopmoneyAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ PopmoneyAccount paymentAccount = (PopmoneyAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("USD", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_ACCOUNT_ID), paymentAccount.getAccountId());
@@ -530,8 +530,8 @@ public void testCreatePromptPayAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_PROMPT_PAY_ID, "PP 0000 1111");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Prompt Pay Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- PromptPayAccount paymentAccount = (PromptPayAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ PromptPayAccount paymentAccount = (PromptPayAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("THB", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_PROMPT_PAY_ID), paymentAccount.getPromptPayId());
@@ -550,8 +550,8 @@ public void testCreateRevolutAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_USERNAME, "revolut123");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- RevolutAccount paymentAccount = (RevolutAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ RevolutAccount paymentAccount = (RevolutAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllRevolutCurrencies(), paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_USERNAME), paymentAccount.getUserName());
@@ -583,8 +583,8 @@ public void testCreateSameBankAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_NATIONAL_ACCOUNT_ID, "123456789");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Same Bank Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- SameBankAccount paymentAccount = (SameBankAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ SameBankAccount paymentAccount = (SameBankAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("GBP", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_COUNTRY),
@@ -620,8 +620,8 @@ public void testCreateSepaInstantAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_BIC, "909");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- SepaInstantAccount paymentAccount = (SepaInstantAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ SepaInstantAccount paymentAccount = (SepaInstantAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_COUNTRY),
Objects.requireNonNull(paymentAccount.getCountry()).code);
verifyAccountSingleTradeCurrency("EUR", paymentAccount);
@@ -651,8 +651,8 @@ public void testCreateSepaAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_BIC, "909");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Conta Sepa Salt"));
String jsonString = getCompletedFormAsJsonString();
- SepaAccount paymentAccount = (SepaAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ SepaAccount paymentAccount = (SepaAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_COUNTRY),
Objects.requireNonNull(paymentAccount.getCountry()).code);
verifyAccountSingleTradeCurrency("EUR", paymentAccount);
@@ -694,8 +694,8 @@ public void testCreateSpecificBanksAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_NATIONAL_ACCOUNT_ID, "123456789");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- SpecificBanksAccount paymentAccount = (SpecificBanksAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ SpecificBanksAccount paymentAccount = (SpecificBanksAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("GBP", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_COUNTRY),
@@ -726,8 +726,8 @@ public void testCreateSwishAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_HOLDER_NAME, "Swish Acct Holder");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Swish Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- SwishAccount paymentAccount = (SwishAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ SwishAccount paymentAccount = (SwishAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("SEK", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_MOBILE_NR), paymentAccount.getMobileNr());
@@ -747,8 +747,8 @@ public void testCreateTransferwiseAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_EMAIL, "jan@doe.info");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- TransferwiseAccount paymentAccount = (TransferwiseAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ TransferwiseAccount paymentAccount = (TransferwiseAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
// As per commit 88f26f93241af698ae689bf081205d0f9dc929fa
// Do not autofill all currencies by default but keep all unselected.
// verifyAccountTradeCurrencies(getAllTransferwiseCurrencies(), paymentAccount);
@@ -769,8 +769,8 @@ public void testCreateUpholdAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_ID, "UA 9876");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored Uphold Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- UpholdAccount paymentAccount = (UpholdAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ UpholdAccount paymentAccount = (UpholdAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountTradeCurrencies(getAllUpholdCurrencies(), paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_ACCOUNT_ID), paymentAccount.getAccountId());
@@ -791,8 +791,8 @@ public void testCreateUSPostalMoneyOrderAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_POSTAL_ADDRESS, "000 Westwood Terrace Austin, TX 78700");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- USPostalMoneyOrderAccount paymentAccount = (USPostalMoneyOrderAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ USPostalMoneyOrderAccount paymentAccount = (USPostalMoneyOrderAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("USD", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_HOLDER_NAME), paymentAccount.getHolderName());
@@ -811,8 +811,8 @@ public void testCreateWeChatPayAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_ACCOUNT_NR, "WC 1234");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, encodeToHex("Restored WeChat Pay Acct Salt"));
String jsonString = getCompletedFormAsJsonString();
- WeChatPayAccount paymentAccount = (WeChatPayAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ WeChatPayAccount paymentAccount = (WeChatPayAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("CNY", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_ACCOUNT_NR), paymentAccount.getAccountNr());
@@ -839,8 +839,8 @@ public void testCreateWesternUnionAccount(TestInfo testInfo) {
COMPLETED_FORM_MAP.put(PROPERTY_NAME_EMAIL, "jane@doe.info");
COMPLETED_FORM_MAP.put(PROPERTY_NAME_SALT, "");
String jsonString = getCompletedFormAsJsonString();
- WesternUnionAccount paymentAccount = (WesternUnionAccount) createPaymentAccount(alicedaemon, jsonString);
- verifyUserPayloadHasPaymentAccountWithId(paymentAccount.getId());
+ WesternUnionAccount paymentAccount = (WesternUnionAccount) createPaymentAccount(aliceClient, jsonString);
+ verifyUserPayloadHasPaymentAccountWithId(aliceClient, paymentAccount.getId());
verifyAccountSingleTradeCurrency("USD", paymentAccount);
verifyCommonFormEntries(paymentAccount);
assertEquals(COMPLETED_FORM_MAP.get(PROPERTY_NAME_HOLDER_NAME), paymentAccount.getFullName());
diff --git a/apitest/src/test/java/bisq/apitest/method/payment/GetPaymentMethodsTest.java b/apitest/src/test/java/bisq/apitest/method/payment/GetPaymentMethodsTest.java
index ca4c8a8e500..6b0aae999b9 100644
--- a/apitest/src/test/java/bisq/apitest/method/payment/GetPaymentMethodsTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/payment/GetPaymentMethodsTest.java
@@ -41,7 +41,7 @@ public static void setUp() {
@Test
@Order(1)
public void testGetPaymentMethods() {
- List paymentMethodIds = getPaymentMethods(alicedaemon)
+ List paymentMethodIds = aliceClient.getPaymentMethods()
.stream()
.map(PaymentMethod::getId)
.collect(Collectors.toList());
diff --git a/apitest/src/test/java/bisq/apitest/method/trade/AbstractTradeTest.java b/apitest/src/test/java/bisq/apitest/method/trade/AbstractTradeTest.java
index 7f4038a0344..24e40d313c5 100644
--- a/apitest/src/test/java/bisq/apitest/method/trade/AbstractTradeTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/trade/AbstractTradeTest.java
@@ -30,22 +30,14 @@ public static void initStaticFixtures() {
protected final TradeInfo takeAlicesOffer(String offerId,
String paymentAccountId,
String takerFeeCurrencyCode) {
- return bobStubs.tradesService.takeOffer(
- createTakeOfferRequest(offerId,
- paymentAccountId,
- takerFeeCurrencyCode))
- .getTrade();
+ return bobClient.takeOffer(offerId, paymentAccountId, takerFeeCurrencyCode);
}
@SuppressWarnings("unused")
protected final TradeInfo takeBobsOffer(String offerId,
String paymentAccountId,
String takerFeeCurrencyCode) {
- return aliceStubs.tradesService.takeOffer(
- createTakeOfferRequest(offerId,
- paymentAccountId,
- takerFeeCurrencyCode))
- .getTrade();
+ return aliceClient.takeOffer(offerId, paymentAccountId, takerFeeCurrencyCode);
}
protected final void verifyExpectedProtocolStatus(TradeInfo trade) {
diff --git a/apitest/src/test/java/bisq/apitest/method/trade/TakeBuyBTCOfferTest.java b/apitest/src/test/java/bisq/apitest/method/trade/TakeBuyBTCOfferTest.java
index 5eeba3d788b..018e22e1836 100644
--- a/apitest/src/test/java/bisq/apitest/method/trade/TakeBuyBTCOfferTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/trade/TakeBuyBTCOfferTest.java
@@ -32,9 +32,8 @@
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestMethodOrder;
-import static bisq.apitest.config.BisqAppConfig.alicedaemon;
-import static bisq.apitest.config.BisqAppConfig.bobdaemon;
import static bisq.cli.CurrencyFormat.formatSatoshis;
+import static bisq.core.btc.wallet.Restrictions.getDefaultBuyerSecurityDepositAsPercent;
import static bisq.core.trade.Trade.Phase.DEPOSIT_CONFIRMED;
import static bisq.core.trade.Trade.Phase.DEPOSIT_PUBLISHED;
import static bisq.core.trade.Trade.Phase.FIAT_SENT;
@@ -61,11 +60,14 @@ public class TakeBuyBTCOfferTest extends AbstractTradeTest {
@Order(1)
public void testTakeAlicesBuyOffer(final TestInfo testInfo) {
try {
- PaymentAccount alicesUsdAccount = createDummyF2FAccount(alicedaemon, "US");
- var alicesOffer = createAliceOffer(alicesUsdAccount,
- "buy",
+ PaymentAccount alicesUsdAccount = createDummyF2FAccount(aliceClient, "US");
+ var alicesOffer = aliceClient.createMarketBasedPricedOffer("buy",
"usd",
12500000,
+ 12500000, // min-amount = amount
+ 0.00,
+ getDefaultBuyerSecurityDepositAsPercent(),
+ alicesUsdAccount.getId(),
TRADE_FEE_CURRENCY_CODE);
var offerId = alicesOffer.getId();
assertFalse(alicesOffer.getIsCurrencyForMakerFeeBtc());
@@ -73,10 +75,10 @@ public void testTakeAlicesBuyOffer(final TestInfo testInfo) {
// Wait for Alice's AddToOfferBook task.
// Wait times vary; my logs show >= 2 second delay.
sleep(3000); // TODO loop instead of hard code wait time
- var alicesUsdOffers = getMyOffersSortedByDate(aliceStubs, "buy", "usd");
+ var alicesUsdOffers = aliceClient.getMyOffersSortedByDate("buy", "usd");
assertEquals(1, alicesUsdOffers.size());
- PaymentAccount bobsUsdAccount = createDummyF2FAccount(bobdaemon, "US");
+ PaymentAccount bobsUsdAccount = createDummyF2FAccount(bobClient, "US");
var trade = takeAlicesOffer(offerId, bobsUsdAccount.getId(), TRADE_FEE_CURRENCY_CODE);
assertNotNull(trade);
assertEquals(offerId, trade.getTradeId());
@@ -85,10 +87,10 @@ public void testTakeAlicesBuyOffer(final TestInfo testInfo) {
tradeId = trade.getTradeId();
genBtcBlocksThenWait(1, 1000);
- alicesUsdOffers = getMyOffersSortedByDate(aliceStubs, "buy", "usd");
+ alicesUsdOffers = aliceClient.getMyOffersSortedByDate("buy", "usd");
assertEquals(0, alicesUsdOffers.size());
- trade = getTrade(bobdaemon, trade.getTradeId());
+ trade = bobClient.getTrade(trade.getTradeId());
EXPECTED_PROTOCOL_STATUS.setState(SELLER_PUBLISHED_DEPOSIT_TX)
.setPhase(DEPOSIT_PUBLISHED)
.setDepositPublished(true);
@@ -96,7 +98,7 @@ public void testTakeAlicesBuyOffer(final TestInfo testInfo) {
logTrade(log, testInfo, "Bob's view after taking offer and sending deposit", trade);
genBtcBlocksThenWait(1, 1000);
- trade = getTrade(bobdaemon, trade.getTradeId());
+ trade = bobClient.getTrade(trade.getTradeId());
EXPECTED_PROTOCOL_STATUS.setState(DEPOSIT_CONFIRMED_IN_BLOCK_CHAIN)
.setPhase(DEPOSIT_CONFIRMED)
.setDepositConfirmed(true);
@@ -111,11 +113,11 @@ public void testTakeAlicesBuyOffer(final TestInfo testInfo) {
@Order(2)
public void testAlicesConfirmPaymentStarted(final TestInfo testInfo) {
try {
- var trade = getTrade(alicedaemon, tradeId);
- confirmPaymentStarted(alicedaemon, trade.getTradeId());
+ var trade = aliceClient.getTrade(tradeId);
+ aliceClient.confirmPaymentStarted(trade.getTradeId());
sleep(3000);
- trade = getTrade(alicedaemon, tradeId);
+ trade = aliceClient.getTrade(tradeId);
assertEquals(OFFER_FEE_PAID.name(), trade.getOffer().getState());
EXPECTED_PROTOCOL_STATUS.setState(BUYER_SAW_ARRIVED_FIAT_PAYMENT_INITIATED_MSG)
.setPhase(FIAT_SENT)
@@ -130,11 +132,11 @@ public void testAlicesConfirmPaymentStarted(final TestInfo testInfo) {
@Test
@Order(3)
public void testBobsConfirmPaymentReceived(final TestInfo testInfo) {
- var trade = getTrade(bobdaemon, tradeId);
- confirmPaymentReceived(bobdaemon, trade.getTradeId());
+ var trade = bobClient.getTrade(tradeId);
+ bobClient.confirmPaymentReceived(trade.getTradeId());
sleep(3000);
- trade = getTrade(bobdaemon, tradeId);
+ trade = bobClient.getTrade(tradeId);
// Note: offer.state == available
assertEquals(AVAILABLE.name(), trade.getOffer().getState());
EXPECTED_PROTOCOL_STATUS.setState(SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG)
@@ -150,19 +152,19 @@ public void testBobsConfirmPaymentReceived(final TestInfo testInfo) {
public void testAlicesKeepFunds(final TestInfo testInfo) {
genBtcBlocksThenWait(1, 1000);
- var trade = getTrade(alicedaemon, tradeId);
+ var trade = aliceClient.getTrade(tradeId);
logTrade(log, testInfo, "Alice's view before keeping funds", trade);
- keepFunds(alicedaemon, tradeId);
+ aliceClient.keepFunds(tradeId);
genBtcBlocksThenWait(1, 1000);
- trade = getTrade(alicedaemon, tradeId);
+ trade = aliceClient.getTrade(tradeId);
EXPECTED_PROTOCOL_STATUS.setState(BUYER_RECEIVED_PAYOUT_TX_PUBLISHED_MSG)
.setPhase(PAYOUT_PUBLISHED);
verifyExpectedProtocolStatus(trade);
logTrade(log, testInfo, "Alice's view after keeping funds", trade);
- BtcBalanceInfo currentBalance = getBtcBalances(bobdaemon);
+ BtcBalanceInfo currentBalance = aliceClient.getBtcBalances();
log.debug("{} Alice's current available balance: {} BTC",
testName(testInfo),
formatSatoshis(currentBalance.getAvailableBalance()));
diff --git a/apitest/src/test/java/bisq/apitest/method/trade/TakeSellBTCOfferTest.java b/apitest/src/test/java/bisq/apitest/method/trade/TakeSellBTCOfferTest.java
index 02d7ff8f43c..247443918ae 100644
--- a/apitest/src/test/java/bisq/apitest/method/trade/TakeSellBTCOfferTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/trade/TakeSellBTCOfferTest.java
@@ -32,9 +32,8 @@
import org.junit.jupiter.api.TestInfo;
import org.junit.jupiter.api.TestMethodOrder;
-import static bisq.apitest.config.BisqAppConfig.alicedaemon;
-import static bisq.apitest.config.BisqAppConfig.bobdaemon;
import static bisq.cli.CurrencyFormat.formatSatoshis;
+import static bisq.core.btc.wallet.Restrictions.getDefaultBuyerSecurityDepositAsPercent;
import static bisq.core.trade.Trade.Phase.*;
import static bisq.core.trade.Trade.State.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
@@ -60,11 +59,14 @@ public class TakeSellBTCOfferTest extends AbstractTradeTest {
@Order(1)
public void testTakeAlicesSellOffer(final TestInfo testInfo) {
try {
- PaymentAccount alicesUsdAccount = createDummyF2FAccount(alicedaemon, "US");
- var alicesOffer = createAliceOffer(alicesUsdAccount,
- "sell",
+ PaymentAccount alicesUsdAccount = createDummyF2FAccount(aliceClient, "US");
+ var alicesOffer = aliceClient.createMarketBasedPricedOffer("sell",
"usd",
- 12500000,
+ 12500000L,
+ 12500000L, // min-amount = amount
+ 0.00,
+ getDefaultBuyerSecurityDepositAsPercent(),
+ alicesUsdAccount.getId(),
TRADE_FEE_CURRENCY_CODE);
var offerId = alicesOffer.getId();
assertTrue(alicesOffer.getIsCurrencyForMakerFeeBtc());
@@ -73,10 +75,10 @@ public void testTakeAlicesSellOffer(final TestInfo testInfo) {
// Wait times vary; my logs show >= 2 second delay, but taking sell offers
// seems to require more time to prepare.
sleep(3000); // TODO loop instead of hard code wait time
- var alicesUsdOffers = getMyOffersSortedByDate(aliceStubs, "sell", "usd");
+ var alicesUsdOffers = aliceClient.getMyOffersSortedByDate("sell", "usd");
assertEquals(1, alicesUsdOffers.size());
- PaymentAccount bobsUsdAccount = createDummyF2FAccount(bobdaemon, "US");
+ PaymentAccount bobsUsdAccount = createDummyF2FAccount(bobClient, "US");
var trade = takeAlicesOffer(offerId, bobsUsdAccount.getId(), TRADE_FEE_CURRENCY_CODE);
assertNotNull(trade);
assertEquals(offerId, trade.getTradeId());
@@ -85,10 +87,10 @@ public void testTakeAlicesSellOffer(final TestInfo testInfo) {
tradeId = trade.getTradeId();
genBtcBlocksThenWait(1, 4000);
- var takeableUsdOffers = getOffersSortedByDate(bobStubs, "sell", "usd");
+ var takeableUsdOffers = bobClient.getOffersSortedByDate("sell", "usd");
assertEquals(0, takeableUsdOffers.size());
- trade = getTrade(bobdaemon, trade.getTradeId());
+ trade = bobClient.getTrade(trade.getTradeId());
EXPECTED_PROTOCOL_STATUS.setState(BUYER_RECEIVED_DEPOSIT_TX_PUBLISHED_MSG)
.setPhase(DEPOSIT_PUBLISHED)
.setDepositPublished(true);
@@ -97,7 +99,7 @@ public void testTakeAlicesSellOffer(final TestInfo testInfo) {
logTrade(log, testInfo, "Bob's view after taking offer and sending deposit", trade);
genBtcBlocksThenWait(1, 1000);
- trade = getTrade(bobdaemon, trade.getTradeId());
+ trade = bobClient.getTrade(trade.getTradeId());
EXPECTED_PROTOCOL_STATUS.setState(DEPOSIT_CONFIRMED_IN_BLOCK_CHAIN)
.setPhase(DEPOSIT_CONFIRMED)
.setDepositConfirmed(true);
@@ -112,11 +114,11 @@ public void testTakeAlicesSellOffer(final TestInfo testInfo) {
@Order(2)
public void testBobsConfirmPaymentStarted(final TestInfo testInfo) {
try {
- var trade = getTrade(bobdaemon, tradeId);
- confirmPaymentStarted(bobdaemon, trade.getTradeId());
+ var trade = bobClient.getTrade(tradeId);
+ bobClient.confirmPaymentStarted(tradeId);
sleep(3000);
- trade = getTrade(bobdaemon, tradeId);
+ trade = bobClient.getTrade(tradeId);
// Note: offer.state == available
assertEquals(AVAILABLE.name(), trade.getOffer().getState());
EXPECTED_PROTOCOL_STATUS.setState(BUYER_SAW_ARRIVED_FIAT_PAYMENT_INITIATED_MSG)
@@ -132,11 +134,11 @@ public void testBobsConfirmPaymentStarted(final TestInfo testInfo) {
@Test
@Order(3)
public void testAlicesConfirmPaymentReceived(final TestInfo testInfo) {
- var trade = getTrade(alicedaemon, tradeId);
- confirmPaymentReceived(alicedaemon, trade.getTradeId());
+ var trade = aliceClient.getTrade(tradeId);
+ aliceClient.confirmPaymentReceived(trade.getTradeId());
sleep(3000);
- trade = getTrade(alicedaemon, tradeId);
+ trade = aliceClient.getTrade(tradeId);
assertEquals(OFFER_FEE_PAID.name(), trade.getOffer().getState());
EXPECTED_PROTOCOL_STATUS.setState(SELLER_SAW_ARRIVED_PAYOUT_TX_PUBLISHED_MSG)
.setPhase(PAYOUT_PUBLISHED)
@@ -151,21 +153,21 @@ public void testAlicesConfirmPaymentReceived(final TestInfo testInfo) {
public void testBobsBtcWithdrawalToExternalAddress(final TestInfo testInfo) {
genBtcBlocksThenWait(1, 1000);
- var trade = getTrade(bobdaemon, tradeId);
+ var trade = bobClient.getTrade(tradeId);
logTrade(log, testInfo, "Bob's view before withdrawing funds to external wallet", trade);
String toAddress = bitcoinCli.getNewBtcAddress();
- withdrawFunds(bobdaemon, tradeId, toAddress, WITHDRAWAL_TX_MEMO);
+ bobClient.withdrawFunds(tradeId, toAddress, WITHDRAWAL_TX_MEMO);
genBtcBlocksThenWait(1, 1000);
- trade = getTrade(bobdaemon, tradeId);
+ trade = bobClient.getTrade(tradeId);
EXPECTED_PROTOCOL_STATUS.setState(WITHDRAW_COMPLETED)
.setPhase(WITHDRAWN)
.setWithdrawn(true);
verifyExpectedProtocolStatus(trade);
logTrade(log, testInfo, "Bob's view after withdrawing funds to external wallet", trade);
- BtcBalanceInfo currentBalance = getBtcBalances(bobdaemon);
+ BtcBalanceInfo currentBalance = bobClient.getBtcBalances();
log.debug("{} Bob's current available balance: {} BTC",
testName(testInfo),
formatSatoshis(currentBalance.getAvailableBalance()));
diff --git a/apitest/src/test/java/bisq/apitest/method/wallet/BsqWalletTest.java b/apitest/src/test/java/bisq/apitest/method/wallet/BsqWalletTest.java
index 04b7ee9fdc7..6be9dd66543 100644
--- a/apitest/src/test/java/bisq/apitest/method/wallet/BsqWalletTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/wallet/BsqWalletTest.java
@@ -37,6 +37,7 @@
import bisq.apitest.config.BisqAppConfig;
import bisq.apitest.method.MethodTest;
+import bisq.cli.GrpcClient;
@Disabled
@Slf4j
@@ -59,9 +60,7 @@ public static void setUp() {
@Test
@Order(1)
public void testGetUnusedBsqAddress() {
- var request = createGetUnusedBsqAddressRequest();
-
- String address = grpcStubs(alicedaemon).walletsService.getUnusedBsqAddress(request).getAddress();
+ var address = aliceClient.getUnusedBsqAddress();
assertFalse(address.isEmpty());
assertTrue(address.startsWith("B"));
@@ -76,13 +75,13 @@ public void testGetUnusedBsqAddress() {
@Test
@Order(2)
public void testInitialBsqBalances(final TestInfo testInfo) {
- BsqBalanceInfo alicesBsqBalances = getBsqBalances(alicedaemon);
+ BsqBalanceInfo alicesBsqBalances = aliceClient.getBsqBalances();
log.debug("{} -> Alice's BSQ Initial Balances -> \n{}",
testName(testInfo),
formatBsqBalanceInfoTbl(alicesBsqBalances));
verifyBsqBalances(ALICES_INITIAL_BSQ_BALANCES, alicesBsqBalances);
- BsqBalanceInfo bobsBsqBalances = getBsqBalances(bobdaemon);
+ BsqBalanceInfo bobsBsqBalances = bobClient.getBsqBalances();
log.debug("{} -> Bob's BSQ Initial Balances -> \n{}",
testName(testInfo),
formatBsqBalanceInfoTbl(bobsBsqBalances));
@@ -92,12 +91,12 @@ public void testInitialBsqBalances(final TestInfo testInfo) {
@Test
@Order(3)
public void testSendBsqAndCheckBalancesBeforeGeneratingBtcBlock(final TestInfo testInfo) {
- String bobsBsqAddress = getUnusedBsqAddress(bobdaemon);
- sendBsq(alicedaemon, bobsBsqAddress, SEND_BSQ_AMOUNT, "100");
+ String bobsBsqAddress = bobClient.getUnusedBsqAddress();
+ aliceClient.sendBsq(bobsBsqAddress, SEND_BSQ_AMOUNT, "100");
sleep(2000);
- BsqBalanceInfo alicesBsqBalances = getBsqBalances(alicedaemon);
- BsqBalanceInfo bobsBsqBalances = waitForNonZeroBsqUnverifiedBalance(bobdaemon);
+ BsqBalanceInfo alicesBsqBalances = aliceClient.getBsqBalances();
+ BsqBalanceInfo bobsBsqBalances = waitForNonZeroBsqUnverifiedBalance(bobClient);
log.debug("BSQ Balances Before BTC Block Gen...");
printBobAndAliceBsqBalances(testInfo,
@@ -129,8 +128,8 @@ public void testBalancesAfterSendingBsqAndGeneratingBtcBlock(final TestInfo test
// wait for both wallets to be saved to disk.
genBtcBlocksThenWait(1, 4000);
- BsqBalanceInfo alicesBsqBalances = getBsqBalances(alicedaemon);
- BsqBalanceInfo bobsBsqBalances = waitForBsqNewAvailableConfirmedBalance(bobdaemon, 150000000);
+ BsqBalanceInfo alicesBsqBalances = aliceClient.getBalances().getBsq();
+ BsqBalanceInfo bobsBsqBalances = waitForBsqNewAvailableConfirmedBalance(bobClient, 150000000);
log.debug("See Available Confirmed BSQ Balances...");
printBobAndAliceBsqBalances(testInfo,
@@ -160,26 +159,26 @@ public static void tearDown() {
tearDownScaffold();
}
- private BsqBalanceInfo waitForNonZeroBsqUnverifiedBalance(BisqAppConfig daemon) {
+ private BsqBalanceInfo waitForNonZeroBsqUnverifiedBalance(GrpcClient grpcClient) {
// A BSQ recipient needs to wait for her daemon to detect a new tx.
// Loop here until her unverifiedBalance != 0, or give up after 15 seconds.
// A slow test is preferred over a flaky test.
- BsqBalanceInfo bsqBalance = getBsqBalances(daemon);
+ BsqBalanceInfo bsqBalance = grpcClient.getBsqBalances();
for (int numRequests = 1; numRequests <= 15 && bsqBalance.getUnverifiedBalance() == 0; numRequests++) {
sleep(1000);
- bsqBalance = getBsqBalances(daemon);
+ bsqBalance = grpcClient.getBsqBalances();
}
return bsqBalance;
}
- private BsqBalanceInfo waitForBsqNewAvailableConfirmedBalance(BisqAppConfig daemon,
+ private BsqBalanceInfo waitForBsqNewAvailableConfirmedBalance(GrpcClient grpcClient,
long staleBalance) {
- BsqBalanceInfo bsqBalance = getBsqBalances(daemon);
+ BsqBalanceInfo bsqBalance = grpcClient.getBsqBalances();
for (int numRequests = 1;
numRequests <= 15 && bsqBalance.getAvailableConfirmedBalance() == staleBalance;
numRequests++) {
sleep(1000);
- bsqBalance = getBsqBalances(daemon);
+ bsqBalance = grpcClient.getBsqBalances();
}
return bsqBalance;
}
diff --git a/apitest/src/test/java/bisq/apitest/method/wallet/BtcTxFeeRateTest.java b/apitest/src/test/java/bisq/apitest/method/wallet/BtcTxFeeRateTest.java
index d5a4e4ef340..693ac0f07c5 100644
--- a/apitest/src/test/java/bisq/apitest/method/wallet/BtcTxFeeRateTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/wallet/BtcTxFeeRateTest.java
@@ -46,7 +46,7 @@ public static void setUp() {
@Test
@Order(1)
public void testGetTxFeeRate(final TestInfo testInfo) {
- TxFeeRateInfo txFeeRateInfo = getTxFeeRate(alicedaemon);
+ var txFeeRateInfo = TxFeeRateInfo.fromProto(aliceClient.getTxFeeRate());
log.debug("{} -> Fee rate with no preference: {}", testName(testInfo), txFeeRateInfo);
assertFalse(txFeeRateInfo.isUseCustomTxFeeRate());
@@ -57,7 +57,7 @@ public void testGetTxFeeRate(final TestInfo testInfo) {
@Order(2)
public void testSetInvalidTxFeeRateShouldThrowException(final TestInfo testInfo) {
Throwable exception = assertThrows(StatusRuntimeException.class, () ->
- setTxFeeRate(alicedaemon, 10));
+ aliceClient.setTxFeeRate(10));
String expectedExceptionMessage =
format("UNKNOWN: tx fee rate preference must be >= %d sats/byte",
BTC_DAO_REGTEST.getDefaultMinFeePerVbyte());
@@ -67,7 +67,7 @@ public void testSetInvalidTxFeeRateShouldThrowException(final TestInfo testInfo)
@Test
@Order(3)
public void testSetValidTxFeeRate(final TestInfo testInfo) {
- TxFeeRateInfo txFeeRateInfo = setTxFeeRate(alicedaemon, 15);
+ var txFeeRateInfo = TxFeeRateInfo.fromProto(aliceClient.setTxFeeRate(15));
log.debug("{} -> Fee rates with custom preference: {}", testName(testInfo), txFeeRateInfo);
assertTrue(txFeeRateInfo.isUseCustomTxFeeRate());
@@ -78,7 +78,7 @@ public void testSetValidTxFeeRate(final TestInfo testInfo) {
@Test
@Order(4)
public void testUnsetTxFeeRate(final TestInfo testInfo) {
- TxFeeRateInfo txFeeRateInfo = unsetTxFeeRate(alicedaemon);
+ var txFeeRateInfo = TxFeeRateInfo.fromProto(aliceClient.unsetTxFeeRate());
log.debug("{} -> Fee rate with no preference: {}", testName(testInfo), txFeeRateInfo);
assertFalse(txFeeRateInfo.isUseCustomTxFeeRate());
diff --git a/apitest/src/test/java/bisq/apitest/method/wallet/BtcWalletTest.java b/apitest/src/test/java/bisq/apitest/method/wallet/BtcWalletTest.java
index 33cd43e7c43..19d065c6cca 100644
--- a/apitest/src/test/java/bisq/apitest/method/wallet/BtcWalletTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/wallet/BtcWalletTest.java
@@ -53,10 +53,10 @@ public static void setUp() {
public void testInitialBtcBalances(final TestInfo testInfo) {
// Bob & Alice's regtest Bisq wallets were initialized with 10 BTC.
- BtcBalanceInfo alicesBalances = getBtcBalances(alicedaemon);
+ BtcBalanceInfo alicesBalances = aliceClient.getBtcBalances();
log.debug("{} Alice's BTC Balances:\n{}", testName(testInfo), formatBtcBalanceInfoTbl(alicesBalances));
- BtcBalanceInfo bobsBalances = getBtcBalances(bobdaemon);
+ BtcBalanceInfo bobsBalances = bobClient.getBtcBalances();
log.debug("{} Bob's BTC Balances:\n{}", testName(testInfo), formatBtcBalanceInfoTbl(bobsBalances));
assertEquals(INITIAL_BTC_BALANCES.getAvailableBalance(), alicesBalances.getAvailableBalance());
@@ -66,20 +66,20 @@ public void testInitialBtcBalances(final TestInfo testInfo) {
@Test
@Order(2)
public void testFundAlicesBtcWallet(final TestInfo testInfo) {
- String newAddress = getUnusedBtcAddress(alicedaemon);
+ String newAddress = aliceClient.getUnusedBtcAddress();
bitcoinCli.sendToAddress(newAddress, "2.5");
genBtcBlocksThenWait(1, 1000);
- BtcBalanceInfo btcBalanceInfo = getBtcBalances(alicedaemon);
+ BtcBalanceInfo btcBalanceInfo = aliceClient.getBtcBalances();
// New balance is 12.5 BTC
assertEquals(1250000000, btcBalanceInfo.getAvailableBalance());
log.debug("{} -> Alice's Funded Address Balance -> \n{}",
testName(testInfo),
- formatAddressBalanceTbl(singletonList(getAddressBalance(alicedaemon, newAddress))));
+ formatAddressBalanceTbl(singletonList(aliceClient.getAddressBalance(newAddress))));
// New balance is 12.5 BTC
- btcBalanceInfo = getBtcBalances(alicedaemon);
+ btcBalanceInfo = aliceClient.getBtcBalances();
bisq.core.api.model.BtcBalanceInfo alicesExpectedBalances =
bisq.core.api.model.BtcBalanceInfo.valueOf(1250000000,
0,
@@ -94,11 +94,10 @@ public void testFundAlicesBtcWallet(final TestInfo testInfo) {
@Test
@Order(3)
public void testAliceSendBTCToBob(TestInfo testInfo) {
- String bobsBtcAddress = getUnusedBtcAddress(bobdaemon);
+ String bobsBtcAddress = bobClient.getUnusedBtcAddress();
log.debug("Sending 5.5 BTC From Alice to Bob @ {}", bobsBtcAddress);
- TxInfo txInfo = sendBtc(alicedaemon,
- bobsBtcAddress,
+ TxInfo txInfo = aliceClient.sendBtc(bobsBtcAddress,
"5.50",
"100",
TX_MEMO);
@@ -109,11 +108,11 @@ public void testAliceSendBTCToBob(TestInfo testInfo) {
genBtcBlocksThenWait(1, 1000);
// Fetch the tx and check for confirmation and memo.
- txInfo = getTransaction(alicedaemon, txInfo.getTxId());
+ txInfo = aliceClient.getTransaction(txInfo.getTxId());
assertFalse(txInfo.getIsPending());
assertEquals(TX_MEMO, txInfo.getMemo());
- BtcBalanceInfo alicesBalances = getBtcBalances(alicedaemon);
+ BtcBalanceInfo alicesBalances = aliceClient.getBtcBalances();
log.debug("{} Alice's BTC Balances:\n{}",
testName(testInfo),
formatBtcBalanceInfoTbl(alicesBalances));
@@ -124,7 +123,7 @@ public void testAliceSendBTCToBob(TestInfo testInfo) {
0);
verifyBtcBalances(alicesExpectedBalances, alicesBalances);
- BtcBalanceInfo bobsBalances = getBtcBalances(bobdaemon);
+ BtcBalanceInfo bobsBalances = bobClient.getBtcBalances();
log.debug("{} Bob's BTC Balances:\n{}",
testName(testInfo),
formatBtcBalanceInfoTbl(bobsBalances));
diff --git a/apitest/src/test/java/bisq/apitest/method/wallet/WalletProtectionTest.java b/apitest/src/test/java/bisq/apitest/method/wallet/WalletProtectionTest.java
index f5dabd90593..30de7f585b8 100644
--- a/apitest/src/test/java/bisq/apitest/method/wallet/WalletProtectionTest.java
+++ b/apitest/src/test/java/bisq/apitest/method/wallet/WalletProtectionTest.java
@@ -41,94 +41,83 @@ public static void setUp() {
@Test
@Order(1)
public void testSetWalletPassword() {
- var request = createSetWalletPasswordRequest("first-password");
- grpcStubs(alicedaemon).walletsService.setWalletPassword(request);
+ aliceClient.setWalletPassword("first-password");
}
@Test
@Order(2)
public void testGetBalanceOnEncryptedWalletShouldThrowException() {
- Throwable exception = assertThrows(StatusRuntimeException.class, () -> getBtcBalances(alicedaemon));
+ Throwable exception = assertThrows(StatusRuntimeException.class, () -> aliceClient.getBtcBalances());
assertEquals("UNKNOWN: wallet is locked", exception.getMessage());
}
@Test
@Order(3)
public void testUnlockWalletFor4Seconds() {
- var request = createUnlockWalletRequest("first-password", 4);
- grpcStubs(alicedaemon).walletsService.unlockWallet(request);
- getBtcBalances(alicedaemon); // should not throw 'wallet locked' exception
+ aliceClient.unlockWallet("first-password", 4);
+ aliceClient.getBtcBalances(); // should not throw 'wallet locked' exception
sleep(4500); // let unlock timeout expire
- Throwable exception = assertThrows(StatusRuntimeException.class, () -> getBtcBalances(alicedaemon));
+ Throwable exception = assertThrows(StatusRuntimeException.class, () -> aliceClient.getBtcBalances());
assertEquals("UNKNOWN: wallet is locked", exception.getMessage());
}
@Test
@Order(4)
public void testGetBalanceAfterUnlockTimeExpiryShouldThrowException() {
- var request = createUnlockWalletRequest("first-password", 3);
- grpcStubs(alicedaemon).walletsService.unlockWallet(request);
+ aliceClient.unlockWallet("first-password", 3);
sleep(4000); // let unlock timeout expire
- Throwable exception = assertThrows(StatusRuntimeException.class, () -> getBtcBalances(alicedaemon));
+ Throwable exception = assertThrows(StatusRuntimeException.class, () -> aliceClient.getBtcBalances());
assertEquals("UNKNOWN: wallet is locked", exception.getMessage());
}
@Test
@Order(5)
public void testLockWalletBeforeUnlockTimeoutExpiry() {
- unlockWallet(alicedaemon, "first-password", 60);
- var request = createLockWalletRequest();
- grpcStubs(alicedaemon).walletsService.lockWallet(request);
- Throwable exception = assertThrows(StatusRuntimeException.class, () -> getBtcBalances(alicedaemon));
+ aliceClient.unlockWallet("first-password", 60);
+ aliceClient.lockWallet();
+ Throwable exception = assertThrows(StatusRuntimeException.class, () -> aliceClient.getBtcBalances());
assertEquals("UNKNOWN: wallet is locked", exception.getMessage());
}
@Test
@Order(6)
public void testLockWalletWhenWalletAlreadyLockedShouldThrowException() {
- var request = createLockWalletRequest();
- Throwable exception = assertThrows(StatusRuntimeException.class, () ->
- grpcStubs(alicedaemon).walletsService.lockWallet(request));
+ Throwable exception = assertThrows(StatusRuntimeException.class, () -> aliceClient.lockWallet());
assertEquals("UNKNOWN: wallet is already locked", exception.getMessage());
}
@Test
@Order(7)
public void testUnlockWalletTimeoutOverride() {
- unlockWallet(alicedaemon, "first-password", 2);
+ aliceClient.unlockWallet("first-password", 2);
sleep(500); // override unlock timeout after 0.5s
- unlockWallet(alicedaemon, "first-password", 6);
+ aliceClient.unlockWallet("first-password", 6);
sleep(5000);
- getBtcBalances(alicedaemon); // getbalance 5s after overriding timeout to 6s
+ aliceClient.getBtcBalances(); // getbalance 5s after overriding timeout to 6s
}
@Test
@Order(8)
public void testSetNewWalletPassword() {
- var request = createSetWalletPasswordRequest(
- "first-password", "second-password");
- grpcStubs(alicedaemon).walletsService.setWalletPassword(request);
- unlockWallet(alicedaemon, "second-password", 2);
- getBtcBalances(alicedaemon);
+ aliceClient.setWalletPassword("first-password", "second-password");
sleep(2500); // allow time for wallet save
+ aliceClient.unlockWallet("second-password", 2);
+ aliceClient.getBtcBalances();
}
@Test
@Order(9)
public void testSetNewWalletPasswordWithIncorrectNewPasswordShouldThrowException() {
- var request = createSetWalletPasswordRequest(
- "bad old password", "irrelevant");
Throwable exception = assertThrows(StatusRuntimeException.class, () ->
- grpcStubs(alicedaemon).walletsService.setWalletPassword(request));
+ aliceClient.setWalletPassword("bad old password", "irrelevant"));
assertEquals("UNKNOWN: incorrect old password", exception.getMessage());
}
@Test
@Order(10)
public void testRemoveNewWalletPassword() {
- var request = createRemoveWalletPasswordRequest("second-password");
- grpcStubs(alicedaemon).walletsService.removeWalletPassword(request);
- getBtcBalances(alicedaemon); // should not throw 'wallet locked' exception
+ aliceClient.removeWalletPassword("second-password");
+ aliceClient.getBtcBalances(); // should not throw 'wallet locked' exception
}
@AfterAll
diff --git a/apitest/src/test/java/bisq/apitest/scenario/PaymentAccountTest.java b/apitest/src/test/java/bisq/apitest/scenario/PaymentAccountTest.java
index 897e8bea3d0..e3ce0a0806b 100644
--- a/apitest/src/test/java/bisq/apitest/scenario/PaymentAccountTest.java
+++ b/apitest/src/test/java/bisq/apitest/scenario/PaymentAccountTest.java
@@ -13,6 +13,7 @@
import static bisq.apitest.Scaffold.BitcoinCoreApp.bitcoind;
import static bisq.apitest.config.BisqAppConfig.alicedaemon;
import static bisq.apitest.config.BisqAppConfig.seednode;
+import static java.util.Objects.requireNonNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.fail;
@@ -80,7 +81,8 @@ public void testCreatePaymentAccount(TestInfo testInfo) {
test.testCreateWeChatPayAccount(testInfo);
test.testCreateWesternUnionAccount(testInfo);
- assertEquals(EXPECTED_NUM_PAYMENT_ACCOUNTS, getPaymentAccounts(alicedaemon).size());
+ var paymentAccounts = requireNonNull(aliceClient).getPaymentAccounts();
+ assertEquals(EXPECTED_NUM_PAYMENT_ACCOUNTS, paymentAccounts.size());
}
@AfterAll
diff --git a/apitest/src/test/java/bisq/apitest/scenario/ScriptedBotTest.java b/apitest/src/test/java/bisq/apitest/scenario/ScriptedBotTest.java
index aa72cd27556..fd187638803 100644
--- a/apitest/src/test/java/bisq/apitest/scenario/ScriptedBotTest.java
+++ b/apitest/src/test/java/bisq/apitest/scenario/ScriptedBotTest.java
@@ -34,7 +34,6 @@
import static bisq.apitest.config.BisqAppConfig.bobdaemon;
import static bisq.apitest.config.BisqAppConfig.seednode;
import static bisq.apitest.scenario.bot.shutdown.ManualShutdown.startShutdownTimer;
-import static java.net.InetAddress.getLoopbackAddress;
import static org.junit.jupiter.api.Assertions.fail;
@@ -46,7 +45,6 @@
import bisq.apitest.scenario.bot.RobotBob;
import bisq.apitest.scenario.bot.script.BashScriptGenerator;
import bisq.apitest.scenario.bot.shutdown.ManualBotShutdownException;
-import bisq.cli.GrpcStubs;
// The test case is enabled if AbstractBotTest#botScriptExists() returns true.
@EnabledIf("botScriptExists")
@@ -75,13 +73,10 @@ public static void startTestHarness() {
// an offer can be taken.
config = new ApiTestConfig("--apiPassword", "xyz");
bitcoinCli = new BitcoinCliHelper(config);
- bobStubs = new GrpcStubs(getLoopbackAddress().getHostAddress(),
- bobdaemon.apiPort,
- config.apiPassword);
log.warn("Don't forget to register dispute agents before trying to trade with me.");
}
- botClient = new BotClient(bobStubs);
+ botClient = new BotClient(bobClient);
}
@BeforeEach
diff --git a/apitest/src/test/java/bisq/apitest/scenario/bot/AbstractBotTest.java b/apitest/src/test/java/bisq/apitest/scenario/bot/AbstractBotTest.java
index 2252bbf10be..763dbac9e2f 100644
--- a/apitest/src/test/java/bisq/apitest/scenario/bot/AbstractBotTest.java
+++ b/apitest/src/test/java/bisq/apitest/scenario/bot/AbstractBotTest.java
@@ -63,7 +63,7 @@ protected BashScriptGenerator getBashScriptGenerator() {
private PaymentAccount createAlicesPaymentAccount() {
BotPaymentAccountGenerator accountGenerator =
- new BotPaymentAccountGenerator(new BotClient(aliceStubs));
+ new BotPaymentAccountGenerator(new BotClient(aliceClient));
String paymentMethodId = botScript.getBotPaymentMethodId();
if (paymentMethodId != null) {
if (paymentMethodId.equals(CLEAR_X_CHANGE_ID)) {
diff --git a/apitest/src/test/java/bisq/apitest/scenario/bot/BotClient.java b/apitest/src/test/java/bisq/apitest/scenario/bot/BotClient.java
index 3428b409f52..c34dc14d28b 100644
--- a/apitest/src/test/java/bisq/apitest/scenario/bot/BotClient.java
+++ b/apitest/src/test/java/bisq/apitest/scenario/bot/BotClient.java
@@ -18,18 +18,8 @@
package bisq.apitest.scenario.bot;
import bisq.proto.grpc.BalancesInfo;
-import bisq.proto.grpc.ConfirmPaymentReceivedRequest;
-import bisq.proto.grpc.ConfirmPaymentStartedRequest;
-import bisq.proto.grpc.CreateOfferRequest;
-import bisq.proto.grpc.CreatePaymentAccountRequest;
-import bisq.proto.grpc.GetBalancesRequest;
-import bisq.proto.grpc.GetOffersRequest;
import bisq.proto.grpc.GetPaymentAccountsRequest;
-import bisq.proto.grpc.GetTradeRequest;
-import bisq.proto.grpc.KeepFundsRequest;
-import bisq.proto.grpc.MarketPriceRequest;
import bisq.proto.grpc.OfferInfo;
-import bisq.proto.grpc.TakeOfferRequest;
import bisq.proto.grpc.TradeInfo;
import protobuf.PaymentAccount;
@@ -45,13 +35,15 @@
-import bisq.cli.GrpcStubs;
+import bisq.cli.GrpcClient;
/**
- * Convenience for test bots making gRPC calls.
+ * Convenience GrpcClient wrapper for bots using gRPC services.
+ *
+ * TODO Consider if the duplication smell is bad enough to force a BotClient user
+ * to use the GrpcClient instead (and delete this class). But right now, I think it is
+ * OK because moving some of the non-gRPC related methods to GrpcClient is even smellier.
*
- * Although this duplicates code in the method package, I anticipate
- * this entire bot package will move to the cli subproject.
*/
@SuppressWarnings({"JavaDoc", "unused"})
@Slf4j
@@ -59,10 +51,10 @@ public class BotClient {
private static final DecimalFormat FIXED_PRICE_FMT = new DecimalFormat("###########0");
- private final GrpcStubs grpcStubs;
+ private final GrpcClient grpcClient;
- public BotClient(GrpcStubs grpcStubs) {
- this.grpcStubs = grpcStubs;
+ public BotClient(GrpcClient grpcClient) {
+ this.grpcClient = grpcClient;
}
/**
@@ -70,8 +62,7 @@ public BotClient(GrpcStubs grpcStubs) {
* @return BalancesInfo
*/
public BalancesInfo getBalance() {
- var req = GetBalancesRequest.newBuilder().build();
- return grpcStubs.walletsService.getBalances(req).getBalances();
+ return grpcClient.getBalances();
}
/**
@@ -80,8 +71,7 @@ public BalancesInfo getBalance() {
* @return double
*/
public double getCurrentBTCMarketPrice(String currencyCode) {
- var request = MarketPriceRequest.newBuilder().setCurrencyCode(currencyCode).build();
- return grpcStubs.priceService.getMarketPrice(request).getPrice();
+ return grpcClient.getBtcPrice(currencyCode);
}
/**
@@ -113,10 +103,7 @@ public List getOffers(String currencyCode) {
* @return List
*/
public List getBuyOffers(String currencyCode) {
- var buyOffersRequest = GetOffersRequest.newBuilder()
- .setCurrencyCode(currencyCode)
- .setDirection("BUY").build();
- return grpcStubs.offersService.getOffers(buyOffersRequest).getOffersList();
+ return grpcClient.getOffers("BUY", currencyCode);
}
/**
@@ -125,10 +112,7 @@ public List getBuyOffers(String currencyCode) {
* @return List
*/
public List getSellOffers(String currencyCode) {
- var buyOffersRequest = GetOffersRequest.newBuilder()
- .setCurrencyCode(currencyCode)
- .setDirection("SELL").build();
- return grpcStubs.offersService.getOffers(buyOffersRequest).getOffersList();
+ return grpcClient.getOffers("SELL", currencyCode);
}
/**
@@ -151,19 +135,14 @@ public OfferInfo createOfferAtMarketBasedPrice(PaymentAccount paymentAccount,
double priceMarginAsPercent,
double securityDepositAsPercent,
String feeCurrency) {
- var req = CreateOfferRequest.newBuilder()
- .setPaymentAccountId(paymentAccount.getId())
- .setDirection(direction)
- .setCurrencyCode(currencyCode)
- .setAmount(amountInSatoshis)
- .setMinAmount(minAmountInSatoshis)
- .setUseMarketBasedPrice(true)
- .setMarketPriceMargin(priceMarginAsPercent)
- .setPrice("0")
- .setBuyerSecurityDeposit(securityDepositAsPercent)
- .setMakerFeeCurrencyCode(feeCurrency)
- .build();
- return grpcStubs.offersService.createOffer(req).getOffer();
+ return grpcClient.createMarketBasedPricedOffer(direction,
+ currencyCode,
+ amountInSatoshis,
+ minAmountInSatoshis,
+ priceMarginAsPercent,
+ securityDepositAsPercent,
+ paymentAccount.getId(),
+ feeCurrency);
}
/**
@@ -186,28 +165,18 @@ public OfferInfo createOfferAtFixedPrice(PaymentAccount paymentAccount,
String fixedOfferPriceAsString,
double securityDepositAsPercent,
String feeCurrency) {
- var req = CreateOfferRequest.newBuilder()
- .setPaymentAccountId(paymentAccount.getId())
- .setDirection(direction)
- .setCurrencyCode(currencyCode)
- .setAmount(amountInSatoshis)
- .setMinAmount(minAmountInSatoshis)
- .setUseMarketBasedPrice(false)
- .setMarketPriceMargin(0)
- .setPrice(fixedOfferPriceAsString)
- .setBuyerSecurityDeposit(securityDepositAsPercent)
- .setMakerFeeCurrencyCode(feeCurrency)
- .build();
- return grpcStubs.offersService.createOffer(req).getOffer();
+ return grpcClient.createFixedPricedOffer(direction,
+ currencyCode,
+ amountInSatoshis,
+ minAmountInSatoshis,
+ fixedOfferPriceAsString,
+ securityDepositAsPercent,
+ paymentAccount.getId(),
+ feeCurrency);
}
public TradeInfo takeOffer(String offerId, PaymentAccount paymentAccount, String feeCurrency) {
- var req = TakeOfferRequest.newBuilder()
- .setOfferId(offerId)
- .setPaymentAccountId(paymentAccount.getId())
- .setTakerFeeCurrencyCode(feeCurrency)
- .build();
- return grpcStubs.tradesService.takeOffer(req).getTrade();
+ return grpcClient.takeOffer(offerId, paymentAccount.getId(), feeCurrency);
}
/**
@@ -216,8 +185,7 @@ public TradeInfo takeOffer(String offerId, PaymentAccount paymentAccount, String
* @return TradeInfo
*/
public TradeInfo getTrade(String tradeId) {
- var req = GetTradeRequest.newBuilder().setTradeId(tradeId).build();
- return grpcStubs.tradesService.getTrade(req).getTrade();
+ return grpcClient.getTrade(tradeId);
}
/**
@@ -243,7 +211,7 @@ public TradeInfo getTrade(String tradeId) {
*/
public String getTradeContract(String tradeId) {
try {
- var trade = getTrade(tradeId);
+ var trade = grpcClient.getTrade(tradeId);
return trade.getContractAsJson();
} catch (Exception ex) {
if (tradeContractIsNotReady.test(ex, tradeId))
@@ -259,7 +227,7 @@ public String getTradeContract(String tradeId) {
* @return boolean
*/
public boolean isTakerDepositFeeTxPublished(String tradeId) {
- return getTrade(tradeId).getIsPayoutPublished();
+ return grpcClient.getTrade(tradeId).getIsPayoutPublished();
}
/**
@@ -268,7 +236,7 @@ public boolean isTakerDepositFeeTxPublished(String tradeId) {
* @return boolean
*/
public boolean isTakerDepositFeeTxConfirmed(String tradeId) {
- return getTrade(tradeId).getIsDepositConfirmed();
+ return grpcClient.getTrade(tradeId).getIsDepositConfirmed();
}
/**
@@ -277,7 +245,7 @@ public boolean isTakerDepositFeeTxConfirmed(String tradeId) {
* @return boolean
*/
public boolean isTradePaymentStartedSent(String tradeId) {
- return getTrade(tradeId).getIsFiatSent();
+ return grpcClient.getTrade(tradeId).getIsFiatSent();
}
/**
@@ -286,7 +254,7 @@ public boolean isTradePaymentStartedSent(String tradeId) {
* @return boolean
*/
public boolean isTradePaymentReceivedConfirmationSent(String tradeId) {
- return getTrade(tradeId).getIsFiatReceived();
+ return grpcClient.getTrade(tradeId).getIsFiatReceived();
}
/**
@@ -295,7 +263,7 @@ public boolean isTradePaymentReceivedConfirmationSent(String tradeId) {
* @return boolean
*/
public boolean isTradePayoutTxPublished(String tradeId) {
- return getTrade(tradeId).getIsPayoutPublished();
+ return grpcClient.getTrade(tradeId).getIsPayoutPublished();
}
/**
@@ -304,9 +272,7 @@ public boolean isTradePayoutTxPublished(String tradeId) {
* @param tradeId
*/
public void sendConfirmPaymentStartedMessage(String tradeId) {
- var req = ConfirmPaymentStartedRequest.newBuilder().setTradeId(tradeId).build();
- //noinspection ResultOfMethodCallIgnored
- grpcStubs.tradesService.confirmPaymentStarted(req);
+ grpcClient.confirmPaymentStarted(tradeId);
}
/**
@@ -315,9 +281,7 @@ public void sendConfirmPaymentStartedMessage(String tradeId) {
* @param tradeId
*/
public void sendConfirmPaymentReceivedMessage(String tradeId) {
- var req = ConfirmPaymentReceivedRequest.newBuilder().setTradeId(tradeId).build();
- //noinspection ResultOfMethodCallIgnored
- grpcStubs.tradesService.confirmPaymentReceived(req);
+ grpcClient.confirmPaymentReceived(tradeId);
}
/**
@@ -326,9 +290,7 @@ public void sendConfirmPaymentReceivedMessage(String tradeId) {
* @param tradeId
*/
public void sendKeepFundsMessage(String tradeId) {
- var req = KeepFundsRequest.newBuilder().setTradeId(tradeId).build();
- //noinspection ResultOfMethodCallIgnored
- grpcStubs.tradesService.keepFunds(req);
+ grpcClient.keepFunds(tradeId);
}
/**
@@ -337,11 +299,7 @@ public void sendKeepFundsMessage(String tradeId) {
* @return PaymentAccount
*/
public PaymentAccount createNewPaymentAccount(String json) {
- var req = CreatePaymentAccountRequest.newBuilder()
- .setPaymentAccountForm(json)
- .build();
- var paymentAccountsService = grpcStubs.paymentAccountsService;
- return paymentAccountsService.createPaymentAccount(req).getPaymentAccount();
+ return grpcClient.createPaymentAccount(json);
}
/**
@@ -351,10 +309,7 @@ public PaymentAccount createNewPaymentAccount(String json) {
* @return PaymentAccount
*/
public PaymentAccount getPaymentAccount(String paymentAccountId) {
- var req = GetPaymentAccountsRequest.newBuilder().build();
- return grpcStubs.paymentAccountsService.getPaymentAccounts(req)
- .getPaymentAccountsList()
- .stream()
+ return grpcClient.getPaymentAccounts().stream()
.filter(a -> (a.getId().equals(paymentAccountId)))
.findFirst()
.orElseThrow(() ->
@@ -370,9 +325,7 @@ public PaymentAccount getPaymentAccount(String paymentAccountId) {
*/
public PaymentAccount getPaymentAccountWithName(String accountName) {
var req = GetPaymentAccountsRequest.newBuilder().build();
- return grpcStubs.paymentAccountsService.getPaymentAccounts(req)
- .getPaymentAccountsList()
- .stream()
+ return grpcClient.getPaymentAccounts().stream()
.filter(a -> (a.getAccountName().equals(accountName)))
.findFirst()
.orElseThrow(() ->
diff --git a/cli/src/main/java/bisq/cli/GrpcClient.java b/cli/src/main/java/bisq/cli/GrpcClient.java
index 533183e2d7d..b49a3c0aa78 100644
--- a/cli/src/main/java/bisq/cli/GrpcClient.java
+++ b/cli/src/main/java/bisq/cli/GrpcClient.java
@@ -19,6 +19,8 @@
import bisq.proto.grpc.AddressBalanceInfo;
import bisq.proto.grpc.BalancesInfo;
+import bisq.proto.grpc.BsqBalanceInfo;
+import bisq.proto.grpc.BtcBalanceInfo;
import bisq.proto.grpc.CancelOfferRequest;
import bisq.proto.grpc.ConfirmPaymentReceivedRequest;
import bisq.proto.grpc.ConfirmPaymentStartedRequest;
@@ -63,6 +65,9 @@
import protobuf.PaymentMethod;
import java.util.List;
+import java.util.stream.Collectors;
+
+import static java.util.Comparator.comparing;
@SuppressWarnings("ResultOfMethodCallIgnored")
public final class GrpcClient {
@@ -78,6 +83,18 @@ public String getVersion() {
return grpcStubs.versionService.getVersion(request).getVersion();
}
+ public BalancesInfo getBalances() {
+ return getBalances("");
+ }
+
+ public BsqBalanceInfo getBsqBalances() {
+ return getBalances("BSQ").getBsq();
+ }
+
+ public BtcBalanceInfo getBtcBalances() {
+ return getBalances("BTC").getBtc();
+ }
+
public BalancesInfo getBalances(String currencyCode) {
var request = GetBalancesRequest.newBuilder()
.setCurrencyCode(currencyCode)
@@ -108,6 +125,18 @@ public String getUnusedBsqAddress() {
return grpcStubs.walletsService.getUnusedBsqAddress(request).getAddress();
}
+ public String getUnusedBtcAddress() {
+ var request = GetFundingAddressesRequest.newBuilder().build();
+ //noinspection OptionalGetWithoutIsPresent
+ return grpcStubs.walletsService.getFundingAddresses(request)
+ .getAddressBalanceInfoList()
+ .stream()
+ .filter(a -> a.getBalance() == 0 && a.getNumConfirmations() == 0)
+ .findFirst()
+ .get()
+ .getAddress();
+ }
+
public TxInfo sendBsq(String address, String amount, String txFeeRate) {
var request = SendBsqRequest.newBuilder()
.setAddress(address)
@@ -151,6 +180,47 @@ public TxInfo getTransaction(String txId) {
return grpcStubs.walletsService.getTransaction(request).getTxInfo();
}
+ public OfferInfo createFixedPricedOffer(String direction,
+ String currencyCode,
+ long amount,
+ long minAmount,
+ String fixedPrice,
+ double securityDeposit,
+ String paymentAcctId,
+ String makerFeeCurrencyCode) {
+ return createOffer(direction,
+ currencyCode,
+ amount,
+ minAmount,
+ false,
+ fixedPrice,
+ 0.00,
+ securityDeposit,
+ paymentAcctId,
+ makerFeeCurrencyCode);
+ }
+
+ public OfferInfo createMarketBasedPricedOffer(String direction,
+ String currencyCode,
+ long amount,
+ long minAmount,
+ double marketPriceMargin,
+ double securityDeposit,
+ String paymentAcctId,
+ String makerFeeCurrencyCode) {
+ return createOffer(direction,
+ currencyCode,
+ amount,
+ minAmount,
+ true,
+ "0",
+ marketPriceMargin,
+ securityDeposit,
+ paymentAcctId,
+ makerFeeCurrencyCode);
+ }
+
+ // TODO make private, move to bottom of class
public OfferInfo createOffer(String direction,
String currencyCode,
long amount,
@@ -205,6 +275,11 @@ public List getOffers(String direction, String currencyCode) {
return grpcStubs.offersService.getOffers(request).getOffersList();
}
+ public List getOffersSortedByDate(String direction, String currencyCode) {
+ var offers = getOffers(direction, currencyCode);
+ return offers.isEmpty() ? offers : sortOffersByDate(offers);
+ }
+
public List getMyOffers(String direction, String currencyCode) {
var request = GetMyOffersRequest.newBuilder()
.setDirection(direction)
@@ -213,6 +288,23 @@ public List getMyOffers(String direction, String currencyCode) {
return grpcStubs.offersService.getMyOffers(request).getOffersList();
}
+ public List getMyOffersSortedByDate(String direction, String currencyCode) {
+ var offers = getMyOffers(direction, currencyCode);
+ return offers.isEmpty() ? offers : sortOffersByDate(offers);
+ }
+
+ public OfferInfo getMostRecentOffer(String direction, String currencyCode) {
+ List offers = getOffersSortedByDate(direction, currencyCode);
+ return offers.isEmpty() ? null : offers.get(offers.size() - 1);
+ }
+
+ // TODO move to bottom of class
+ private List sortOffersByDate(List offerInfoList) {
+ return offerInfoList.stream()
+ .sorted(comparing(OfferInfo::getDate))
+ .collect(Collectors.toList());
+ }
+
public TradeInfo takeOffer(String offerId, String paymentAccountId, String takerFeeCurrencyCode) {
var request = TakeOfferRequest.newBuilder()
.setOfferId(offerId)
@@ -301,9 +393,15 @@ public void removeWalletPassword(String walletPassword) {
grpcStubs.walletsService.removeWalletPassword(request);
}
- public void setWalletPassword(String walletPassword, String newWalletPassword) {
+ public void setWalletPassword(String walletPassword) {
var request = SetWalletPasswordRequest.newBuilder()
- .setPassword(walletPassword)
+ .setPassword(walletPassword).build();
+ grpcStubs.walletsService.setWalletPassword(request);
+ }
+
+ public void setWalletPassword(String oldWalletPassword, String newWalletPassword) {
+ var request = SetWalletPasswordRequest.newBuilder()
+ .setPassword(oldWalletPassword)
.setNewPassword(newWalletPassword).build();
grpcStubs.walletsService.setWalletPassword(request);
}