예제 #1
0
- Two nodes, each with half power

Procedure:
- stop node1
- send tx to node0
- start node1
- repeat above
- test wallet sync
'''


supervisor = UnixStreamXMLRPCClient('data/supervisor.sock')
rpc = get_rpc()

print('Wait for 2 validators online')
wait_for_validators(rpc, 2)

os.environ['ENCKEY'] = rpc.wallet.enckey()

print('Prepare node0 transfer addresses')

enckey = rpc.wallet.enckey()
unbonded = rpc.address.list()[1]
transfer1 = rpc.address.list(type='transfer')[0]


txid = rpc.staking.withdraw_all_unbonded(unbonded, transfer1, enckey=enckey)
wait_for_tx(rpc, txid)
rpc.wallet.sync()

addresses = [rpc.address.create(type='transfer') for i in range(10)]
예제 #2
0
# keep these values same as jail_cluster.json
TARGET_NODE = 'node2'
TARGET_NODE_MNEMONIC = 'symptom labor zone shrug chicken bargain hood define tornado mass inquiry rural step color guitar'
TARGET_NODE_VALIDATOR_SEED = '5c1b9c06ae7485cd0f9d75819f964db3b1306ebd397f5bbdc1dd386a32b7c1c0'
MISSED_BLOCK_THRESHOLD = 5
JAIL_DURATION = 10
BASE_PORT = int(os.environ.get('BASE_PORT', 25560))
TARGET_PORT = BASE_PORT + 2 * 10

supervisor = UnixStreamXMLRPCClient('data/supervisor.sock')
rpc = RPC(BASE_PORT)

# wait for 3 validators online
print('Wait for 3 validators online')
wait_for_validators(rpc, 3)

enckey = rpc.wallet.restore(TARGET_NODE_MNEMONIC, name='target')

print('Stop', TARGET_NODE)
stop_node(supervisor, TARGET_NODE)

print('Waiting for', MISSED_BLOCK_THRESHOLD + 3, 'blocks')
wait_for_blocks(rpc, MISSED_BLOCK_THRESHOLD + 3)

assert len(rpc.chain.validators()['validators']) == 2

addr = rpc.address.list(enckey=enckey, name='target')[0]
state = rpc.staking.state(addr)
punishment = state['last_slash']
print('punishment', punishment)
예제 #3
0
# keep these values same as jail_cluster.json
VALIDATOR_SEED = '3d96c3c476e463bdcd751c9bf1715b7da37229ac00be33f34496797ca892b68a'

BASE_PORT = int(os.environ.get('BASE_PORT', 26650))
supervisor = UnixStreamXMLRPCClient('data/supervisor.sock')
rpc = get_rpc()
# wait for at least one block generated
wait_for_blocks(rpc, 1, height=0)

# stop node1
print('Stop node1')
stop_node(supervisor, 'node1')

print('Wait for 1 validators online')
wait_for_validators(rpc, 1)

enckey = rpc.wallet.enckey()
os.environ['ENCKEY'] = enckey
bonded_staking, unbonded_staking = rpc.address.list()[:2]
transfer = rpc.address.list(type='transfer')[0]

txid = rpc.staking.withdraw_all_unbonded(unbonded_staking, transfer)
wait_for_tx(rpc, txid)
rpc.wallet.sync()

txid = rpc.staking.deposit(bonded_staking, [{'id': txid, 'index': 0}])
wait_for_tx(rpc, txid)
rpc.wallet.sync()

wait_for_blocks(rpc, 3)