def test_get_code(client, hex_accounts):
    txn_hash = client.send_transaction(
        _from=hex_accounts[0],
        data=CONTRACT_BIN,
        value=1234,
    )
    txn_receipt = client.get_transaction_receipt(txn_hash)
    contract_address = txn_receipt['contractAddress']

    assert contract_address

    code = client.get_code(contract_address)
    assert force_bytes(code) == force_bytes(CONTRACT_BIN_RUNTIME)
Exemple #2
0
def test_get_code(client, hex_accounts):
    txn_hash = client.send_transaction(
        _from=hex_accounts[0],
        data=CONTRACT_BIN,
        value=1234,
    )
    txn_receipt = client.get_transaction_receipt(txn_hash)
    contract_address = txn_receipt['contractAddress']

    assert contract_address

    code = client.get_code(contract_address)
    assert force_bytes(code) == force_bytes(CONTRACT_BIN_RUNTIME)
def test_new_filter_with_topic_filter_on_indexed_arg(client,
                                                     client_call_emitter,
                                                     Events,
                                                     LogFunctions,
                                                     LogTopics):
    filter_id = client.new_filter(from_block="earliest", to_block="latest", address=[], topics=[])

    txn_hash = client_call_emitter(
        LogFunctions.logSingle,
        [Events.LogSingleWithIndex, 1234567890],
    )

    changes = client.get_filter_changes(filter_id)

    assert len(changes) == 1
    log_entry = changes[0]

    assert LogTopics.LogSingleWithIndex in log_entry['topics']
    assert force_bytes(encode_number(1234567890, 32)) in log_entry['topics']
Exemple #4
0
def test_new_filter_with_topic_filter_on_indexed_arg(client,
                                                     client_call_emitter,
                                                     Events, LogFunctions,
                                                     LogTopics):
    filter_id = client.new_filter(from_block="earliest",
                                  to_block="latest",
                                  address=[],
                                  topics=[])

    txn_hash = client_call_emitter(
        LogFunctions.logSingle,
        [Events.LogSingleWithIndex, 1234567890],
    )

    changes = client.get_filter_changes(filter_id)

    assert len(changes) == 1
    log_entry = changes[0]

    assert LogTopics.LogSingleWithIndex in log_entry['topics']
    assert force_bytes(encode_number(1234567890, 32)) in log_entry['topics']
def test_eth_getCode(rpc_client, accounts):
    txn_hash = rpc_client(
        method="eth_sendTransaction",
        params=[{
            "from": accounts[0],
            "data": CONTRACT_BIN,
            "value": 1234,
        }],
    )
    txn_receipt = rpc_client(
        method="eth_getTransactionReceipt",
        params=[txn_hash],
    )
    contract_address = txn_receipt['contractAddress']

    assert contract_address

    contract_code = rpc_client(
        method="eth_getCode",
        params=[contract_address],
    )

    assert force_bytes(contract_code) == CONTRACT_BIN_RUNTIME
Exemple #6
0
def test_get_code_non_contract(client, hex_accounts):
    code = client.get_code('0xd3cda913deb6f67967b99d67acdfa1712c293601')
    assert force_bytes(code) == b'0x'
def test_force_bytes(input, expected):
    actual = force_bytes(input)
    assert is_binary(actual)
    assert actual == expected
Exemple #8
0
def event_topic(event_signature):
    return encode_data(sha3(force_bytes(event_signature)))
def test_force_bytes(input, expected):
    actual = force_bytes(input)
    assert is_binary(actual)
    assert actual == expected
def test_get_code_non_contract(client, hex_accounts):
    code = client.get_code('0xd3cda913deb6f67967b99d67acdfa1712c293601')
    assert force_bytes(code) == b'0x'