Пример #1
0
def test_xinfin_utils():

    assert is_network(network=_["xinfin"]["network"])
    assert not is_network(network="unknown")

    assert is_address(address=_["xinfin"]["wallet"]["sender"]["address"])
    assert is_address(address=_["xinfin"]["wallet"]["recipient"]["address"])

    assert is_transaction_raw(
        transaction_raw=_["xinfin"]["fund"]["unsigned"]["transaction_raw"])
    assert not is_transaction_raw(transaction_raw="unknown")

    assert isinstance(get_xrc20_data("abi"), list)
    assert isinstance(get_xrc20_data("bin"), str)
    assert isinstance(get_xrc20_data("bin-runtime"), str)
    assert isinstance(get_xrc20_data("opcodes"), str)

    assert decode_transaction_raw(transaction_raw=_["xinfin"]["fund"]["unsigned"]["transaction_raw"]) == \
        {
            "fee": _["xinfin"]["fund"]["unsigned"]["fee"],
            "network": _["xinfin"]["network"],
            "signatures": None,
            "transaction": _["xinfin"]["fund"]["unsigned"]["json"],
            "type": "xinfin_fund_unsigned"
        }

    # Wrong Ethereum transaction raw must be signed, not unsigned transaction raw.
    with pytest.raises(TransactionRawError):
        submit_transaction_raw(
            transaction_raw=_["xinfin"]["fund"]["unsigned"]["transaction_raw"])
Пример #2
0
def test_xinfin_cli_refund(cli_tester):

    refund = cli_tester.invoke(cli_main, [
        "xinfin", "refund", "--address",
        _["xinfin"]["wallet"]["sender"]["address"], "--transaction-hash",
        _["xinfin"]["transaction_hash"], "--network", _["xinfin"]["network"]
    ])

    assert refund.exit_code == 0
    assert is_transaction_raw(refund.output)
def test_xinfin_cli_xrc20_withdraw(cli_tester):

    xrc20_withdraw = cli_tester.invoke(cli_main, [
        "xinfin", "withdraw", "--address",
        _["xinfin"]["wallet"]["recipient"]["address"], "--transaction-hash",
        _["xinfin"]["xrc20_transaction_hash"], "--secret-key",
        _["xinfin"]["xrc20_htlc"]["secret"]["key"], "--network",
        _["xinfin"]["network"], "--xrc20", True
    ])
    assert xrc20_withdraw.exit_code == 0
    assert is_transaction_raw(xrc20_withdraw.output)
Пример #4
0
def test_xinfin_cli_xrc20_fund(cli_tester):

    xrc20_fund = cli_tester.invoke(cli_main, [
        "xinfin", "fund", "--secret-hash",
        _["xinfin"]["xrc20_htlc"]["secret"]["hash"], "--recipient-address",
        _["xinfin"]["wallet"]["recipient"]["address"], "--sender-address",
        _["xinfin"]["wallet"]["sender"]["address"], "--endtime",
        get_current_timestamp(plus=3600), "--amount",
        _["xinfin"]["xrc20_amount"], "--network", _["xinfin"]["network"],
        "--token-address",
        _["xinfin"]["xrc20_htlc"]["agreements"]["token_address"], "--xrc20",
        True
    ])
    assert xrc20_fund.exit_code == 0
    assert is_transaction_raw(xrc20_fund.output)
Пример #5
0
def test_xinfin_cli_fund(cli_tester):

    fund = cli_tester.invoke(
        cli_main, [
            "xinfin",
            "fund",
            "--secret-hash", _["xinfin"]["htlc"]["secret"]["hash"],
            "--recipient-address", _["xinfin"]["wallet"]["recipient"]["address"],
            "--sender-address", _["xinfin"]["wallet"]["sender"]["address"],
            "--endtime", get_current_timestamp(plus=3600),
            "--amount", _["xinfin"]["amount"],
            "--unit", _["xinfin"]["unit"],
            "--network", _["xinfin"]["network"]
        ]
    )
    assert fund.exit_code == 0
    assert is_transaction_raw(fund.output)