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

Use single ElectrumXServer instance for all integration tests #532

Merged
merged 1 commit into from
Oct 30, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public synchronized void beforeAll(ExtensionContext context) throws Exception {
// Register close hook
context.getRoot()
.getStore(GLOBAL)
.put("register_close_hook", this);
.put("register_bitcoind_close_hook", this);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,22 +23,43 @@

import java.io.IOException;

public class ElectrumXServerExtension implements BeforeAllCallback, AfterAllCallback, ParameterResolver {
import static org.junit.jupiter.api.extension.ExtensionContext.Namespace.GLOBAL;

private final ElectrumXServerRegtestSetup regtestSetup;
public class ElectrumXServerExtension implements BeforeAllCallback, ExtensionContext.Store.CloseableResource, ParameterResolver {

public ElectrumXServerExtension() throws IOException {
regtestSetup = new ElectrumXServerRegtestSetup();
private static boolean isRunning;
private static final ElectrumXServerRegtestSetup regtestSetup;

static {
try {
regtestSetup = new ElectrumXServerRegtestSetup();
} catch (IOException e) {
throw new RuntimeException(e);
}
}

public ElectrumXServerExtension() {
}

@Override
public void beforeAll(ExtensionContext context) throws Exception {
regtestSetup.start();
public synchronized void beforeAll(ExtensionContext context) throws Exception {
if (!isRunning) {
regtestSetup.start();
isRunning = true;

// Register close hook
context.getRoot()
.getStore(GLOBAL)
.put("register_electrumx_close_hook", this);
}
}

@Override
public void afterAll(ExtensionContext context) {
regtestSetup.shutdown();
public synchronized void close() {
if (isRunning) {
regtestSetup.shutdown();
isRunning = false;
}
}

@Override
Expand Down