-
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.
DefaultRpcClient: add constructor for configurabe Transport implement…
…ations * Add TransportFactory interface * Add constructor that takes a TransportFactory, make it the canonical constructor * Rename JavaNet test spec to DefaultRpcClientSpec and have it use the factory to construct an client using the JavaNet client. TODO: Testing could obviously be improved. See the TODOs in the code.
- Loading branch information
1 parent
9db5736
commit beaf95f
Showing
4 changed files
with
78 additions
and
61 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
cj-btc-rx/src/main/java/org/consensusj/bitcoin/rx/ChainTipPublisher.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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package org.consensusj.bitcoin.rx;/** | ||
* | ||
*/ | ||
public class ChainTipPublisher { | ||
} |
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
51 changes: 51 additions & 0 deletions
51
consensusj-jsonrpc/src/test/groovy/org/consensusj/jsonrpc/DefaultRpcClientSpec.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package org.consensusj.jsonrpc | ||
|
||
import spock.lang.Ignore | ||
import spock.lang.Specification | ||
|
||
import org.consensusj.bitcoin.jsonrpc.RpcURI | ||
|
||
/** | ||
* RPCClient test specification | ||
*/ | ||
@Ignore("Integration test") | ||
class DefaultRpcClientSpec extends Specification { | ||
private final int regTestPort = RpcURI.RPCPORT_REGTEST | ||
private final URI testServerUri = "http://localhost:${regTestPort}".toURI(); | ||
private final String user = "bitcoinrpc" | ||
private final String pass = "pass" | ||
// TODO: Refactor so tests automatically run against both factories. | ||
private final DefaultRpcClient.TransportFactory transportFactory = (m) -> new JsonRpcClientJavaNet(m, JsonRpcTransport.getDefaultSSLContext(), testServerUri, user, pass) | ||
//private final DefaultRpcClient.TransportFactory transportFactory = (m) -> new JsonRpcClientHttpUrlConnection(m, JsonRpcTransport.getDefaultSSLContext(), testServerUri, user, pass) | ||
|
||
def "constructor works correctly" () { | ||
when: | ||
def client = new DefaultRpcClient(transportFactory, JsonRpcMessage.Version.V2) | ||
|
||
then: | ||
client.serverURI == "http://localhost:${regTestPort}".toURI() | ||
client.getJsonRpcVersion() == JsonRpcMessage.Version.V2 | ||
} | ||
|
||
// TODO: Create JsonRpcClientJavaNetSpec that tests the sendRequestForResponseString method | ||
|
||
// def "get block count as string" () { | ||
// when: | ||
// def client = new DefaultRpcClient(testServerUri, user, pass) | ||
// JsonRpcRequest req = new JsonRpcRequest("getblockcount"); | ||
// String blockcount = client.sendRequestForResponseString(req).join() | ||
// | ||
// then: | ||
// blockcount instanceof String | ||
// blockcount.length() >= 1 | ||
// } | ||
|
||
def "get block count as JsonRpcResponse" () { | ||
when: | ||
def client = new DefaultRpcClient(transportFactory, JsonRpcMessage.Version.V2) | ||
Integer blockcount = client.send("getblockcount", Integer.class) | ||
|
||
then: | ||
blockcount >= 0 | ||
} | ||
} |
47 changes: 0 additions & 47 deletions
47
consensusj-jsonrpc/src/test/groovy/org/consensusj/jsonrpc/JsonRpcClientJavaNetSpec.groovy
This file was deleted.
Oops, something went wrong.