Example testing/transaction updates

- Convert bitcoin -> dash
 - Complete testing section
 - Update transaction simple spending example

Added script to run through simple spending example on regtest
This commit is contained in:
thephez 2017-12-11 17:06:13 -05:00
parent 822098b5a1
commit 21cd8094d0
5 changed files with 239 additions and 164 deletions

View file

@ -7,9 +7,11 @@ http://opensource.org/licenses/MIT.
## Testing Applications
{% include helpers/subhead-links.md %}
<!-- __ -->
{% autocrossref %}
Bitcoin Core provides testing tools designed to let developers
Dash Core provides testing tools designed to let developers
test their applications with reduced risks and limitations.
{% endautocrossref %}
@ -19,18 +21,26 @@ test their applications with reduced risks and limitations.
{% autocrossref %}
When run with no arguments, all Bitcoin Core programs default to Bitcoin's main
When run with no arguments, all Dash Core programs default to Dash's main
network ([mainnet][/en/glossary/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
it's safer and cheaper to use Dash's test network (testnet)
where the duffs 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`<!--noref--> with `bitcoin-cli`, `bitcoind` or `bitcoin-qt` or add
`testnet=1`<!--noref--> to your `bitcoin.conf` file as [described earlier][bitcoind initial setup]. 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.
To use testnet, use the argument `-testnet`<!--noref--> with `dash-cli`, `dashd`
or `dash-qt` or add `testnet=1`<!--noref--> to your `dash.conf` file as
[described earlier][dashd initial setup]. To get free duffs for testing,
check the faucets listed below. They are community supported and due to
potentially frequent Testnet changes, one or more of them may be unavailable at
a given time:
* [Testnet Faucet - Dash.org]
* [Testnet Faucet - Masternode.io]
* [Testnet Faucet - Dashninja.pl]
Testnet is a public resource provided for free by members of the community,
so please don't abuse it.
{% endautocrossref %}
@ -39,45 +49,41 @@ community, so please don't abuse it.
{% autocrossref %}
For situations
where interaction with random peers and blocks is unnecessary or
unwanted, Bitcoin Core's regression test mode (regtest mode) lets you
For situations where interaction with random peers and blocks is unnecessary or
unwanted, Dash 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 bitcoind][bitcoind initial setup].
environment after you first [configure dashd][dashd initial setup].
{% endautocrossref %}
{% highlight bash %}
> bitcoind -regtest -daemon
Bitcoin server starting
> dashd -regtest -daemon
Dash Core server starting
{% endhighlight %}
{% autocrossref %}
Start `bitcoind` in regtest mode to create a private block chain.
Start `dashd` in regtest mode to create a private block chain.
{% endautocrossref %}
~~~
## Bitcoin Core 0.10.1 and earlier
bitcoin-cli -regtest setgenerate true 101
## Bitcoin Core master (as of commit 48265f3)
bitcoin-cli -regtest generate 101
## Dash Core
dash-cli -regtest generate 101
~~~
{% autocrossref %}
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 Bitcoin's default
rules, the first blocks pay a block reward of 50 bitcoins. Unlike
mainnet, in regtest mode only the first 150 blocks pay a reward of 50 bitcoins.
a generic PC. Because this is a new block chain using Dash's default
rules, the first blocks pay a block reward of 500 dash. Unlike
mainnet, in regtest mode only the first 150 blocks pay a reward of 500 dash.
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.
@ -85,19 +91,19 @@ transaction from block #1.
{% endautocrossref %}
{% highlight bash %}
bitcoin-cli -regtest getbalance
50.00000000
dash-cli -regtest getbalance
500.00000000
{% endhighlight %}
{% autocrossref %}
Verify that we now have 50 bitcoins available to spend.
Verify that we now have 500 dash available to spend.
You can now use Bitcoin Core RPCs prefixed with `bitcoin-cli -regtest`<!--noref-->.
You can now use Dash Core RPCs prefixed with `dash-cli -regtest`<!--noref-->.
Regtest wallets and block chain state (chainstate) are saved in the `regtest`<!--noref-->
subdirectory of the Bitcoin Core configuration directory. You can safely
delete the `regtest`<!--noref--> subdirectory and restart Bitcoin Core to
subdirectory of the Dash Core configuration directory. You can safely
delete the `regtest`<!--noref--> subdirectory and restart Dash 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.)