Skip to content

Commit

Permalink
When testing for specific network, use network ID.
Browse files Browse the repository at this point in the history
  • Loading branch information
schildbach committed Dec 6, 2015
1 parent c0b2e7c commit 313e2c1
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/org/bitcoinj/core/Wallet.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ public Wallet(Context context, KeyChainGroup keyChainGroup) {
this.context = context;
this.params = context.getParams();
this.keyChainGroup = checkNotNull(keyChainGroup);
if (params == UnitTestParams.get())
if (params.getId().equals(NetworkParameters.ID_UNITTESTNET))
this.keyChainGroup.setLookaheadSize(5); // Cut down excess computation for unit tests.
// If this keyChainGroup was created fresh just now (new wallet), make HD so a backup can be made immediately
// without having to call current/freshReceiveKey. If there are already keys in the chain of any kind then
Expand Down Expand Up @@ -3700,7 +3700,7 @@ public String toString() {
*/
public Transaction createSend(Address address, Coin value) throws InsufficientMoneyException {
SendRequest req = SendRequest.to(address, value);
if (params == UnitTestParams.get())
if (params.getId().equals(NetworkParameters.ID_UNITTESTNET))
req.shuffleOutputs = false;
completeTx(req);
return req.tx;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/org/bitcoinj/kits/WalletAppKit.java
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ protected void startUp() throws Exception {
for (PeerAddress addr : peerAddresses) vPeerGroup.addAddress(addr);
vPeerGroup.setMaxConnections(peerAddresses.length);
peerAddresses = null;
} else if (params != RegTestParams.get() && !useTor) {
} else if (!params.getId().equals(NetworkParameters.ID_REGTEST) && !useTor) {
vPeerGroup.addPeerDiscovery(discovery != null ? discovery : new DnsDiscovery(params));
}
vChain.addWallet(vWallet);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,6 @@ public static boolean isSelectable(Transaction tx) {
confidence.getSource().equals(TransactionConfidence.Source.SELF) &&
// In regtest mode we expect to have only one peer, so we won't see transactions propagate.
// TODO: The value 1 below dates from a time when transactions we broadcast *to* were counted, set to 0
(confidence.numBroadcastPeers() > 1 || tx.getParams() == RegTestParams.get());
(confidence.numBroadcastPeers() > 1 || tx.getParams().getId().equals(NetworkParameters.ID_REGTEST));
}
}

0 comments on commit 313e2c1

Please sign in to comment.