コード例 #1
0
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)
assert punishment['kind'] == 'NonLive'
print('slash amount', punishment['amount'])

print('Starting', TARGET_NODE)
supervisor.supervisor.startProcessGroup(TARGET_NODE)
wait_for_port(TARGET_PORT + 9)
print('Started', TARGET_NODE)

jailed_until = state['validator']['jailed_until']
assert jailed_until is None, 'NonLive fault is not jailed'

print('Join', TARGET_NODE)
txid = rpc.staking.join(
    TARGET_NODE,
    SigningKey(TARGET_NODE_VALIDATOR_SEED).pub_key_base64(),
    addr,
    enckey=enckey,
    name='target',
)

print('Wait for transaction', txid)
コード例 #2
0
ファイル: byzantine_test.py プロジェクト: lezzokafka/thaler
print('Join node0')
txid = rpc.staking.join(
    'node0',
    SigningKey(VALIDATOR_SEED).pub_key_base64(),
    bonded_staking,
    rpc.staking.gen_keypackage(),
)

wait_for_tx(rpc, txid)

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

# start node1
supervisor.supervisor.startProcessGroup('node1')
wait_for_port(BASE_PORT + 10 + 7)

wait_for_blocks(rpc, 13)
rpc.wallet.sync()
state = rpc.staking.state(bonded_staking)
assert state['node_meta']['CouncilNode']['jailed_until'] is not None, 'jailed for byzantine fault'
punishment = state['last_slash']
print('punishment', punishment)
assert punishment['kind'] == 'ByzantineFault'

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

stop_node(supervisor, 'node1')
print('Wait until jailed_until', state['node_meta']['CouncilNode']['jailed_until'])
wait_for_blocktime(rpc, state['node_meta']['CouncilNode']['jailed_until'])