/** Returns a testnet params modified to allow any difficulty target. */ @Deprecated public static NetworkParameters unitTests() { return UnitTestParams.get(); }
public static synchronized UnitTestParams get() { if (instance == null) { instance = new UnitTestParams(); } return instance; }
/** * Ensure that hashForSignature() doesn't modify a transaction's data, which could wreak multithreading havoc. */ @Test public void testHashForSignatureThreadSafety() { Block genesis = UnitTestParams.get().getGenesisBlock(); Block block1 = genesis.createNextBlock(new ECKey().toAddress(UnitTestParams.get()), genesis.getTransactions().get(0).getOutput(0).getOutPointFor()); final Transaction tx = block1.getTransactions().get(1); final String txHash = tx.getHashAsString(); final String txNormalizedHash = tx.hashForSignature(0, new byte[0], Transaction.SigHash.ALL.byteValue()).toString(); for (int i = 0; i < 100; i++) { // ensure the transaction object itself was not modified; if it was, the hash will change assertEquals(txHash, tx.getHashAsString()); new Thread(){ public void run() { assertEquals(txNormalizedHash, tx.hashForSignature(0, new byte[0], Transaction.SigHash.ALL.byteValue()).toString()); } }; } }
/** Returns a testnet params modified to allow any difficulty target. */ @Deprecated public static NetworkParameters unitTests() { return UnitTestParams.get(); }
public static synchronized UnitTestParams get() { if (instance == null) { instance = new UnitTestParams(); } return instance; }
/** Returns a testnet context modified to allow any difficulty target. */ @Deprecated public static NetworkParameters unitTests() { return UnitTestParams.get(); }
public static synchronized UnitTestParams get() { if (instance == null) { instance = new UnitTestParams(); } return instance; }
/** Returns a testnet params modified to allow any difficulty target. */ @Deprecated public static NetworkParameters unitTests() { return UnitTestParams.get(); }
public static synchronized UnitTestParams get() { if (instance == null) { instance = new UnitTestParams(); } return instance; }
/** Returns the network parameters for the given string ID or NULL if not recognized. */ @Nullable public static NetworkParameters fromID(String id) { if (id.equals(ID_MAINNET)) { return MainNetParams.get(); } else if (id.equals(ID_TESTNET)) { return TestNet3Params.get(); } else if (id.equals(ID_UNITTESTNET)) { return UnitTestParams.get(); } else if (id.equals(ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string ID or NULL if not recognized. */ @Nullable public static NetworkParameters fromID(String id) { if (id.equals(ID_MAINNET)) { return MainNetParams.get(); } else if (id.equals(ID_TESTNET)) { return TestNet3Params.get(); } else if (id.equals(ID_UNITTESTNET)) { return UnitTestParams.get(); } else if (id.equals(ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string paymentProtocolID or NULL if not recognized. */ @Nullable public static NetworkParameters fromPmtProtocolID(String pmtProtocolId) { if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_MAINNET)) { return MainNetParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_TESTNET)) { return TestNet3Params.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_UNIT_TESTS)) { return UnitTestParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string paymentProtocolID or NULL if not recognized. */ @Nullable public static NetworkParameters fromPmtProtocolID(String pmtProtocolId) { if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_MAINNET)) { return MainNetParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_TESTNET)) { return TestNet3Params.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_UNIT_TESTS)) { return UnitTestParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string paymentProtocolID or NULL if not recognized. */ @Nullable public static NetworkParameters fromPmtProtocolID(String pmtProtocolId) { if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_MAINNET)) { return MainNetParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_TESTNET)) { return TestNet3Params.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_UNIT_TESTS)) { return UnitTestParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string ID or NULL if not recognized. */ @Nullable public static NetworkParameters fromID(String id) { if (id.equals(ID_MAINNET)) { return MainNetParams.get(); } else if (id.equals(ID_TESTNET)) { return TestNet3Params.get(); } else if (id.equals(ID_UNITTESTNET)) { return UnitTestParams.get(); } else if (id.equals(ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string ID or NULL if not recognized. */ @Nullable public static NetworkParameters fromID(String id) { if (id.equals(ID_MAINNET)) { return MainNetParams.get(); } else if (id.equals(ID_TESTNET)) { return TestNet3Params.get(); } else if (id.equals(ID_UNITTESTNET)) { return UnitTestParams.get(); } else if (id.equals(ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
/** Returns the network parameters for the given string paymentProtocolID or NULL if not recognized. */ @Nullable public static NetworkParameters fromPmtProtocolID(String pmtProtocolId) { if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_MAINNET)) { return MainNetParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_TESTNET)) { return TestNet3Params.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_UNIT_TESTS)) { return UnitTestParams.get(); } else if (pmtProtocolId.equals(PAYMENT_PROTOCOL_ID_REGTEST)) { return RegTestParams.get(); } else { return null; } }
public void setUp() throws Exception { setUp(new MemoryBlockStore(UnitTestParams.get())); }
@Test(expected = ProtocolException.class) public void readStrOfExtremeLength() throws Exception { NetworkParameters params = UnitTestParams.get(); VarInt length = new VarInt(Integer.MAX_VALUE); byte[] payload = length.encode(); new VarStrMessage(params, payload); }
@Test(expected = ProtocolException.class) public void readByteArrayOfExtremeLength() throws Exception { NetworkParameters params = UnitTestParams.get(); VarInt length = new VarInt(Integer.MAX_VALUE); byte[] payload = length.encode(); new VarBytesMessage(params, payload); }