Exemple #1
0
def test_oracle_registration():
    client = EpochClient()
    weather_oracle = WeatherOracle(
        query_format="{'city': str}",
        response_format="{'temp_c': int}",
        default_query_fee=0,
        default_fee=10,
        default_ttl=50,
        default_query_ttl=2,
        default_response_ttl=2,
    )
    client.register_oracle(weather_oracle)
    client.listen_until(weather_oracle.is_ready, timeout=5)
    assert weather_oracle.oracle_id is not None
Exemple #2
0
def test_oracle_query_received():
    client = EpochClient()
    weather_oracle = WeatherOracle(
        query_format="{'city': str}",
        response_format="{'temp_c': int}",
        default_query_fee=0,
        default_fee=10,
        default_ttl=50,
        default_query_ttl=2,
        default_response_ttl=2,
    )
    client.register_oracle(weather_oracle)
    client.listen_until(weather_oracle.is_ready, timeout=5)
    weather_query = WeatherQuery(
        oracle_pubkey=weather_oracle.oracle_id,
        query_fee=0,
        fee=10,
        query_ttl=2,
        response_ttl=2,
    )
    client.mount(weather_query)
    weather_query.query("{'city': 'Berlin'}")
    client.listen_until(lambda: weather_query.response_received, timeout=5)