Exemple #1
0
    enckey=enckey,
    name='target',
)

print('Wait for transaction', txid)
wait_for_tx(rpc, txid)

print('Wait 3 blocks for validators to take effect')
wait_for_blocks(rpc, 3)

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

############## non-live and wait for cleanup ##################

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

rpc.wallet.sync(enckey=enckey, name='target')
print('state before cleanup', rpc.staking.state(addr, name='target'))

wait_for_blocktime(rpc, latest_block_time(rpc) + 18)
rpc.wallet.sync(enckey=enckey, name='target')
state = rpc.staking.state(addr, name='target')
print('state', state)
assert state.get('node_meta') is None
Exemple #2
0
bonded_staking = rpc.address.list()[0]

# first reward distribution
# minted = 6978080000
minted = monetary_expansion(init_bonded * 2, 145000000000000000)

state = rpc.chain.staking(bonded_staking, height=2)
assert int(state['bonded']) == init_bonded + minted // 2

enckey2 = rpc2.wallet.enckey()
bonded_staking2 = rpc2.address.list(enckey=enckey2)[0]

state = rpc.chain.staking(bonded_staking2, height=2)
bonded_rewarded = init_bonded + minted // 2
last_bonded = int(state['bonded'])
block_time = latest_block_time(rpc)

if last_bonded == bonded_rewarded:
    # wait for it to get jailed and slashed later
    wait_for_blocks(rpc, 6)

    # jailed and slashed
    slashed = int(last_bonded * 0.2)
    state = rpc.chain.staking(bonded_staking2)
    assert int(
        state['bonded']
    ) == last_bonded - slashed, 'incorrect bonded: %s' % state['bonded']
    last_bonded = int(state['bonded'])
else:
    # already jailed
    slashed = int(init_bonded * 0.2)