Skip to content

Commit

Permalink
Move JUnit 5 BitcoindExtension to wallets.regtest module
Browse files Browse the repository at this point in the history
The wallets.regtest can't depend on any Bisq 2 API to be able to re-use
the bitcoind regtest module in Bisq 1. I migrated our BitcoinJ fork to
the upstream version but Bisq 1 uses deprecated/removed BitcoinJ APIs,
and it's too risky to update critical code without testing the changes.
Bisq 1 doesn't have any bitcoind-based integration testing code and
quicker to re-use Bisq 2 bitcoind integration test infrastructure.
  • Loading branch information
alvasw committed Sep 4, 2024
1 parent 679fd81 commit b76d475
Show file tree
Hide file tree
Showing 16 changed files with 78 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.regtest.ConnectionFailureIntegrationTests;
import bisq.wallets.regtest.bitcoind.BitcoindRegtestSetup;
import bisq.wallets.regtest.process.MultiProcessCoordinator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.bitcoind.rpc.BitcoindDaemon;
import bisq.wallets.bitcoind.rpc.calls.BitcoindCreateWalletRpcCall;
import bisq.wallets.json_rpc.RpcConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.bitcoind.rpc.BitcoindDaemon;
import bisq.wallets.regtest.AbstractRegtestSetup;
import bisq.wallets.regtest.bitcoind.BitcoindRegtestSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.bitcoind.rpc.BitcoindWallet;
import bisq.wallets.bitcoind.rpc.responses.BitcoindDescriptor;
import bisq.wallets.bitcoind.rpc.responses.BitcoindListDescriptorResponse;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.bitcoind.rpc.BitcoindDaemon;
import bisq.wallets.bitcoind.rpc.BitcoindWallet;
import bisq.wallets.bitcoind.rpc.calls.requests.BitcoindImportDescriptorRequestEntry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.bitcoind.rpc.BitcoindWallet;
import bisq.wallets.core.model.AddressType;
import bisq.wallets.regtest.bitcoind.BitcoindRegtestSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.bitcoind.rpc.BitcoindWallet;
import bisq.wallets.bitcoind.rpc.responses.BitcoindListTransactionsResponse;
import bisq.wallets.core.model.AddressType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.bitcoind.rpc.BitcoindWallet;
import bisq.wallets.bitcoind.rpc.responses.BitcoindListUnspentResponse;
import bisq.wallets.regtest.bitcoind.BitcoindRegtestSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.bitcoind.rpc.BitcoindWallet;
import bisq.wallets.core.model.AddressType;
import bisq.wallets.regtest.bitcoind.BitcoindRegtestSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.bitcoind.rpc.BitcoindWallet;
import bisq.wallets.core.model.AddressType;
import bisq.wallets.regtest.bitcoind.BitcoindRegtestSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.bitcoind.rpc.BitcoindDaemon;
import bisq.wallets.bitcoind.rpc.BitcoindWallet;
import bisq.wallets.json_rpc.RpcConfig;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind.zmq;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.regtest.bitcoind.BitcoindRegtestSetup;
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.Test;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

package bisq.wallets.bitcoind.zmq;

import bisq.wallets.bitcoind.regtest.BitcoindExtension;
import bisq.wallets.regtest.BitcoindExtension;
import bisq.wallets.bitcoind.rpc.BitcoindDaemon;
import bisq.wallets.bitcoind.rpc.responses.BitcoindGetZmqNotificationsResponse;
import bisq.wallets.regtest.bitcoind.BitcoindRegtestSetup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
* along with Bisq. If not, see <http://www.gnu.org/licenses/>.
*/

package bisq.wallets.bitcoind.regtest;
package bisq.wallets.regtest;

import bisq.wallets.regtest.bitcoind.BitcoindRegtestSetup;
import org.junit.jupiter.api.extension.BeforeAllCallback;
Expand Down
62 changes: 62 additions & 0 deletions wallets/regtest/src/main/java/bisq/wallets/regtest/Os.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package bisq.wallets.regtest;

import lombok.Getter;

import java.util.Locale;

public enum Os {
LINUX("linux"),
MAC_OS("macos"),
WINDOWS("win");

@Getter
private final String canonicalName;

Os(String canonicalName) {
this.canonicalName = canonicalName;
}

public static bisq.common.platform.OS getOS() {
String osName = getOsName();
if (isLinux(osName)) {
return bisq.common.platform.OS.LINUX;
} else if (isMacOs(osName)) {
return bisq.common.platform.OS.MAC_OS;
} else if (isWindows(osName)) {
return bisq.common.platform.OS.WINDOWS;
}
throw new IllegalStateException("Running on unsupported OS: " + osName);
}

public static boolean isLinux() {
return isLinux(getOsName());
}

public static boolean isLinux(String osName) {
return osName.contains("linux");
}

public static boolean isMacOs() {
return isMacOs(getOsName());
}

public static boolean isMacOs(String osName) {
return osName.contains("mac") || osName.contains("darwin");
}

public static boolean isWindows() {
return isWindows(getOsName());
}

public static boolean isWindows(String osName) {
return osName.contains("win");
}

public static String getOsName() {
return System.getProperty("os.name").toLowerCase(Locale.US);
}

public static String getOsVersion() {
return System.getProperty("os.version");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@

package bisq.wallets.regtest.bitcoind;

import bisq.common.platform.OS;
import bisq.common.util.NetworkUtils;
import bisq.wallets.bitcoind.rpc.BitcoindDaemon;
import bisq.wallets.bitcoind.rpc.BitcoindWallet;
import bisq.wallets.bitcoind.rpc.responses.BitcoindListUnspentResponse;
import bisq.wallets.bitcoind.zmq.ZmqListeners;
import bisq.wallets.json_rpc.RpcConfig;
import bisq.wallets.regtest.AbstractRegtestSetup;
import bisq.wallets.regtest.Os;
import bisq.wallets.regtest.process.MultiProcessCoordinator;
import lombok.Getter;

Expand Down Expand Up @@ -158,7 +158,7 @@ private Path installBitcoind(Path bitcoindBinaryDir) throws IOException {
throw new IllegalStateException("Couldn't extract bitcoind binary.");
}

if (OS.isLinux() || OS.isMacOs()) {
if (Os.isLinux() || Os.isMacOs()) {
isSuccess = bitcoindPath.toFile().setExecutable(true);
if (!isSuccess) {
throw new IllegalStateException("Couldn't set executable bit on bitcoind binary.");
Expand Down

0 comments on commit b76d475

Please sign in to comment.