-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added RegressionTestAnyHost. This allows sync peers from non-local host. This is useful when using docker for regtest setups. * added RegressionTestNoReset. This allows user to keep the previous regtest blockchain db instead of deleting after each restart. * updated sample-bchd.conf with the 2 new options * added ./bchrpc/regtest/tools with instructions on how to perform observation using regtest network and docker
- Loading branch information
Showing
14 changed files
with
90 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Regtest tools | ||
|
||
Methods and commands that allow additional observation while debugging node behavior can be placed here. These tools are intended to be run on an ad-hoc basis separate from the tests located in the test folder. | ||
|
||
## Interaction with bchd3 | ||
The docker-compose regtest network with 2 connected nodes, which can be started using `$ docker-compose up -d` from the regtest directory. A third node, `bchd3` is intended to be interacted with directly using `$ docker-compose exec bchd3 bash`, you can start and stop the node as needed for observational purposes during a debug session. | ||
|
||
### Example commands for bchd3 interaction | ||
|
||
* Start node 3 with no indexes: `bchd --regtest --rpcuser=bitcoin --rpcpass=password --notls --addpeer=bchd1 --regtestanyhost` | ||
* Start node 3 with all indexes: `bchd --regtest --rpcuser=bitcoin --rpcpass=password --notls --addpeer=bchd1 --regtestanyhost --regtestnoreset --txindex --slpindex --addrindex` | ||
* Get node 3 peer info: `bchctl -u=bitcoin -P=password --rpcserver=localhost:18334 --notls getpeerinfo` | ||
|
||
**Note:** The flag `--regtestanyhost` allows node 3 to connect to the other peers on the docker network. Without this the node won't sync to non-localhost peers in the docker-compose network. The flag `--regtestnoreset` prevents deletion of regtest blockchain data from previous runs. By default, regtest data dir is reset at node startup. | ||
|
||
## ./tools/Generator.ts | ||
|
||
This script keeps `bchd2` node actively generating one block per second for 1000 blocks. | ||
|
||
Example usage: | ||
|
||
1. Make sure the regtest network is running via `$ docker-compose up -d` (must cd into the regtest directory) | ||
2. Start the generator script via `$ npx ts-node ./tools/generator.ts`. This will run until all 1000 blocks are generated. | ||
3. Shell into the `bchd3` container and start, stop, or inspect the node as required for observation. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { createRpcClient, sleep } from '../lib/utils'; | ||
|
||
// setup RPC clients (used primarily for generating blocks only) | ||
const bchd2Rpc = createRpcClient(); | ||
|
||
// use a floating promise to generate 1 block each second | ||
(async () => { | ||
let counter = 0; | ||
while (counter < 1000) { | ||
counter++; | ||
await bchd2Rpc.generate(1); | ||
await sleep(1000); | ||
} | ||
})(); |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -42,4 +42,6 @@ type Config struct { | |
MinSyncPeerNetworkSpeed uint64 | ||
|
||
FastSyncMode bool | ||
|
||
RegTestSyncAnyHost bool | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters