mirror of
https://github.com/bitcoinj/bitcoinj.git
synced 2025-01-19 05:33:44 +01:00
TransactionBroadcastTest: use TestNet3Params, rather than UnitTestParams
This commit is contained in:
parent
1f10855462
commit
4d1e8d659e
@ -80,7 +80,7 @@ public class TransactionBroadcastTest extends TestWithPeerGroup {
|
||||
@Test
|
||||
public void fourPeers() throws Exception {
|
||||
InboundMessageQueuer[] channels = { connectPeer(1), connectPeer(2), connectPeer(3), connectPeer(4) };
|
||||
Transaction tx = FakeTxBuilder.createFakeTx(UNITTEST);
|
||||
Transaction tx = FakeTxBuilder.createFakeTx(TESTNET);
|
||||
tx.getConfidence().setSource(TransactionConfidence.Source.SELF);
|
||||
TransactionBroadcast broadcast = new TransactionBroadcast(peerGroup, tx);
|
||||
final AtomicDouble lastProgress = new AtomicDouble();
|
||||
@ -118,7 +118,7 @@ public class TransactionBroadcastTest extends TestWithPeerGroup {
|
||||
// immediately with the latest state. This avoids API users writing accidentally racy code when they use
|
||||
// a convenience method like peerGroup.broadcastTransaction.
|
||||
InboundMessageQueuer[] channels = { connectPeer(1), connectPeer(2), connectPeer(3), connectPeer(4) };
|
||||
Transaction tx = FakeTxBuilder.createFakeTx(UNITTEST, CENT, address);
|
||||
Transaction tx = FakeTxBuilder.createFakeTx(TESTNET, CENT, address);
|
||||
tx.getConfidence().setSource(TransactionConfidence.Source.SELF);
|
||||
TransactionBroadcast broadcast = peerGroup.broadcastTransaction(tx);
|
||||
inbound(channels[1], InventoryMessage.with(tx));
|
||||
@ -131,14 +131,14 @@ public class TransactionBroadcastTest extends TestWithPeerGroup {
|
||||
@Test
|
||||
public void rejectHandling() throws Exception {
|
||||
InboundMessageQueuer[] channels = { connectPeer(0), connectPeer(1), connectPeer(2), connectPeer(3), connectPeer(4) };
|
||||
Transaction tx = FakeTxBuilder.createFakeTx(UNITTEST);
|
||||
Transaction tx = FakeTxBuilder.createFakeTx(TESTNET);
|
||||
TransactionBroadcast broadcast = new TransactionBroadcast(peerGroup, tx);
|
||||
CompletableFuture<TransactionBroadcast> future = broadcast.broadcastAndAwaitRelay();
|
||||
// 0 and 3 are randomly selected to receive the broadcast.
|
||||
assertEquals(tx, outbound(channels[1]));
|
||||
assertEquals(tx, outbound(channels[2]));
|
||||
assertEquals(tx, outbound(channels[4]));
|
||||
RejectMessage reject = new RejectMessage(UNITTEST, RejectMessage.RejectCode.DUST, tx.getTxId(), "tx", "dust");
|
||||
RejectMessage reject = new RejectMessage(TESTNET, RejectMessage.RejectCode.DUST, tx.getTxId(), "tx", "dust");
|
||||
inbound(channels[1], reject);
|
||||
inbound(channels[4], reject);
|
||||
try {
|
||||
@ -163,7 +163,7 @@ public class TransactionBroadcastTest extends TestWithPeerGroup {
|
||||
assertEquals(FIFTY_COINS, wallet.getBalance());
|
||||
|
||||
// Now create a spend, and expect the announcement on p1.
|
||||
Address dest = LegacyAddress.fromKey(UNITTEST, new ECKey());
|
||||
Address dest = LegacyAddress.fromKey(TESTNET, new ECKey());
|
||||
Wallet.SendResult sendResult = wallet.sendCoins(peerGroup, dest, COIN);
|
||||
assertFalse(sendResult.broadcastComplete.isDone());
|
||||
Transaction t1;
|
||||
@ -190,7 +190,7 @@ public class TransactionBroadcastTest extends TestWithPeerGroup {
|
||||
// Make sure we can create spends, and that they are announced. Then do the same with offline mode.
|
||||
|
||||
// Set up connections and block chain.
|
||||
VersionMessage ver = new VersionMessage(UNITTEST, 2);
|
||||
VersionMessage ver = new VersionMessage(TESTNET, 2);
|
||||
ver.localServices = VersionMessage.NODE_NETWORK;
|
||||
InboundMessageQueuer p1 = connectPeer(1, ver);
|
||||
InboundMessageQueuer p2 = connectPeer(2);
|
||||
@ -207,7 +207,7 @@ public class TransactionBroadcastTest extends TestWithPeerGroup {
|
||||
wallet.addTransactionConfidenceEventListener((wallet, tx) -> transactions[0] = tx);
|
||||
|
||||
// Now create a spend, and expect the announcement on p1.
|
||||
Address dest = LegacyAddress.fromKey(UNITTEST, new ECKey());
|
||||
Address dest = LegacyAddress.fromKey(TESTNET, new ECKey());
|
||||
Wallet.SendResult sendResult = wallet.sendCoins(peerGroup, dest, COIN);
|
||||
assertNotNull(sendResult.tx);
|
||||
Threading.waitForUserCode();
|
||||
@ -228,7 +228,7 @@ public class TransactionBroadcastTest extends TestWithPeerGroup {
|
||||
// 49 BTC in change.
|
||||
assertEquals(valueOf(49, 0), t1.getValueSentToMe(wallet));
|
||||
// The future won't complete until it's heard back from the network on p2.
|
||||
InventoryMessage inv = new InventoryMessage(UNITTEST);
|
||||
InventoryMessage inv = new InventoryMessage(TESTNET);
|
||||
inv.addTransaction(t1);
|
||||
inbound(p2, inv);
|
||||
pingAndWait(p2);
|
||||
|
Loading…
Reference in New Issue
Block a user