当前位置: 首页>>代码示例>>Java>>正文


Java UnitTestParams.get方法代码示例

本文整理汇总了Java中com.google.bitcoin.params.UnitTestParams.get方法的典型用法代码示例。如果您正苦于以下问题:Java UnitTestParams.get方法的具体用法?Java UnitTestParams.get怎么用?Java UnitTestParams.get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.bitcoin.params.UnitTestParams的用法示例。


在下文中一共展示了UnitTestParams.get方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testDecode

import com.google.bitcoin.params.UnitTestParams; //导入方法依赖的package包/类
@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 = UnitTestParams.get();
    
    VersionMessage ver = new VersionMessage(params, Hex.decode("71110100000000000000000048e5e95000000000000000000000000000000000000000000000ffff7f000001479d000000000000000000000000000000000000ffff7f000001479d0000000000000000172f426974436f696e4a3a302e372d534e415053484f542f0004000000"));
    assertTrue(!ver.relayTxesBeforeFilter);
    assertTrue(ver.bestHeight == 1024);
    assertTrue(ver.subVer.equals("/BitCoinJ:0.7-SNAPSHOT/"));
    
    ver = new VersionMessage(params, Hex.decode("71110100000000000000000048e5e95000000000000000000000000000000000000000000000ffff7f000001479d000000000000000000000000000000000000ffff7f000001479d0000000000000000172f426974436f696e4a3a302e372d534e415053484f542f00040000"));
    assertTrue(ver.relayTxesBeforeFilter);
    assertTrue(ver.bestHeight == 1024);
    assertTrue(ver.subVer.equals("/BitCoinJ:0.7-SNAPSHOT/"));
    
    ver = new VersionMessage(params, Hex.decode("71110100000000000000000048e5e95000000000000000000000000000000000000000000000ffff7f000001479d000000000000000000000000000000000000ffff7f000001479d0000000000000000172f426974436f696e4a3a302e372d534e415053484f542f"));
    assertTrue(ver.relayTxesBeforeFilter);
    assertTrue(ver.bestHeight == 0);
    assertTrue(ver.subVer.equals("/BitCoinJ:0.7-SNAPSHOT/"));
    
    ver = new VersionMessage(params, Hex.decode("71110100000000000000000048e5e95000000000000000000000000000000000000000000000ffff7f000001479d000000000000000000000000000000000000ffff7f000001479d0000000000000000"));
    assertTrue(ver.relayTxesBeforeFilter);
    assertTrue(ver.bestHeight == 0);
    assertTrue(ver.subVer.equals(""));
}
 
开发者ID:keremhd,项目名称:mintcoinj,代码行数:26,代码来源:VersionMessageTest.java

示例2: setUp

import com.google.bitcoin.params.UnitTestParams; //导入方法依赖的package包/类
public void setUp(BlockStore blockStore) throws Exception {
    BriefLogFormatter.init();

    unitTestParams = UnitTestParams.get();
    Wallet.SendRequest.DEFAULT_FEE_PER_KB = BigInteger.ZERO;
    this.blockStore = blockStore;
    wallet = new Wallet(unitTestParams);
    key = new ECKey();
    address = key.toAddress(unitTestParams);
    wallet.addKey(key);
    blockChain = new BlockChain(unitTestParams, wallet, blockStore);

    startPeerServers();
    if (clientType == ClientType.NIO_CLIENT_MANAGER || clientType == ClientType.BLOCKING_CLIENT_MANAGER)
        channels.startAndWait();

    socketAddress = new InetSocketAddress("127.0.0.1", 1111);
}
 
开发者ID:keremhd,项目名称:mintcoinj,代码行数:19,代码来源:TestWithNetworkConnections.java

示例3: deserializeFilteredBlock

import com.google.bitcoin.params.UnitTestParams; //导入方法依赖的package包/类
@Test
// Simple deserialization sanity check
public void deserializeFilteredBlock() throws Exception {
    NetworkParameters params = UnitTestParams.get();

    // Random real block (000000000000dab0130bbcc991d3d7ae6b81aa6f50a798888dfe62337458dc45)
    // With one tx
    FilteredBlock block = new FilteredBlock(params, Hex.decode("0100000079cda856b143d9db2c1caff01d1aecc8630d30625d10e8b4b8b0000000000000b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f196367291b4d4c86041b8fa45d630100000001b50cc069d6a3e33e3ff84a5c41d9d3febe7c770fdcc96b2c3ff60abe184f19630101"));
    
    // Check that the header was properly deserialized
    assertTrue(block.getBlockHeader().getHash().equals(new Sha256Hash("000000000000dab0130bbcc991d3d7ae6b81aa6f50a798888dfe62337458dc45")));
    
    // Check that the partial merkle tree is correct
    List<Sha256Hash> txesMatched = block.getTransactionHashes();
    assertTrue(txesMatched.size() == 1);
    assertTrue(txesMatched.contains(new Sha256Hash("63194f18be0af63f2c6bc9dc0f777cbefed3d9415c4af83f3ee3a3d669c00cb5")));
}
 
开发者ID:keremhd,项目名称:mintcoinj,代码行数:18,代码来源:FilteredBlockAndPartialMerkleTreeTests.java

示例4: setUp

import com.google.bitcoin.params.UnitTestParams; //导入方法依赖的package包/类
public void setUp(BlockStore blockStore) throws Exception {
    BriefLogFormatter.init();

    unitTestParams = UnitTestParams.get();
    Wallet.SendRequest.DEFAULT_FEE_PER_KB = BigInteger.ZERO;
    this.blockStore = blockStore;
    wallet = new Wallet(unitTestParams);
    key = new ECKey();
    address = key.toAddress(unitTestParams);
    wallet.addKey(key);
    blockChain = new BlockChain(unitTestParams, wallet, blockStore);

    startPeerServers();
    if (clientType == ClientType.NIO_CLIENT_MANAGER || clientType == ClientType.BLOCKING_CLIENT_MANAGER) {
        channels.startAsync();
        channels.awaitRunning();
    }

    socketAddress = new InetSocketAddress("127.0.0.1", 1111);
}
 
开发者ID:testzcrypto,项目名称:animecoinj,代码行数:21,代码来源:TestWithNetworkConnections.java

示例5: testDecode

import com.google.bitcoin.params.UnitTestParams; //导入方法依赖的package包/类
@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 = UnitTestParams.get();
    
    VersionMessage ver = new VersionMessage(params, Hex.decode("71110100000000000000000048e5e95000000000000000000000000000000000000000000000ffff7f000001479d000000000000000000000000000000000000ffff7f000001479d0000000000000000172f426974436f696e4a3a302e372d534e415053484f542f0004000000"));
    assertTrue(!ver.relayTxesBeforeFilter);
    assertTrue(ver.bestHeight == 1024);
    assertTrue(ver.subVer.equals("/"+CoinDefinition.coinName+"J:0.7-SNAPSHOT/"));
    
    ver = new VersionMessage(params, Hex.decode("71110100000000000000000048e5e95000000000000000000000000000000000000000000000ffff7f000001479d000000000000000000000000000000000000ffff7f000001479d0000000000000000172f426974436f696e4a3a302e372d534e415053484f542f00040000"));
    assertTrue(ver.relayTxesBeforeFilter);
    assertTrue(ver.bestHeight == 1024);
    assertTrue(ver.subVer.equals("/"+CoinDefinition.coinName+"J:0.7-SNAPSHOT/"));
    
    ver = new VersionMessage(params, Hex.decode("71110100000000000000000048e5e95000000000000000000000000000000000000000000000ffff7f000001479d000000000000000000000000000000000000ffff7f000001479d0000000000000000172f426974436f696e4a3a302e372d534e415053484f542f"));
    assertTrue(ver.relayTxesBeforeFilter);
    assertTrue(ver.bestHeight == 0);
    assertTrue(ver.subVer.equals("/"+CoinDefinition.coinName+"J:0.7-SNAPSHOT/"));
    
    ver = new VersionMessage(params, Hex.decode("71110100000000000000000048e5e95000000000000000000000000000000000000000000000ffff7f000001479d000000000000000000000000000000000000ffff7f000001479d0000000000000000"));
    assertTrue(ver.relayTxesBeforeFilter);
    assertTrue(ver.bestHeight == 0);
    assertTrue(ver.subVer.equals(""));
}
 
开发者ID:testzcrypto,项目名称:animecoinj,代码行数:26,代码来源:VersionMessageTest.java

示例6: setUp

import com.google.bitcoin.params.UnitTestParams; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    BriefLogFormatter.init();
    Utils.setMockClock(); // Use mock clock
    Wallet.SendRequest.DEFAULT_FEE_PER_KB = BigInteger.ZERO;
    unitTestParams = UnitTestParams.get();
    wallet = new Wallet(unitTestParams);
    wallet.addKey(new ECKey());
    wallet.addKey(new ECKey());
    blockStore = new MemoryBlockStore(unitTestParams);
    chain = new BlockChain(unitTestParams, wallet, blockStore);
    coinsTo = wallet.getKeys().get(0).toAddress(unitTestParams);
    coinsTo2 = wallet.getKeys().get(1).toAddress(unitTestParams);
    someOtherGuy = new ECKey().toAddress(unitTestParams);
}
 
开发者ID:keremhd,项目名称:mintcoinj,代码行数:16,代码来源:ChainSplitTest.java

示例7: testUpdateLength

import com.google.bitcoin.params.UnitTestParams; //导入方法依赖的package包/类
@Test
public void testUpdateLength() {
    NetworkParameters params = UnitTestParams.get();
    Block block = params.getGenesisBlock().createNextBlockWithCoinbase(new ECKey().getPubKey());
    assertEquals(block.bitcoinSerialize().length, block.length);
    final int origBlockLen = block.length;
    Transaction tx = new Transaction(params);
    // this is broken until the transaction has > 1 input + output (which is required anyway...)
    //assertTrue(tx.length == tx.bitcoinSerialize().length && tx.length == 8);
    byte[] outputScript = new byte[10];
    Arrays.fill(outputScript, (byte) ScriptOpCodes.OP_FALSE);
    tx.addOutput(new TransactionOutput(params, null, BigInteger.valueOf(1), outputScript));
    tx.addInput(new TransactionInput(params, null, new byte[] {(byte) ScriptOpCodes.OP_FALSE},
            new TransactionOutPoint(params, 0, Sha256Hash.create(new byte[] {1}))));
    int origTxLength = 8 + 2 + 8 + 1 + 10 + 40 + 1 + 1;
    assertEquals(tx.bitcoinSerialize().length, tx.length);
    assertEquals(origTxLength, tx.length);
    block.addTransaction(tx);
    assertEquals(block.bitcoinSerialize().length, block.length);
    assertEquals(origBlockLen + tx.length, block.length);
    block.getTransactions().get(1).getInputs().get(0).setScriptBytes(new byte[] {(byte) ScriptOpCodes.OP_FALSE, (byte) ScriptOpCodes.OP_FALSE});
    assertEquals(block.length, origBlockLen + tx.length);
    assertEquals(tx.length, origTxLength + 1);
    block.getTransactions().get(1).getInputs().get(0).setScriptBytes(new byte[] {});
    assertEquals(block.length, block.bitcoinSerialize().length);
    assertEquals(block.length, origBlockLen + tx.length);
    assertEquals(tx.length, origTxLength - 1);
    block.getTransactions().get(1).addInput(new TransactionInput(params, null, new byte[] {(byte) ScriptOpCodes.OP_FALSE},
            new TransactionOutPoint(params, 0, Sha256Hash.create(new byte[] {1}))));
    assertEquals(block.length, origBlockLen + tx.length);
    assertEquals(tx.length, origTxLength + 41); // - 1 + 40 + 1 + 1
}
 
开发者ID:coinspark,项目名称:sparkbit-bitcoinj,代码行数:33,代码来源:BlockTest.java

示例8: setUp

import com.google.bitcoin.params.UnitTestParams; //导入方法依赖的package包/类
@Override
@Before
public void setUp() throws Exception {
    super.setUp(new MemoryBlockStore(UnitTestParams.get()));
    peerGroup.addWallet(wallet);
    // Fix the random permutation that TransactionBroadcast uses to shuffle the peers.
    TransactionBroadcast.random = new Random(0);
    peerGroup.setMinBroadcastConnections(2);
}
 
开发者ID:sserrano44,项目名称:bitcoinj-watcher-service,代码行数:10,代码来源:TransactionBroadcastTest.java

示例9: basics

import com.google.bitcoin.params.UnitTestParams; //导入方法依赖的package包/类
@Test
public void basics() throws Exception {
    NetworkParameters params = UnitTestParams.get();
    File f = File.createTempFile("spvblockstore", null);
    f.delete();
    f.deleteOnExit();
    SPVBlockStore store = new SPVBlockStore(params, f);

    Address to = new ECKey().toAddress(params);
    // Check the first block in a new store is the genesis block.
    StoredBlock genesis = store.getChainHead();
    assertEquals(params.getGenesisBlock(), genesis.getHeader());
    assertEquals(0, genesis.getHeight());


    // Build a new block.
    StoredBlock b1 = genesis.build(genesis.getHeader().createNextBlock(to).cloneAsHeader());
    store.put(b1);
    store.setChainHead(b1);
    store.close();

    // Check we can get it back out again if we rebuild the store object.
    store = new SPVBlockStore(params, f);
    StoredBlock b2 = store.get(b1.getHeader().getHash());
    assertEquals(b1, b2);
    // Check the chain head was stored correctly also.
    StoredBlock chainHead = store.getChainHead();
    assertEquals(b1, chainHead);
}
 
开发者ID:coinspark,项目名称:sparkbit-bitcoinj,代码行数:30,代码来源:SPVBlockStoreTest.java

示例10: roundTripDumpedPrivKey

import com.google.bitcoin.params.UnitTestParams; //导入方法依赖的package包/类
@Test
public void roundTripDumpedPrivKey() throws Exception {
    ECKey key = new ECKey();
    assertTrue(key.isCompressed());
    NetworkParameters params = UnitTestParams.get();
    String base58 = key.getPrivateKeyEncoded(params).toString();
    ECKey key2 = new DumpedPrivateKey(params, base58).getKey();
    assertTrue(key2.isCompressed());
    assertTrue(Arrays.equals(key.getPrivKeyBytes(), key2.getPrivKeyBytes()));
    assertTrue(Arrays.equals(key.getPubKey(), key2.getPubKey()));
}
 
开发者ID:keremhd,项目名称:mintcoinj,代码行数:12,代码来源:ECKeyTest.java

示例11: setUp

import com.google.bitcoin.params.UnitTestParams; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
    unitTestParams = UnitTestParams.get();
    wallet = new Wallet(unitTestParams);
    wallet.addKey(new ECKey());

    resetBlockStore();
    
    Transaction tx1 = createFakeTx(unitTestParams,
            Utils.toNanoCoins(2, 0),
            wallet.getKeys().get(0).toAddress(unitTestParams));
    
    //add a second input so can test granularity of byte cache.
    Transaction prevTx = new Transaction(unitTestParams);
    TransactionOutput prevOut = new TransactionOutput(unitTestParams, prevTx, Utils.toNanoCoins(1, 0), wallet.getKeys().get(0).toAddress(unitTestParams));
    prevTx.addOutput(prevOut);
    // Connect it.
    tx1.addInput(prevOut);
    
    Transaction tx2 = createFakeTx(unitTestParams, Utils.toNanoCoins(1, 0),
            new ECKey().toAddress(unitTestParams));

    Block b1 = createFakeBlock(blockStore, tx1, tx2).block;

    BitcoinSerializer bs = new BitcoinSerializer(unitTestParams);
    
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    bs.serialize(tx1, bos);
    tx1BytesWithHeader = bos.toByteArray();
    tx1Bytes = tx1.bitcoinSerialize();
    
    bos.reset();
    bs.serialize(tx2, bos);
    tx2BytesWithHeader = bos.toByteArray();
    tx2Bytes = tx2.bitcoinSerialize();
    
    bos.reset();
    bs.serialize(b1, bos);
    b1BytesWithHeader = bos.toByteArray();
    b1Bytes = b1.bitcoinSerialize();
}
 
开发者ID:coinspark,项目名称:sparkbit-bitcoinj,代码行数:42,代码来源:LazyParseByteCacheTest.java


注:本文中的com.google.bitcoin.params.UnitTestParams.get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。