com.google.bitcoin.utils
Class TestWithWallet

java.lang.Object
  extended by com.google.bitcoin.utils.TestWithWallet

public class TestWithWallet
extends Object

A utility class that you can derive from in your unit tests. TestWithWallet sets up a wallet with a key, an in memory block store and a block chain object. It also provides helper methods for filling the wallet with money in whatever ways you wish. Note that for simplicity with amounts, this class sets the default fee per kilobyte to zero in setUp and back to normal in tearDown. If you are wanting to test your behaviour with fees (a good idea!) make sure you set the Wallet.SendRequest#DEFAULT_FEE_PER_KB value to Transaction.REFERENCE_DEFAULT_MIN_TX_FEE before doing so.


Field Summary
protected  BlockStore blockStore
           
protected  BlockChain chain
           
protected  Address myAddress
           
protected  ECKey myKey
           
protected static NetworkParameters params
           
protected  Wallet wallet
           
 
Constructor Summary
TestWithWallet()
           
 
Method Summary
protected  Transaction sendMoneyToWallet(BigInteger value, AbstractBlockChain.NewBlockType type)
           
protected  Transaction sendMoneyToWallet(Transaction tx, AbstractBlockChain.NewBlockType type)
           
protected  Transaction sendMoneyToWallet(Wallet wallet, BigInteger value, Address toAddress, AbstractBlockChain.NewBlockType type)
           
protected  Transaction sendMoneyToWallet(Wallet wallet, BigInteger value, ECKey toPubKey, AbstractBlockChain.NewBlockType type)
           
protected  Transaction sendMoneyToWallet(Wallet wallet, Transaction tx, AbstractBlockChain.NewBlockType type)
           
 void setUp()
           
 void tearDown()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

params

protected static final NetworkParameters params

myKey

protected ECKey myKey

myAddress

protected Address myAddress

wallet

protected Wallet wallet

chain

protected BlockChain chain

blockStore

protected BlockStore blockStore
Constructor Detail

TestWithWallet

public TestWithWallet()
Method Detail

setUp

public void setUp()
           throws Exception
Throws:
Exception

tearDown

public void tearDown()
              throws Exception
Throws:
Exception

sendMoneyToWallet

@Nullable
protected Transaction sendMoneyToWallet(Wallet wallet,
                                                 Transaction tx,
                                                 AbstractBlockChain.NewBlockType type)
                                 throws IOException,
                                        VerificationException
Throws:
IOException
VerificationException

sendMoneyToWallet

@Nullable
protected Transaction sendMoneyToWallet(Transaction tx,
                                                 AbstractBlockChain.NewBlockType type)
                                 throws IOException,
                                        VerificationException
Throws:
IOException
VerificationException

sendMoneyToWallet

@Nullable
protected Transaction sendMoneyToWallet(Wallet wallet,
                                                 BigInteger value,
                                                 Address toAddress,
                                                 AbstractBlockChain.NewBlockType type)
                                 throws IOException,
                                        VerificationException
Throws:
IOException
VerificationException

sendMoneyToWallet

@Nullable
protected Transaction sendMoneyToWallet(Wallet wallet,
                                                 BigInteger value,
                                                 ECKey toPubKey,
                                                 AbstractBlockChain.NewBlockType type)
                                 throws IOException,
                                        VerificationException
Throws:
IOException
VerificationException

sendMoneyToWallet

@Nullable
protected Transaction sendMoneyToWallet(BigInteger value,
                                                 AbstractBlockChain.NewBlockType type)
                                 throws IOException,
                                        VerificationException
Throws:
IOException
VerificationException


Copyright © 2014. All rights reserved.