Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bisq.properties pickup in ApiTest #6724

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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);
}
alejandrogarcia83 marked this conversation as resolved.
Show resolved Hide resolved

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