Exemple #1
0
def test_msg_request_creation_min_count_fail():
    msg_request = MsgRequest(
        oracle_script_id=1,
        calldata=bytes.fromhex("000000034254430000000000000001"),
        ask_count=3,
        min_count=0,
        client_id="from_pyband",
        sender=Address.from_acc_bech32("band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c"),
    )
    with pytest.raises(ValueError, match="invalid min count got: min count: 0"):
        msg_request.validate()
def test_msg_delegate_coin_fail():
    msg_delegate = MsgDelegate(
        delegator_address=Address.from_acc_bech32(
            "band1jrhuqrymzt4mnvgw8cvy3s9zhx3jj0dq30qpte"),
        validator_address=Address.from_val_bech32(
            "bandvaloper1j9vk75jjty02elhwqqjehaspfslaem8pr20qst"),
        amount=Coin(amount=-1000000, denom="uband"),
    )

    with pytest.raises(ValueError, match="Expect amount more than 0"):
        msg_delegate.amount.validate()
Exemple #3
0
def test_msg_request_creation_client_id_count_fail():
    msg_request = MsgRequest(
        oracle_script_id=1,
        calldata=bytes.fromhex("000000034254430000000000000001"),
        ask_count=3,
        min_count=2,
        client_id="Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum",
        sender=Address.from_acc_bech32("band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c"),
    )
    with pytest.raises(ValueError, match="too long client id"):
        msg_request.validate()
Exemple #4
0
def test_msg_request_creation_oracle_script_id_fail():
    msg_request = MsgRequest(
        oracle_script_id=0,
        calldata=bytes.fromhex("000000034254430000000000000001"),
        ask_count=4,
        min_count=3,
        client_id="from_pyband",
        sender=Address.from_acc_bech32(
            "band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c"),
    )
    with pytest.raises(NegativeIntegerError,
                       match="oracle script id cannot less than zero"):
        msg_request.validate()
Exemple #5
0
def test_msg_request_get_sender():
    msg_request = MsgRequest(
        oracle_script_id=1,
        calldata=bytes.fromhex("000000034254430000000000000001"),
        ask_count=4,
        min_count=3,
        client_id="from_pyband",
        sender=Address.from_acc_bech32(
            "band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c"),
    )

    assert msg_request.get_sender().to_acc_bech32(
    ) == "band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c"
Exemple #6
0
def test_get_sign_data_chain_id_fail():
    t = (Transaction().with_messages(
        MsgRequest(
            oracle_script_id=1,
            calldata=bytes.fromhex("000000034254430000000000000001"),
            ask_count=4,
            min_count=3,
            client_id="from_pyband",
            sender=Address.from_acc_bech32(
                "band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c"),
        )).with_account_num(100).with_sequence(30))

    with pytest.raises(ValueError, match="chain_id should be defined"):
        t.get_sign_data()
Exemple #7
0
def test_get_sign_data_memo_fail():
    t = (Transaction().with_messages(
        MsgRequest(
            oracle_script_id=1,
            calldata=bytes.fromhex("000000034254430000000000000001"),
            ask_count=4,
            min_count=3,
            client_id="from_pyband",
            sender=Address.from_acc_bech32(
                "band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c"),
        )).with_account_num(100).with_sequence(30).with_chain_id("bandchain"))

    with pytest.raises(ValueError, match="memo is too large"):
        t.with_memo(
            "This is the longest memo in the world. This is the longest memo in the world. This is the longest memo in the world. This is the longest memo in the world. This is the longest memo in the world. This is the longest memo in the world. This is the longest memo in the world.This is the longest memo in the world. This is the longest memo in the world.This is the longest memo in the world."
        )
Exemple #8
0
def test_get_sign_data_success():
    t = (Transaction().with_messages(
        MsgRequest(
            oracle_script_id=1,
            calldata=bytes.fromhex("000000034254430000000000000001"),
            ask_count=4,
            min_count=3,
            client_id="from_pyband",
            sender=Address.from_acc_bech32(
                "band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c"),
        )).with_account_num(100).with_sequence(30).with_chain_id("bandchain"))

    assert (
        t.get_sign_data() ==
        b'{"account_number":"100","chain_id":"bandchain","fee":{"amount":[{"amount":"0","denom":"uband"}],"gas":"200000"},"memo":"","msgs":[{"type":"oracle/Request","value":{"ask_count":"4","calldata":"AAAAA0JUQwAAAAAAAAAB","client_id":"from_pyband","min_count":"3","oracle_script_id":"1","sender":"band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c"}}],"sequence":"30"}'
    )
Exemple #9
0
def test_msg_request_creation_success():
    msg_request = MsgRequest(
        oracle_script_id=1,
        calldata=bytes.fromhex("000000034254430000000000000001"),
        ask_count=4,
        min_count=3,
        client_id="from_pyband",
        sender=Address.from_acc_bech32("band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c"),
    )
    assert msg_request.validate() == True

    assert msg_request.as_json() == {
        "type": "oracle/Request",
        "value": {
            "oracle_script_id": "1",
            "calldata": "AAAAA0JUQwAAAAAAAAAB",
            "ask_count": "4",
            "min_count": "3",
            "client_id": "from_pyband",
            "sender": "band13eznuehmqzd3r84fkxu8wklxl22r2qfmtlth8c",
        },
    }