Skip to content

Commit

Permalink
Merge branch 'master' into release/v1.9.12
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandrogarcia83 authored Jul 13, 2023
2 parents 3f2d55a + 02e87d5 commit 85a457c
Show file tree
Hide file tree
Showing 40 changed files with 512 additions and 161 deletions.
26 changes: 24 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,28 @@ jobs:
distribution: 'zulu'

- name: Build with Gradle
uses: gradle/gradle-build-action@v2.4.2
uses: gradle/gradle-build-action@v2.5.1
with:
arguments: build --scan
arguments: build jacocoTestReport testCodeCoverageReport --scan

- name: Upload coverage report
uses: actions/upload-artifact@v3
with:
name: coverage-report
path: code-coverage-report/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml

publish_coverage:
name: Publish coverage
runs-on: ubuntu-latest
needs: build
steps:
- name: Download coverage report
uses: actions/download-artifact@v3
with:
name: coverage-report
path: code-coverage-report/build/reports/jacoco/testCodeCoverageReport
- name: Run codacy-coverage-reporter
uses: codacy/codacy-coverage-reporter-action@v1.3.0
with:
project-token: ${{ secrets.CODACY_PROJECT_TOKEN }}
coverage-reports: ${{ github.workspace }}/code-coverage-report/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml
15 changes: 4 additions & 11 deletions apitest/dao-setup.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
//
// The :apitest subproject will not run on Windows, and these tasks have not been
// tested on Windows.
def buildResourcesDir = project(":apitest").buildDir.path + '/resources/main'
def buildResourcesDir = project(":apitest").sourceSets.main.resources.srcDirs.first().path

// This task requires ant in the system $PATH.
task installDaoSetup(dependsOn: 'cleanDaoSetup') {
doLast {
println "Installing dao-setup directories in build dir $buildResourcesDir ..."
def src = 'https://github.com/bisq-network/bisq/raw/master/docs/dao-setup.zip'
def destfile = project.rootDir.path + '/apitest/src/main/resources/dao-setup.zip'
def destfile = buildResourcesDir + '/dao-setup.zip'
def url = new URL(src)
def f = new File(destfile)
if (f.exists()) {
Expand Down Expand Up @@ -48,21 +48,14 @@ task installDaoSetup(dependsOn: 'cleanDaoSetup') {
}

// Copy files from unzip target dir 'dao-setup' to build/resources/main.
def daoSetupSrc = project.rootDir.path + '/apitest/src/main/resources/dao-setup'
def daoSetupDest = buildResourcesDir + '/dao-setup'
def daoSetupSrc = buildResourcesDir + '/dao-setup'
def daoSetupDest = buildResourcesDir
println "Copying $daoSetupSrc to $daoSetupDest ..."
copy {
from daoSetupSrc
into daoSetupDest
}

// Move dao-setup files from build/resources/main/dao-setup to build/resources/main
file(buildResourcesDir + '/dao-setup/Bitcoin-regtest')
.renameTo(file(buildResourcesDir + '/Bitcoin-regtest'))
file(buildResourcesDir + '/dao-setup/bisq-BTC_REGTEST_Alice_dao')
.renameTo(file(buildResourcesDir + '/bisq-BTC_REGTEST_Alice_dao'))
file(buildResourcesDir + '/dao-setup/bisq-BTC_REGTEST_Bob_dao')
.renameTo(file(buildResourcesDir + '/bisq-BTC_REGTEST_Bob_dao'))
delete file(buildResourcesDir + '/dao-setup')
}
}
Expand Down
31 changes: 20 additions & 11 deletions apitest/src/main/java/bisq/apitest/Scaffold.java
Original file line number Diff line number Diff line change
Expand Up @@ -242,28 +242,37 @@ public void installDaoSetupDirectories() {

log.info("Copied all dao-setup files to {}", buildDataDir);

// Try to avoid confusion about which 'bisq.properties' file is or was loaded
// by a Bisq instance: delete the 'bisq.properties' file automatically copied
// to the 'apitest/build/resources/main' directory during IDE or Gradle build.
// Note: there is no way to prevent this deleted file from being re-copied
// from 'src/main/resources' to the buildDataDir each time you hit the build
// button in the IDE.
BashCommand rmRedundantBisqPropertiesFile =
new BashCommand("rm -rf " + buildDataDir + "/bisq.properties");
if (rmRedundantBisqPropertiesFile.run().getExitStatus() != 0)
throw new IllegalStateException("Could not delete redundant bisq.properties file");
// Copy 'bisq.properties' file from 'src/main/resources' to each
// Bisq instance's DataDir
copyBisqPropertiesFileToAppDataDir();

// Copy the blocknotify script from the src resources dir to the build
// resources dir. Users may want to edit comment out some lines when all
// the default block notifcation ports being will not be used (to avoid
// seeing rpc notifcation warnings in log files).
installBitcoinBlocknotify();

} catch (IOException | InterruptedException ex) {
throw new IllegalStateException("Could not install dao-setup files from " + daoSetupDir, ex);
}
}

private void copyBisqPropertiesFileToAppDataDir() throws IOException, InterruptedException {
copyBisqPropertiesFileToAppDataDir(alicedaemon);
copyBisqPropertiesFileToAppDataDir(bobdaemon);
}

private void copyBisqPropertiesFileToAppDataDir(BisqAppConfig bisqAppConfig) throws IOException, InterruptedException {
if (!new File(config.baseSrcResourcesDir + "/bisq.properties").exists()) return;

String instanceDataDir = config.rootAppDataDir + "/" + bisqAppConfig.appName;
BashCommand moveToDataDir =
new BashCommand("cp " + config.baseSrcResourcesDir + "/bisq.properties " + instanceDataDir);
if (moveToDataDir.run().getExitStatus() != 0)
throw new IllegalStateException("Could not copy bisq.properties to " + instanceDataDir);
log.debug("bisq.properties copied to " + instanceDataDir);
}


private void cleanDaoSetupDirectories() {
String buildDataDir = config.rootAppDataDir.getAbsolutePath();
log.info("Cleaning dao-setup data in {}", buildDataDir);
Expand Down
11 changes: 11 additions & 0 deletions apitest/src/main/java/bisq/apitest/config/ApiTestConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ public class ApiTestConfig {
static final String ENABLE_BISQ_DEBUGGING = "enableBisqDebugging";
static final String REGISTER_DISPUTE_AGENTS = "registerDisputeAgents";

static final String SUSPEND_INSTANCE = "suspendInstance";

// Default values for certain options
static final String DEFAULT_CONFIG_FILE_NAME = "apitest.properties";

Expand Down Expand Up @@ -126,6 +128,8 @@ public class ApiTestConfig {
public final String baseBuildResourcesDir;
public final String baseSrcResourcesDir;

public final String suspendedInstances;

// The parser that will be used to parse both cmd line and config file options
private final OptionParser parser = new OptionParser();

Expand Down Expand Up @@ -261,6 +265,12 @@ public ApiTestConfig(String... args) {
.withRequiredArg()
.ofType(Boolean.class)
.defaultsTo(true);

ArgumentAcceptingOptionSpec<String> suspendInstancesOpt =
parser.accepts(SUSPEND_INSTANCE, "Suspended the given instances when debugging")
.withRequiredArg()
.ofType(String.class)
.defaultsTo(EMPTY);
try {
CompositeOptionSet options = new CompositeOptionSet();

Expand Down Expand Up @@ -319,6 +329,7 @@ public ApiTestConfig(String... args) {
this.callRateMeteringConfigPath = options.valueOf(callRateMeteringConfigPathOpt);
this.enableBisqDebugging = options.valueOf(enableBisqDebuggingOpt);
this.registerDisputeAgents = options.valueOf(registerDisputeAgentsOpt);
this.suspendedInstances = options.valueOf(suspendInstancesOpt);

// Assign values to special-case static fields.
BASH_PATH_VALUE = bashPath;
Expand Down
6 changes: 4 additions & 2 deletions apitest/src/main/java/bisq/apitest/linux/BisqProcess.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.io.IOException;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -66,8 +67,9 @@ public BisqProcess(BisqAppConfig bisqAppConfig, ApiTestConfig config) {
this.useDevPrivilegeKeys = true;
this.findBisqPidScript = (config.isRunningTest ? "." : "./apitest")
+ "/scripts/get-bisq-pid.sh";
this.debugOpts = config.enableBisqDebugging
? " -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:" + bisqAppConfig.remoteDebugPort
this.debugOpts = config.enableBisqDebugging ? " -agentlib:jdwp=transport=dt_socket,server=y,"
+ "suspend=" + (Arrays.asList(config.suspendedInstances.split(",")).contains(bisqAppConfig.name()) ? "y" : "n")
+ ",address=*:" + bisqAppConfig.remoteDebugPort
: "";
}

Expand Down
3 changes: 1 addition & 2 deletions apitest/src/test/java/bisq/apitest/ApiTestCase.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,7 @@ public static void setUpScaffold(Enum<?>... supportingApps)
throws InterruptedException, ExecutionException, IOException {
String[] params = new String[]{
"--supportingApps", stream(supportingApps).map(Enum::name).collect(Collectors.joining(",")),
"--callRateMeteringConfigPath", getTestRateMeterInterceptorConfig().getAbsolutePath(),
"--enableBisqDebugging", "false"
"--callRateMeteringConfigPath", getTestRateMeterInterceptorConfig().getAbsolutePath()
};
setUpScaffold(params);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ public class CallRateMeteringInterceptorTest extends MethodTest {
@BeforeAll
public static void setUp() {
startSupportingApps(false,
false,
bitcoind, alicedaemon);
}

Expand Down
9 changes: 2 additions & 7 deletions apitest/src/test/java/bisq/apitest/method/MethodTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,25 @@ public class MethodTest extends ApiTestCase {

public static void startSupportingApps(File callRateMeteringConfigFile,
boolean generateBtcBlock,
boolean startSupportingAppsInDebugMode,
Enum<?>... supportingApps) {
try {
setUpScaffold(new String[]{
"--supportingApps", toNameList.apply(supportingApps),
"--callRateMeteringConfigPath", callRateMeteringConfigFile.getAbsolutePath(),
"--enableBisqDebugging", startSupportingAppsInDebugMode ? "true" : "false"
});
doPostStartup(generateBtcBlock);
} catch (Exception ex) {
fail(ex);
}
}

public static void startSupportingApps(boolean generateBtcBlock,
boolean startSupportingAppsInDebugMode,
Enum<?>... supportingApps) {
public static void startSupportingApps(boolean generateBtcBlock, Enum<?>... supportingApps) {
try {
// Disable call rate metering where there is no callRateMeteringConfigFile.
File callRateMeteringConfigFile = getTestRateMeterInterceptorConfig();
setUpScaffold(new String[]{
"--supportingApps", toNameList.apply(supportingApps),
"--callRateMeteringConfigPath", callRateMeteringConfigFile.getAbsolutePath(),
"--enableBisqDebugging", startSupportingAppsInDebugMode ? "true" : "false"
"--callRateMeteringConfigPath", callRateMeteringConfigFile.getAbsolutePath()
});
doPostStartup(generateBtcBlock);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,7 @@ public abstract class AbstractOfferTest extends MethodTest {

@BeforeAll
public static void setUp() {
setUp(false);
}

public static void setUp(boolean startSupportingAppsInDebugMode) {
startSupportingApps(true,
startSupportingAppsInDebugMode,
bitcoind,
seednode,
arbdaemon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class BsqSwapOfferTest extends AbstractOfferTest {

@BeforeAll
public static void setUp() {
AbstractOfferTest.setUp(false);
}

@BeforeEach
public void generateBtcBlock() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@

import bisq.core.payment.PaymentAccount;

import bisq.proto.grpc.OfferInfo;

import io.grpc.StatusRuntimeException;

import java.util.List;
import java.util.concurrent.TimeoutException;

import lombok.extern.slf4j.Slf4j;

import org.junit.jupiter.api.Disabled;
Expand Down Expand Up @@ -59,8 +64,8 @@ public void testTakeAlicesBuyOffer(final TestInfo testInfo) {
PaymentAccount alicesUsdAccount = createDummyF2FAccount(aliceClient, "US");
var alicesOffer = aliceClient.createMarketBasedPricedOffer(BUY.name(),
USD,
12_500_000L,
12_500_000L, // min-amount = amount
10_000_000L,
10_000_000L, // min-amount = amount
0.00,
defaultBuyerSecurityDepositPct.get(),
alicesUsdAccount.getId(),
Expand All @@ -71,19 +76,34 @@ public void testTakeAlicesBuyOffer(final TestInfo testInfo) {

// Wait for Alice's AddToOfferBook task.
// Wait times vary; my logs show >= 2-second delay.
sleep(3_000); // TODO loop instead of hard code a wait time
var alicesUsdOffers = aliceClient.getMyOffersSortedByDate(BUY.name(), USD);
var timeout = System.currentTimeMillis() + 3000;
while (bobClient.getOffersSortedByDate(USD, true).size() < 1) {
sleep(100);
if (System.currentTimeMillis() > timeout)
fail(new TimeoutException("Timed out waiting for Offer to be added to OfferBook"));
}

List<OfferInfo> alicesUsdOffers = aliceClient.getMyOffersSortedByDate(BUY.name(), USD);
assertEquals(1, alicesUsdOffers.size());

PaymentAccount bobsUsdAccount = createDummyF2FAccount(bobClient, "US");
var ignoredTakeOfferAmountParam = 0L;

var trade = takeAlicesOffer(offerId,
bobsUsdAccount.getId(),
TRADE_FEE_CURRENCY_CODE,
ignoredTakeOfferAmountParam,
false);
sleep(2_500); // Allow available offer to be removed from offer book.
alicesUsdOffers = aliceClient.getMyOffersSortedByDate(BUY.name(), USD);

// Allow available offer to be removed from offer book.
timeout = System.currentTimeMillis() + 2500;
do {
alicesUsdOffers = aliceClient.getMyOffersSortedByDate(BUY.name(), USD);
sleep(100);
if (System.currentTimeMillis() > timeout)
fail(new TimeoutException("Timed out waiting for Offer to be removed from OfferBook"));
} while (alicesUsdOffers.size() > 0);

assertEquals(0, alicesUsdOffers.size());

trade = bobClient.getTrade(tradeId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,6 @@ public class TakeBuyBTCOfferWithNationalBankAcctTest extends AbstractTradeTest {
private static PaymentAccount alicesPaymentAccount;
private static PaymentAccount bobsPaymentAccount;

@BeforeAll
public static void setUp() {
setUp(false);
}

@Test
@Order(1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public class TakeSellXMROfferTest extends AbstractTradeTest {

@BeforeAll
public static void setUp() {
AbstractOfferTest.setUp(false);
AbstractOfferTest.setUp();
createXmrPaymentAccounts();
EXPECTED_PROTOCOL_STATUS.init();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public class BsqWalletTest extends MethodTest {
@BeforeAll
public static void setUp() {
startSupportingApps(true,
false,
bitcoind,
seednode,
arbdaemon,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ public class BtcTxFeeRateTest extends MethodTest {
@BeforeAll
public static void setUp() {
startSupportingApps(false,
true,
bitcoind,
seednode,
alicedaemon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ public class BtcWalletTest extends MethodTest {
@BeforeAll
public static void setUp() {
startSupportingApps(false,
false,
bitcoind,
seednode,
alicedaemon,
Expand Down
5 changes: 0 additions & 5 deletions apitest/src/test/java/bisq/apitest/scenario/OfferTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,6 @@
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class OfferTest extends AbstractOfferTest {

@BeforeAll
public static void setUp() {
setUp(false); // Use setUp(true) for running API daemons in remote debug mode.
}

@Test
@Order(1)
public void testCreateOfferValidation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ public static void setUp() {
try {
callRateMeteringConfigFile = getTestRateMeterInterceptorConfig();
startSupportingApps(callRateMeteringConfigFile,
false,
false,
bitcoind, seednode, arbdaemon, alicedaemon);
} catch (Exception ex) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ public class WalletTest extends MethodTest {
@BeforeAll
public static void setUp() {
startSupportingApps(true,
false,
bitcoind,
seednode,
arbdaemon,
Expand Down
Loading

0 comments on commit 85a457c

Please sign in to comment.