-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move BTCTestSupport from Groovy to Java
Move from cj-btc-jsonrpc-gvy to cj-btc-jsonrpc module
- Loading branch information
1 parent
5fa1b71
commit a9e505f
Showing
4 changed files
with
12 additions
and
12 deletions.
There are no files selected for viewing
1 change: 1 addition & 0 deletions
1
...src/main/groovy/org/consensusj/bitcoin/jsonrpc/groovy/test/JTransactionTestSupport.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 9 additions & 10 deletions
19
...jsonrpc/groovy/test/BTCTestSupport.groovy → .../bitcoin/jsonrpc/test/BTCTestSupport.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
} | ||
} | ||
} |