mirror of
https://github.com/seigler/dash-docs
synced 2025-07-28 10:16:15 +00:00
Create a "Testing Applications" subsection in devel-examples
Move existing "regtest / testnet" texts to the new subsection and link to it Move Bitcoin Core setup instructions in devel-examples Add a consistent introduction for devel-(guide/ref/examples) Fix autocrossref.rb to not add links inside {% highlight %} code blocks
This commit is contained in:
parent
8a5db84a80
commit
ffed3c2529
12 changed files with 187 additions and 125 deletions
91
_includes/example_testing.md
Normal file
91
_includes/example_testing.md
Normal file
|
@ -0,0 +1,91 @@
|
|||
## Testing Applications
|
||||
|
||||
{% autocrossref %}
|
||||
|
||||
Bitcoin Core provides testing tools designed to let developers
|
||||
test their applications with reduced risks and limitations.
|
||||
|
||||
{% endautocrossref %}
|
||||
|
||||
### Testnet
|
||||
|
||||
{% autocrossref %}
|
||||
|
||||
When run with no arguments, all Bitcoin Core programs default to Bitcoin's main
|
||||
network ([mainnet][mainnet]{:#term-mainnet}{:.term}). However, for development,
|
||||
it's safer and cheaper to use Bitcoin's test network (testnet)
|
||||
where the satoshis 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 `bitcoin-cli`, `bitcoind` or `bitcoin-qt` or add
|
||||
<!--[-->`testnet=1`<!--]--> to your `bitcoin.conf` file. To get
|
||||
free satoshis 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.
|
||||
|
||||
{% endautocrossref %}
|
||||
|
||||
### Regtest Mode
|
||||
|
||||
{% autocrossref %}
|
||||
|
||||
For situations
|
||||
where interaction with random peers and blocks is unnecessary or
|
||||
unwanted, Bitcoin 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.
|
||||
|
||||
{% endautocrossref %}
|
||||
|
||||
{% highlight bash %}
|
||||
> bitcoind -regtest -daemon
|
||||
Bitcoin server starting
|
||||
{% endhighlight %}
|
||||
|
||||
{% autocrossref %}
|
||||
|
||||
Start `bitcoind` in regtest mode to create a private block chain.
|
||||
|
||||
{% endautocrossref %}
|
||||
|
||||
~~~
|
||||
bitcoin-cli -regtest setgenerate true 101
|
||||
~~~
|
||||
|
||||
{% autocrossref %}
|
||||
|
||||
Generate 101 blocks using a special version of the `setgenerate` RPC
|
||||
which is only available in regtest mode. This takes about 30 seconds on
|
||||
a generic PC. Because this is a new block chain using Bitcoin's default
|
||||
rules, the first 210,000 blocks pay a block reward of 50 bitcoins.
|
||||
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.
|
||||
|
||||
{% endautocrossref %}
|
||||
|
||||
{% highlight bash %}
|
||||
bitcoin-cli -regtest getbalance
|
||||
50.00000000
|
||||
{% endhighlight %}
|
||||
|
||||
{% autocrossref %}
|
||||
|
||||
Verify that we now have 50 bitcoins available to spend.
|
||||
|
||||
You can now use Bitcoin Core RPCs prefixed with <!--[-->`bitcoin-cli -regtest`<!--]-->.
|
||||
|
||||
Regtest wallets and block chain state (chainstate) are saved in the <!--[-->`regtest`<!--]-->
|
||||
subdirectory of the Bitcoin Core configuration directory. You can safely
|
||||
delete the <!--[-->`regtest`<!--]--> subdirectory and restart Bitcoin Core to
|
||||
start a new regtest. (See the [Developer Examples Introduction][devexamples] for default
|
||||
configuration directory locations on various operating systems. Always back up
|
||||
mainnet wallets before performing dangerous operations such as deleting.)
|
||||
|
||||
{% endautocrossref %}
|
Loading…
Add table
Add a link
Reference in a new issue