Пример #1
0
def test_status_codes(doggo_proxy, default_http_client: DefaultHTTPClient,
                      http_doggo_url: str):
    patch_on_http_response(default_http_client, abort_on=[404])
    default_http_client.get(http_doggo_url)
    assert default_http_client.last_response.status_code == 200
    default_http_client.get(http_doggo_url[:-1])
    assert default_http_client.last_response.status_code == 404
Пример #2
0
def test_cheating_client(
    doggo_proxy,
    web3,
    default_http_client: DefaultHTTPClient,
    wait_for_blocks,
    http_doggo_url: str,
):
    patch_on_http_response(default_http_client, abort_on=[502])
    balance = web3.eth.getBalance(doggo_proxy.channel_manager.receiver)
    assert balance > 0
    # remove all receiver's eth
    web3.eth.sendTransaction({
        'from': doggo_proxy.channel_manager.receiver,
        'to': FAUCET_ADDRESS,
        'value': balance - 90000
    })
    wait_for_blocks(1)
    default_http_client.get(http_doggo_url)
    # proxy is expected to return 502 - it has no funds
    assert default_http_client.last_response.status_code == 502
    web3.eth.sendTransaction({
        'from': FAUCET_ADDRESS,
        'to': doggo_proxy.channel_manager.receiver,
        'value': balance
    })
    wait_for_blocks(1)
    default_http_client.get(http_doggo_url)
    # now it should proceed normally
    assert default_http_client.last_response.status_code == 200
Пример #3
0
def test_status_codes(
        doggo_proxy,
        session: Session,
        http_doggo_url: str
):
    patch_on_http_response(session, abort_on=[404])
    session.get(http_doggo_url)
    assert session.last_response.status_code == 200
    session.get(http_doggo_url[:-1])
    assert session.last_response.status_code == 404
Пример #4
0
def test_status_codes(doggo_proxy, default_http_client):
    patch_on_http_response(default_http_client, abort_on=[404])
    default_http_client.run('doggo.jpg')
    assert default_http_client.last_response.status_code == 200
    default_http_client.run('does-not-exist')
    assert default_http_client.last_response.status_code == 404