Create your own private testnet docker container
Host should already have docker installed
$ apt install make guile-2.2 libgc-dev
Built image will be tagged testnet-box
$ make docker-build
docker-temp
will be removed on exit
$ make docker-temp
docker-run
will leave the container after exit to be resumed later
$ make docker-run
docker-rm
can be used to remove existing container named testnet-box
$ make docker-rm
This will start up two nodes using the two datadirs 1
and 2
. They
will only connect to each other in order to remain an isolated private testnet.
Two nodes are provided, as one is used to generate blocks and it's balance
will be increased as this occurs (imitating a miner). You may want a second node
where this behavior is not observed.
Node 1
will listen on port 19000
, allowing node 2
to connect to it.
Node 1
will listen on port 19001
and node 2
will listen on port 19011
for the JSON-RPC server.
$ make start
$ make getinfo
coin-cli -datadir=1 -getinfo
{
"version": 219900,
"blocks": 0,
"headers": 0,
"verificationprogress": 1,
"timeoffset": 0,
"connections": {
"in": 1,
"out": 0,
"total": 1
},
"proxy": "",
"difficulty": 1.52587890625e-05,
"chain": "main",
"relayfee": 0.00001000,
"warnings": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
}
coin-cli -datadir=2 -getinfo
{
"version": 219900,
"blocks": 0,
"headers": 0,
"verificationprogress": 1,
"timeoffset": 0,
"connections": {
"in": 0,
"out": 1,
"total": 1
},
"proxy": "",
"difficulty": 1.52587890625e-05,
"chain": "main",
"relayfee": 0.00001000,
"warnings": "This is a pre-release test build - use at your own risk - do not use for mining or merchant applications"
}
coin-cli -datadir=1 createwallet wallet1
coin-cli -datadir=2 createwallet wallet2
Normally on the live, real, network, blocks are generated, on average, every 15 seconds. Since this testnet-in-box uses a private network, we are able to generate a block instantly using a simple command.
To generate a block:
$ make generate
To generate more than 1 block:
$ make generate BLOCKS=10
$ make generate BLOCKS=200
$ make getinfo
$ make address2
To send coin that you've generated to the second wallet: (be sure to change the ADDRESS value below to wallet address generated in the prior command)
$ make sendfrom1 ADDRESS=dyq1... AMOUNT=10
Run the getinfo command again. Does the balance show up? Why not?
$ make getinfo
$ make generate
$ make stop
To clean up any files created while running the testnet and restore to the original state:
$ make clean