コード例 #1
0
def test_verify_unsubmitted_report():
    reports = REQUEST_TEST.reports
    auth = Auth(Client("xxx"))
    assert (auth.verify_unsubmitted_report(
        reports,
        "bandvaloper1yplk6n4wmeaarxp966gukpxupg3jqfcqkh32mw") == False)
    assert (auth.verify_unsubmitted_report(
        reports, "bandvaloper1alzj765pzuhtjkmslme4fdpeakc0036xnyjltn") == True)
コード例 #2
0
def test_verify_requested_validator():
    request = REQUEST_TEST.request
    auth = Auth(Client("xxx"))
    assert (auth.verify_requested_validator(
        request, "bandvaloper1yplk6n4wmeaarxp966gukpxupg3jqfcqkh32mw") == True)
    assert (auth.verify_requested_validator(
        request,
        "bandvaloper1trx2cm6vm9v63grg9uhmk7sy233zve4q25rgre") == False)
    assert (auth.verify_requested_validator(
        request, "bandvaloper1yyv5jkqaukq0ajqn7vhkyhpff7h6e99j3gv0tr") == True)
コード例 #3
0
def get_band_luna_price():
    coinone, bithumb, gdac, gopax = None, None, None, None
    try:
        oracle_script_id, multiplier, min_count, ask_count = [
            int(param, 10) for param in band_luna_price_params.split(",")
        ]
        exchanges = ["coinone", "bithumb", "gdac", "gopax"]
        bandcli = Client(band_endpoint)
        schema = bandcli.get_oracle_script(oracle_script_id).schema
        obi = PyObi(schema)
        result = obi.decode_output(
            bandcli.get_latest_request(
                oracle_script_id,
                obi.encode_input({
                    "exchanges": exchanges,
                    "base_symbol": "LUNA",
                    "quote_symbol": "KRW",
                    "multiplier": multiplier
                }), min_count, ask_count).result.response_packet_data.result)
        abms = []
        for (order_book, ex) in zip(result['order_books'], exchanges):
            abm = None
            if order_book['ask'] > 0 and order_book['bid'] > 0 and order_book[
                    'mid'] > 0:
                luna_price = {
                    "base_currency": "ukrw",
                    "exchange": f"band_{ex}",
                    "askprice": order_book['ask'] / multiplier,
                    "bidprice": order_book['bid'] / multiplier,
                    "midprice": order_book['mid'] / multiplier
                }
                luna_base = "USDKRW"
                luna_midprice_krw = order_book['mid'] / multiplier
                abm = (luna_price, luna_base, luna_midprice_krw)
            abms.append(abm)
        coinone, bithumb, gdac, gopax = abms
    except:
        METRIC_OUTBOUND_ERROR.labels('band-luna').inc()
        logger.exception("Error in get_band_luna_price")

    return coinone, bithumb, gdac, gopax
コード例 #4
0
def pyband_client(_grpc_server, grpc_addr):
    from pyband.proto.cosmos.auth.v1beta1.query_pb2_grpc import add_QueryServicer_to_server as add_cosmos_query

    add_cosmos_query(QueryServicer(), _grpc_server)

    _grpc_server.add_insecure_port(grpc_addr)
    _grpc_server.start()

    from pyband.client import Client

    yield Client(grpc_addr, insecure=True)
    _grpc_server.stop(grace=None)
コード例 #5
0
ファイル: send_tx_test.py プロジェクト: bandprotocol/pyband
def pyband_client(_grpc_server, grpc_addr):
    from pyband.proto.cosmos.tx.v1beta1.service_pb2_grpc import add_ServiceServicer_to_server as add_cosmos_tx

    add_cosmos_tx(CosmosTransactionServicer(), _grpc_server)

    _grpc_server.add_insecure_port(grpc_addr)
    _grpc_server.start()

    from pyband.client import Client

    yield Client(grpc_addr, insecure=True)
    _grpc_server.stop(grace=None)
コード例 #6
0
    "signatures": [
        {
            "signature": "hQpMSSaOVbT5vd3yladNX9RNA9vSq4ts4cPufdoesjUtPje5i73f048MM0xPnAB7JWSRuUSsZD5M6L6WGk3Qkw==",
            "pub_key": {
                "type": "tendermint/PubKeySecp256k1",
                "value": "A/5wi9pmUk/SxrzpBoLjhVWoUeA9Ku5PYpsF3pD1Htm8",
            },
            "account_number": "0",
            "sequence": "1092",
        }
    ],
}

TIMEOUT = 3

client = Client(TEST_RPC, TIMEOUT)


@patch("requests.post")
def test_send_tx_sync_mode_timeout(requests_mock):
    requests_mock.side_effect = ReadTimeout
    with pytest.raises(ReadTimeout):
        res = client.send_tx_sync_mode(TEST_MSG)


@patch("requests.post")
def test_send_tx_block_mode_timeout(requests_mock):
    requests_mock.side_effect = ReadTimeout
    with pytest.raises(ReadTimeout):
        res = client.send_tx_block_mode(TEST_MSG)
コード例 #7
0
    },
    "memo":
    "Memo",
    "signatures": [{
        "signature":
        "hQpMSSaOVbT5vd3yladNX9RNA9vSq4ts4cPufdoesjUtPje5i73f048MM0xPnAB7JWSRuUSsZD5M6L6WGk3Qkw==",
        "pub_key": {
            "type": "tendermint/PubKeySecp256k1",
            "value": "A/5wi9pmUk/SxrzpBoLjhVWoUeA9Ku5PYpsF3pD1Htm8",
        },
        "account_number": "0",
        "sequence": "1092",
    }],
}

client = Client(TEST_RPC)


def test_send_tx_sync_mode_success(requests_mock):
    requests_mock.register_uri(
        "POST",
        "{}/txs".format(TEST_RPC),
        json={
            "height": "0",
            "txhash":
            "E204AAD58ACA8F00942B1BB66D9F745F5E2C21E04C5DF6A0CB73DF02B6B51121",
            "raw_log": "[]",
        },
        status_code=200,
    )