Ejemplo n.º 1
0
def test_next_nonce(delegate, identity_contract, accounts, owner_key):

    source = identity_contract.address
    destination = accounts[3]

    meta_transaction = MetaTransaction(from_=source,
                                       to=destination,
                                       value=123,
                                       nonce=delegate.calc_next_nonce(source))
    signed_meta_transaction = meta_transaction.signed(owner_key)

    assert delegate.calc_next_nonce(source) == 1
    delegate.send_signed_meta_transaction(signed_meta_transaction)
    assert delegate.calc_next_nonce(source) == 2

    meta_transaction = MetaTransaction(from_=source,
                                       to=destination,
                                       value=123,
                                       nonce=delegate.calc_next_nonce(source))
    signed_meta_transaction = meta_transaction.signed(owner_key)

    assert delegate.calc_next_nonce(source) == 2
    delegate.send_signed_meta_transaction(signed_meta_transaction)
    assert delegate.calc_next_nonce(source) == 3
Ejemplo n.º 2
0
def test_delegate_meta_transaction(delegate, identity, web3, accounts,
                                   owner_key):
    """"
    Tests that a transaction is sent by the delegate upon receiving a meta-transaction.
    """

    meta_transaction = MetaTransaction(
        from_=identity.address,
        to=accounts[2],
        value=123,
        data=(1234).to_bytes(10, byteorder="big"),
        nonce=1,
        extra_data=(123456789).to_bytes(10, byteorder="big"),
    )

    signed_meta_transaction = meta_transaction.signed(owner_key)

    tx_hash = delegate.send_signed_meta_transaction(signed_meta_transaction)
    tx = web3.eth.getTransaction(tx_hash)

    assert tx["from"] == web3.eth.coinbase
    assert HexBytes(tx["to"]) == identity.address