Ejemplo n.º 1
0
def userB_has_some_amount_of_eth_in_plasma_cash(context, amount):
    client = Client(container.get_root_chain(), container.get_child_chain_client(), userB_key)
    block = client.get_block(TRANSFER_TX_BLOCK)
    tx = block.get_tx_by_uid(uid)
    assert tx.amount == amount, 'tx.amount {} != amount: {}'.format(tx.amount, amount)

    assert_msg = 'tx.new_owner {} not same address as userB: {}'.format(tx.new_owner.hex(), userB)
    assert address_equals(tx.new_owner.hex(), userB), assert_msg
def then_root_chain_cancels_the_challenge(context):
    client = Client(container.get_root_chain(),
                    container.get_child_chain_client(), userD_key)
    deposit_block = client.get_block(DEPOSIT_TX_BLOCK)
    deposit_tx = deposit_block.get_tx_by_uid(uid)

    root_chain = container.get_root_chain()
    assert not root_chain.functions.isChallengeExisted(
        uid, rlp.encode(deposit_tx)).call({'from': userD})
def userD_responds_to_the_history_challenge(context):
    client = Client(container.get_root_chain(),
                    container.get_child_chain_client(), userD_key)
    deposit_block = client.get_block(DEPOSIT_TX_BLOCK)
    deposit_tx = deposit_block.get_tx_by_uid(uid)

    client.respond_challenge_exit(rlp.encode(deposit_tx),
                                  uid,
                                  tx_blk_num=TRANSFER_TX_1_BLOCK)
    time.sleep(5)
Ejemplo n.º 4
0
def userC_starts_to_exit_some_eth_from_plasma_cash(context, amount):
    client = Client(container.get_root_chain(),
                    container.get_child_chain_client(), userC_key)

    deposit_block = client.get_block(DEPOSIT_TX_BLOCK)
    deposit_tx = deposit_block.get_tx_by_uid(uid)
    deposit_block.merklize_transaction_set()
    deposit_tx_proof = deposit_block.merkle.create_merkle_proof(uid)

    # invalid tx doesn't exist in child chain
    invalid_tx = Transaction(DEPOSIT_TX_BLOCK, uid, 1,
                             utils.normalize_address(userC))
    invalid_tx.sign(utils.normalize_key(userA_key))
    invalid_tx_merkle = SparseMerkleTree(257, {uid: invalid_tx.merkle_hash})
    invalid_tx_proof = invalid_tx_merkle.create_merkle_proof(uid)

    root_chain = container.get_root_chain()
    root_chain.functions.startExit(
        rlp.encode(deposit_tx), deposit_tx_proof, DEPOSIT_TX_BLOCK,
        rlp.encode(invalid_tx), invalid_tx_proof,
        TRANSFER_TX_2_BLOCK).transact({'from': userC})
    time.sleep(5)