3
0
mirror of https://github.com/Qortal/altcoinj.git synced 2025-02-07 14:54:15 +00:00

Further global replace of NetworkParameters.* -> *.get()

This commit is contained in:
Matt Corallo 2013-05-22 23:50:50 +02:00 committed by Mike Hearn
parent f4c3b6a49d
commit 5993f2dc6c
16 changed files with 40 additions and 23 deletions

View File

@ -19,6 +19,7 @@ package com.google.bitcoin.core;
import com.google.bitcoin.core.Wallet.BalanceType;
import com.google.bitcoin.params.MainNetParams;
import com.google.bitcoin.params.TestNet2Params;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.store.BlockStore;
import com.google.bitcoin.store.MemoryBlockStore;
import com.google.bitcoin.utils.BriefLogFormatter;
@ -63,7 +64,7 @@ public class BlockChainTest {
BriefLogFormatter.initVerbose();
testNetChain = new BlockChain(testNet, new Wallet(testNet), new MemoryBlockStore(testNet));
unitTestParams = NetworkParameters.unitTests();
unitTestParams = UnitTestParams.get();
wallet = new Wallet(unitTestParams) {
@Override
public void receiveFromBlock(Transaction tx, StoredBlock block, BlockChain.NewBlockType blockType) throws VerificationException {

View File

@ -16,6 +16,8 @@
package com.google.bitcoin.core;
import com.google.bitcoin.params.TestNet2Params;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.script.ScriptOpCodes;
import org.junit.Test;
import org.spongycastle.util.encoders.Hex;
@ -30,7 +32,7 @@ import java.util.Arrays;
import static org.junit.Assert.*;
public class BlockTest {
static final NetworkParameters params = NetworkParameters.testNet2();
static final NetworkParameters params = TestNet2Params.get();
public static final byte[] blockBytes;
@ -66,7 +68,7 @@ public class BlockTest {
@Test
public void testProofOfWork() throws Exception {
// This params accepts any difficulty target.
NetworkParameters params = NetworkParameters.unitTests();
NetworkParameters params = UnitTestParams.get();
Block block = new Block(params, blockBytes);
block.setNonce(12346);
try {
@ -153,7 +155,7 @@ public class BlockTest {
@Test
public void testUpdateLength() {
NetworkParameters params = NetworkParameters.unitTests();
NetworkParameters params = UnitTestParams.get();
Block block = params.getGenesisBlock().createNextBlockWithCoinbase(new ECKey().getPubKey());
assertEquals(block.bitcoinSerialize().length, block.length);
final int origBlockLen = block.length;

View File

@ -17,6 +17,7 @@
package com.google.bitcoin.core;
import com.google.bitcoin.core.TransactionConfidence.ConfidenceType;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.store.MemoryBlockStore;
import com.google.bitcoin.utils.BriefLogFormatter;
import org.junit.Before;
@ -43,7 +44,7 @@ public class ChainSplitTest {
@Before
public void setUp() throws Exception {
BriefLogFormatter.init();
unitTestParams = NetworkParameters.unitTests();
unitTestParams = UnitTestParams.get();
wallet = new Wallet(unitTestParams);
wallet.addKey(new ECKey());
wallet.addKey(new ECKey());

View File

@ -21,6 +21,7 @@ import com.google.bitcoin.crypto.KeyCrypter;
import com.google.bitcoin.crypto.KeyCrypterScrypt;
import com.google.bitcoin.params.MainNetParams;
import com.google.bitcoin.params.TestNet3Params;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.utils.BriefLogFormatter;
import com.google.protobuf.ByteString;
import org.bitcoinj.wallet.Protos;
@ -355,7 +356,7 @@ public class ECKeyTest {
public void roundTripDumpedPrivKey() throws Exception {
ECKey key = new ECKey();
assertTrue(key.isCompressed());
NetworkParameters params = NetworkParameters.unitTests();
NetworkParameters params = UnitTestParams.get();
String base58 = key.getPrivateKeyEncoded(params).toString();
ECKey key2 = new DumpedPrivateKey(params, base58).getKey();
assertTrue(key2.isCompressed());

View File

@ -1,6 +1,7 @@
package com.google.bitcoin.core;
import com.google.bitcoin.core.TransactionConfidence.ConfidenceType;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.store.MemoryBlockStore;
import org.junit.Test;
import org.spongycastle.util.encoders.Hex;
@ -16,7 +17,7 @@ public class FilteredBlockAndPartialMerkleTreeTests extends TestWithPeerGroup {
@Test
// Simple deserialization sanity check
public void deserializeFilteredBlock() throws Exception {
NetworkParameters params = NetworkParameters.unitTests();
NetworkParameters params = UnitTestParams.get();
// Random real block (000000000000dab0130bbcc991d3d7ae6b81aa6f50a798888dfe62337458dc45)
// With one tx
@ -33,7 +34,7 @@ public class FilteredBlockAndPartialMerkleTreeTests extends TestWithPeerGroup {
@Test
public void serializeDownloadBlockWithWallet() throws Exception {
unitTestParams = NetworkParameters.unitTests();
unitTestParams = UnitTestParams.get();
// First we create all the neccessary objects, including lots of serialization and double-checks
// Note that all serialized forms here are generated by the reference client/pulled from block explorer
@ -76,7 +77,7 @@ public class FilteredBlockAndPartialMerkleTreeTests extends TestWithPeerGroup {
assertTrue(Arrays.equals(filter.bitcoinSerialize(), Hex.decode("0e1b091ca195e45a9164889b6bc46a09000000efbeadde02")));
// Cheat and place the previous block (block 100000) at the head of the block store without supporting blocks
blockStore = new MemoryBlockStore(NetworkParameters.unitTests());
blockStore = new MemoryBlockStore(UnitTestParams.get());
blockStore.put(new StoredBlock(new Block(unitTestParams, Hex.decode("0100000050120119172a610421a6c3011dd330d9df07b63616c2cc1f1cd00200000000006657a9252aacd5c0b2940996ecff952228c3067cc38d4885efb5a4ac4247e9f337221b4d4c86041b0f2b5710")),
BigInteger.valueOf(1), 100000));
blockStore.setChainHead(blockStore.get(new Sha256Hash("000000000003ba27aa200b1cecaad478d2b00432346c3f1f3986da1afd33e506")));

View File

@ -18,6 +18,7 @@
package com.google.bitcoin.core;
import com.google.bitcoin.core.Transaction.SigHash;
import com.google.bitcoin.params.MainNetParams;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.script.Script;
import com.google.bitcoin.store.BlockStoreException;
@ -176,7 +177,7 @@ public class FullPrunedBlockChainTest {
@Test
public void testFirst100KBlocks() throws BlockStoreException, VerificationException, PrunedException {
NetworkParameters params = NetworkParameters.prodNet();
NetworkParameters params = MainNetParams.get();
File blockFile = new File(getClass().getResource("first-100k-blocks.dat").getFile());
BlockFileLoader loader = new BlockFileLoader(params, Arrays.asList(new File[] {blockFile}));

View File

@ -17,6 +17,7 @@
package com.google.bitcoin.core;
import com.google.bitcoin.params.MainNetParams;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.store.BlockStore;
import com.google.bitcoin.store.MemoryBlockStore;
import org.junit.Before;
@ -78,7 +79,7 @@ public class LazyParseByteCacheTest {
@Before
public void setUp() throws Exception {
unitTestParams = NetworkParameters.unitTests();
unitTestParams = UnitTestParams.get();
wallet = new Wallet(unitTestParams);
wallet.addKey(new ECKey());

View File

@ -16,6 +16,7 @@
package com.google.bitcoin.core;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.utils.BriefLogFormatter;
import org.junit.Before;
import org.junit.Test;
@ -26,7 +27,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
public class MemoryPoolTest {
private NetworkParameters params = NetworkParameters.unitTests();
private NetworkParameters params = UnitTestParams.get();
private Transaction tx1, tx2;
private PeerAddress address1, address2, address3;

View File

@ -18,6 +18,7 @@ package com.google.bitcoin.core;
import com.google.bitcoin.discovery.PeerDiscovery;
import com.google.bitcoin.discovery.PeerDiscoveryException;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.store.MemoryBlockStore;
import org.junit.After;
import org.junit.Before;
@ -34,12 +35,12 @@ import java.util.concurrent.TimeUnit;
import static org.junit.Assert.*;
public class PeerGroupTest extends TestWithPeerGroup {
static final NetworkParameters params = NetworkParameters.unitTests();
static final NetworkParameters params = UnitTestParams.get();
@Override
@Before
public void setUp() throws Exception {
super.setUp(new MemoryBlockStore(NetworkParameters.unitTests()));
super.setUp(new MemoryBlockStore(UnitTestParams.get()));
peerGroup.addWallet(wallet);
}

View File

@ -16,6 +16,7 @@
package com.google.bitcoin.core;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.store.BlockStore;
import com.google.bitcoin.store.MemoryBlockStore;
import com.google.bitcoin.utils.BriefLogFormatter;
@ -49,7 +50,7 @@ public class TestWithNetworkConnections {
protected ChannelPipeline pipeline;
public void setUp() throws Exception {
setUp(new MemoryBlockStore(NetworkParameters.unitTests()));
setUp(new MemoryBlockStore(UnitTestParams.get()));
}
public void setUp(BlockStore blockStore) throws Exception {
@ -58,7 +59,7 @@ public class TestWithNetworkConnections {
control = createStrictControl();
control.checkOrder(false);
unitTestParams = NetworkParameters.unitTests();
unitTestParams = UnitTestParams.get();
this.blockStore = blockStore;
wallet = new Wallet(unitTestParams);
key = new ECKey();

View File

@ -16,6 +16,7 @@
package com.google.bitcoin.core;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.store.BlockStore;
import com.google.bitcoin.store.MemoryBlockStore;
import com.google.bitcoin.utils.BriefLogFormatter;
@ -29,7 +30,7 @@ import static com.google.bitcoin.core.TestUtils.createFakeBlock;
import static com.google.bitcoin.core.TestUtils.createFakeTx;
public class TestWithWallet {
protected static final NetworkParameters params = NetworkParameters.unitTests();
protected static final NetworkParameters params = UnitTestParams.get();
protected ECKey myKey;
protected Address myAddress;
protected Wallet wallet;

View File

@ -1,5 +1,6 @@
package com.google.bitcoin.core;
import com.google.bitcoin.params.UnitTestParams;
import org.junit.Test;
import org.spongycastle.util.encoders.Hex;
@ -9,7 +10,7 @@ public class VersionMessageTest {
@Test
// Test that we can decode version messages which miss data which some old nodes may not include
public void testDecode() throws Exception {
NetworkParameters params = NetworkParameters.unitTests();
NetworkParameters params = UnitTestParams.get();
VersionMessage ver = new VersionMessage(params, Hex.decode("71110100000000000000000048e5e95000000000000000000000000000000000000000000000ffff7f000001479d000000000000000000000000000000000000ffff7f000001479d0000000000000000172f426974436f696e4a3a302e372d534e415053484f542f0004000000"));
assertTrue(!ver.relayTxesBeforeFilter);

View File

@ -19,6 +19,7 @@ import com.google.bitcoin.core.Address;
import com.google.bitcoin.core.ECKey;
import com.google.bitcoin.core.NetworkParameters;
import com.google.bitcoin.core.StoredBlock;
import com.google.bitcoin.params.UnitTestParams;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
@ -38,7 +39,7 @@ public class BoundedOverheadBlockStoreTest {
File temp = folder.newFile("bitcoinj-test");
System.out.println(temp.getAbsolutePath());
NetworkParameters params = NetworkParameters.unitTests();
NetworkParameters params = UnitTestParams.get();
Address to = new ECKey().toAddress(params);
BoundedOverheadBlockStore store = new BoundedOverheadBlockStore(params, temp);
// Check the first block in a new store is the genesis block.
@ -64,7 +65,7 @@ public class BoundedOverheadBlockStoreTest {
File temp = folder.newFile("bitcoinj-test");
System.out.println(temp.getAbsolutePath());
NetworkParameters params = NetworkParameters.unitTests();
NetworkParameters params = UnitTestParams.get();
BoundedOverheadBlockStore store = new BoundedOverheadBlockStore(params, temp);
try {
BoundedOverheadBlockStore store1 = new BoundedOverheadBlockStore(params, temp);

View File

@ -20,6 +20,7 @@ import com.google.bitcoin.core.ECKey;
import com.google.bitcoin.core.NetworkParameters;
import com.google.bitcoin.core.StoredBlock;
import com.google.bitcoin.params.UnitTestParams;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@ -43,7 +44,7 @@ public class DiskBlockStoreTest {
temp = folder.newFile("bitcoinj-test");
System.out.println(temp.getAbsolutePath());
params = NetworkParameters.unitTests();
params = UnitTestParams.get();
to = new ECKey().toAddress(params);
}

View File

@ -20,6 +20,7 @@ import com.google.bitcoin.core.Address;
import com.google.bitcoin.core.ECKey;
import com.google.bitcoin.core.NetworkParameters;
import com.google.bitcoin.core.StoredBlock;
import com.google.bitcoin.params.UnitTestParams;
import org.junit.Test;
import java.io.File;
@ -30,7 +31,7 @@ public class SPVBlockStoreTest {
@Test
public void basics() throws Exception {
NetworkParameters params = NetworkParameters.unitTests();
NetworkParameters params = UnitTestParams.get();
File f = File.createTempFile("spvblockstore", null);
f.delete();
f.deleteOnExit();

View File

@ -4,6 +4,7 @@ package com.google.bitcoin.store;
import com.google.bitcoin.core.*;
import com.google.bitcoin.core.TransactionConfidence.ConfidenceType;
import com.google.bitcoin.params.MainNetParams;
import com.google.bitcoin.params.UnitTestParams;
import com.google.bitcoin.utils.BriefLogFormatter;
import com.google.protobuf.ByteString;
import org.bitcoinj.wallet.Protos;
@ -22,7 +23,7 @@ import static com.google.bitcoin.core.TestUtils.createFakeTx;
import static org.junit.Assert.*;
public class WalletProtobufSerializerTest {
static final NetworkParameters params = NetworkParameters.unitTests();
static final NetworkParameters params = UnitTestParams.get();
private ECKey myKey;
private Address myAddress;
private Wallet myWallet;