def test_transacting_with_contract_with_arguments(web3_tester, math_contract):
    initial_value = math_contract.call().counter()

    # workaround for bug in eth-tester-client.  The first real transaction
    # after a `.call(..)` doesn't get registered correctly with the test EVM.
    from testrpc import testrpc
    testrpc.evm_mine()

    txn_hash = math_contract.transact().increment(5)
    txn_receipt = web3_tester.eth.getTransactionReceipt(txn_hash)
    assert txn_receipt is not None

    final_value = math_contract.call().counter()

    assert final_value - initial_value == 5
Exemplo n.º 2
0
def setup_tester_rpc_provider():
    from testrpc import testrpc

    from web3.web3.rpcprovider import TestRPCProvider
    port = get_open_port()
    provider = TestRPCProvider(port=port)

    testrpc.full_reset()
    testrpc.rpc_configure('eth_mining', False)
    testrpc.rpc_configure('eth_protocolVersion', '0x3f')
    testrpc.rpc_configure('net_version', 1)
    testrpc.evm_mine()

    wait_for_http_connection(port)
    yield provider
    provider.server.shutdown()
    provider.server.server_close()
Exemplo n.º 3
0
    def __enter__(self):
        if self._running:
            raise ValueError("The TesterChain is already running")

        if self.port is None:
            self.port = get_open_port()

        self.provider = TestRPCProvider(port=self.port)

        testrpc.full_reset()
        testrpc.rpc_configure('eth_mining', False)
        testrpc.rpc_configure('eth_protocolVersion', '0x3f')
        testrpc.rpc_configure('net_version', 1)
        testrpc.evm_mine()

        wait_for_connection('127.0.0.1', self.port)
        self._running = True
        return self
Exemplo n.º 4
0
def web3_tester_provider():
    from testrpc import testrpc

    from web3.providers.rpc import TestRPCProvider
    port = get_open_port()
    provider = TestRPCProvider(port=port)

    testrpc.full_reset()
    testrpc.rpc_configure('eth_mining', False)
    testrpc.rpc_configure('eth_protocolVersion', '0x3f')
    testrpc.rpc_configure('net_version', 1)
    testrpc.evm_mine()

    provider.testrpc = testrpc
    wait_for_http_connection(port)

    yield provider

    provider.server.stop()
    provider.server.close()
    provider.thread.kill()