Skip to main content

Testing Applications

ReddCoin Core provides testing tools designed to let developers test their applications with reduced risks and limitations.

Testnet

When run with no arguments, all ReddCoin Core programs default to ReddCoin’s main network (mainnet). However, for development, it’s safer and cheaper to use ReddCoin’s test network (testnet) where the reddoshis spent have no real-world value. Testnet also relaxes some restrictions (such as standard transaction checks) so you can test functions which might currently be disabled by default on mainnet.

To use testnet, use the argument -testnet with reddcoin-cli, reddcoind or reddcoin-qt or add testnet=1 to your reddcoin.conf file as described earlier. To get free reddoshis for testing, use Piotr Piasecki’s testnet faucet. Testnet is a public resource provided for free by members of the community, so please don’t abuse it.

Regtest Mode

For situations where interaction with random peers and blocks is unnecessary or unwanted, ReddCoin Core’s regression test mode (regtest mode) lets you instantly create a brand-new private block chain with the same basic rules as testnet—but one major difference: you choose when to create new blocks, so you have complete control over the environment.

Many developers consider regtest mode the preferred way to develop new applications. The following example will let you create a regtest environment after you first configure reddcoind.

> reddcoind -regtest -daemon
Reddcoin server starting

Start reddcoind in regtest mode to create a private block chain.

reddcoin-cli -regtest generatetoaddress 101 $(reddcoin-cli -regtest getnewaddress)

Generate 101 blocks using a special RPC which is only available in regtest mode. This takes less than a second on a generic PC. Regtest uses the same reward schedule as mainnet, so block 1 pays out the premine reward of 545,000,000 RDD. A block must have 100 confirmations before its coinbase can be spent, so we generate 101 blocks to get access to the coinbase transaction from block #1.

reddcoin-cli -regtest getbalance
545000000.00000000

Verify that we now have block 1's premine reward of 545,000,000 RDD available to spend.

You can now use ReddCoin Core RPCs prefixed with reddcoin-cli -regtest.

Regtest wallets and block chain state (chainstate) are saved in the regtest subdirectory of the ReddCoin Core configuration directory. You can safely delete the regtest subdirectory and restart ReddCoin Core to start a new regtest. (See the Developer Examples Introduction for default configuration directory locations on various operating systems. Always back up mainnet wallets before performing dangerous operations such as deleting.)