Fake RPC Server for Testing

Dependencies

Please follow the guide for multi-node testnet. And do add the --mainnet-url option to specifiy a bitcoincashnode's RPC endpoint, which can be a real one or a fake one, just as following:
1
./smartbchd start --mainnet-url=http://node-ip-address:port-number
Copied!

Running a Fake RPC Server for Testing

The bchnode tool mimics a real bitcoincashnode's RPC behavior. You can use it with the following steps:

Start the bchnode RPC Server

1
Git clone https://github.com/smartbch/testkit.git
2
cd bchnode
3
go run main.go &
Copied!

Add a New Validator's public key and voting power

The format is pubkey-votingPower-action, where the action can be "add", "edit" or "retire".
1
cd scripts ;# there are some utility scripts in the directory testkit/bchnode/scripts
2
./pubkey.sh eeed4fae3da010e393efed2aacd271971fd2383fc68109a475d6c9ef65435d52-9-add
Copied!
The bchnode produces blocks with fixed interval (default is 3 seconds) to vote for the validators.

Adjust block interval

To change the block interval to 10 seconds:
1
./interval.sh 10
Copied!

Simulate a Block Reorg

1
./reorg.sh
Copied!
The bchnode will simulate a fork at the height which is 8 blocks less than current height, and re-generate the recent 8 blocks.

The Suggested Scenarios for Test

  1. 1.
    Configure bchnode to follow the voting power and pubkeys specified in genesis.json
  2. 2.
    Keep the current voting power and pubkeys for three epochs.
  3. 3.
    Change the voting power setting of bchnode, such that at new epochs, the smartbchd follows the new voting power.
  4. 4.
    Run block reorg at bchnode, and smartbchd can work normally.
  5. 5.
    Add new validators in and let bchnode vote them to be active.
  6. 6.
    Restart smartbchd and it can also work fine.

smartBCH parameters for testing with bchnode

1
NumBlocksInEpoch int64 = 30
2
NumBlocksToClearMemory int64 = 1000s
3
WaitingBlockDelayTime int64 = 2s
4
SwitchEpochDelayTime int64 = 10s
5
MinVotingPercentPerEpoch = 10 //10 percent in NumBlocksInEpoch, like 2016 / 10 = 201
6
MinVotingPubKeysPercentPerEpoch = 34 //34 percent in active validators,
Copied!
Last modified 4mo ago