Skip to content

Commit

Permalink
Move BTCTestSupport from Groovy to Java
Browse files Browse the repository at this point in the history
Move from cj-btc-jsonrpc-gvy to cj-btc-jsonrpc module
  • Loading branch information
msgilligan committed Sep 25, 2023
1 parent 5fa1b71 commit a9e505f
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.consensusj.bitcoin.jsonrpc.groovy.test

import org.consensusj.bitcoin.json.pojo.RawTransactionInfo
import org.consensusj.bitcoin.jsonrpc.test.BTCTestSupport
import org.consensusj.bitcoin.jsonrpc.test.RegTestFundingSource
import org.consensusj.bitcoin.jsonrpc.test.TransactionIngredients
import org.consensusj.jsonrpc.JsonRpcStatusException
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.consensusj.bitcoin.test
import groovy.util.logging.Slf4j
import org.bitcoinj.base.BitcoinNetwork
import org.consensusj.bitcoin.jsonrpc.BitcoinExtendedClient
import org.consensusj.bitcoin.jsonrpc.groovy.test.BTCTestSupport
import org.consensusj.bitcoin.jsonrpc.test.BTCTestSupport
import org.consensusj.bitcoin.jsonrpc.RpcURI
import org.consensusj.bitcoin.jsonrpc.test.TestServers
import spock.lang.Specification
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package org.consensusj.bitcoin.test
import groovy.util.logging.Slf4j
import org.bitcoinj.base.BitcoinNetwork
import org.consensusj.bitcoin.jsonrpc.BitcoinExtendedClient
import org.consensusj.bitcoin.jsonrpc.groovy.test.BTCTestSupport
import org.consensusj.bitcoin.jsonrpc.test.BTCTestSupport
import org.consensusj.bitcoin.jsonrpc.test.FundingSource
import org.consensusj.bitcoin.jsonrpc.test.FundingSourceAccessor
import org.consensusj.bitcoin.jsonrpc.test.RegTestFundingSource
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,26 @@
package org.consensusj.bitcoin.jsonrpc.groovy.test
package org.consensusj.bitcoin.jsonrpc.test;

import groovy.transform.CompileStatic
import org.bitcoinj.base.Network
import org.consensusj.bitcoin.jsonrpc.test.BitcoinClientAccessor
import org.bitcoinj.base.Network;
import org.consensusj.jsonrpc.JsonRpcException;

// TODO: Migrate to Java
/**
* Test support functions intended to be mixed-in to Spock test specs
*/
@CompileStatic
interface BTCTestSupport extends BitcoinClientAccessor {
public interface BTCTestSupport extends BitcoinClientAccessor {

/**
* Wait for the server to become ready and validate the Bitcoin network it is running on
* @param expectedNetworkParams The network the server is expected to be running on
* @param expectedNetwork The network the server is expected to be running on
*/
default void serverReady(Network expectedNetwork) {
default void serverReady(Network expectedNetwork) throws JsonRpcException {
Boolean ready = client().waitForServer(60); // Wait up to 1 minute
if (!ready) {
throw new RuntimeException("Timeout waiting for server");
}
// As soon as the server is ready we must initialize network parameters in the client (by querying them)
Network network = client().getNetwork();
assert network.equals(expectedNetwork);
if (!network.equals(expectedNetwork)) {
throw new IllegalStateException("Server reports unexpected Bitcoin network.");
}
}
}

0 comments on commit a9e505f

Please sign in to comment.