Testing Applications

BitcoinEvo Core comes with tools specifically designed to help developers safely test their applications with minimized risks.

Testnet

By default, when running BitcoinEvo Core programs without any arguments, they will operate on BitcoinEvo’s primary network (mainnet). However, for development purposes, it’s safer and more cost-effective to use BitcoinEvo’s test network (testnet), where the satoshis used hold no real-world value. Additionally, testnet relaxes certain restrictions (such as standard transaction validation) allowing you to test functions that may not be available on mainnet by default.

To access testnet, you can either use the argument -testnet with bitcoinevo-cli, bitcoinevod, or bitcoinevo-qt, or add testnet=1 to your bitcoinevo.conf file as mentioned previously. Testnet is a shared community resource offered for free, so please be considerate and avoid overuse.

RegTest Mode

If you don’t need interaction with external peers or blocks, BitcoinEvo Core’s regression test mode (regtest mode) allows you to generate a new private blockchain instantly, maintaining testnet’s basic rules, but with one key difference: you decide when to create new blocks, giving you total control over the test environment.

Many developers favor regtest mode as the optimal way to build and test applications. The example below shows how to set up a regtest environment once you’ve configured bitcoinevod.

bitcoinevod -regtest -daemon
BitcoinEvo server starting

This starts bitcoinevod in regtest mode, establishing a private blockchain.

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

This command generates 101 blocks using a special RPC, which is only available in regtest mode. On a typical computer, this process completes in less than a second. Since the blockchain is new and adheres to BitcoinEvo’s default rules, the initial blocks generate a block reward of 50 bitcoinevos. Unlike mainnet, in regtest mode, only the first 150 blocks provide a reward of 50 bitcoinevos. Additionally, a block must have 100 confirmations before its reward can be spent, which is why 101 blocks are generated — to unlock the coinbase transaction from block #1.

bitcoinevo-cli -regtest getbalance
50.00000000

This confirms that we now have 50 bitcoinevos ready to be spent.

From here, you can start using BitcoinEvo Core RPCs with the prefix bitcoinevo-cli -regtest.

In regtest mode, wallet data and blockchain state (chainstate) are stored in the regtest subdirectory within the BitcoinEvo Core configuration folder. You can safely delete this subdirectory and restart BitcoinEvo Core to reset the regtest environment. (Refer to the Developer Examples Introduction for the default configuration folder paths for different operating systems. Always back up your mainnet wallets before executing risky operations like deleting files.)