Testing Applications

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

Testnet

When run with no arguments, all LcRyp Core programs default to LcRyp’s main network (mainnet). However, for development, it’s safer and cheaper to use LcRyp’s test network (testnet) where the rypcents 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 lcryp-cli, lcrypd or lcryp-qt or add testnet=1 to your lcryp.conf file as described earlier.

Regtest Mode

For situations where interaction with random peers and blocks is unnecessary or unwanted, LcRyp 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 lcrypd.

> lcrypd -regtest -daemon
LcRyp server starting

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

## LcRyp Core and earlier
lcryp-cli -regtest setgenerate true 101

## LcRyp Core 17.1 and earlier
lcryp-cli -regtest generate 101

## LcRyp Core 18.0 and later
lcryp-cli -regtest generatetoaddress 101 $(lcryp-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. Because this is a new block chain using LcRyp’s default rules, the first blocks pay a block reward of 50 lcryps. Unlike mainnet, in regtest mode only the first 150 blocks pay a reward of 50 lcryps. However, a block must have 100 confirmations before that reward can be spent, so we generate 101 blocks to get access to the coinbase transaction from block #1.

lcryp-cli -regtest getbalance
50.00000000

Verify that we now have 50 lcryps available to spend.

You can now use LcRyp Core RPCs prefixed with lcryp-cli -regtest.

Regtest wallets and block chain state (chainstate) are saved in the regtest subdirectory of the LcRyp Core configuration directory. You can safely delete the regtest subdirectory and restart LcRyp 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.)