示例#1
0
def unbond_command(casperlabs_client, args):
    logging.info(f"UNBOND {args}")
    _set_session(args, "unbonding.wasm")

    if not args.session_args:
        args.session_args = ABI.args_to_json(
            ABI.args([
                ABI.optional_value("amount",
                                   ABI.long_value("amount", args.amount))
            ]))

    return deploy_command(casperlabs_client, args)
示例#2
0
def test_legacy_args_from_json():
    json_str = json.dumps(LEGACY_ARGS)
    args = ABI.args_from_json(json_str)
    assert args[0] == ABI.long_value("amount", long_value)
    assert args[1] == ABI.account("account", account)
    assert args[2] == ABI.optional_value("main_purse", None)
    assert args[3] == ABI.big_int("number", big_int_value)
    assert args[4] == ABI.bytes_value("my_bytes", account)

    assert args[5] == ABI.key_hash("my_hash", account)
    assert args[6] == ABI.key_address("my_address", account)
    assert args[7] == ABI.key_uref("my_uref", account, access_rights=5)
    assert args[8] == ABI.key_local("my_local", account)
示例#3
0
def test_args_to_json():
    args = [
        ABI.long_value("amount", long_value),
        ABI.account("account", account),
        ABI.optional_value("purse_id", None),
        ABI.big_int("number", big_int_value),
        ABI.bytes_value("my_bytes", account),
        ABI.key_hash("my_hash", account),
        ABI.key_address("my_address", account),
        ABI.key_uref("my_uref", account, access_rights=5),
        ABI.key_local("my_local", account),
    ]
    json_str1 = json.dumps(ARGS, ensure_ascii=True, sort_keys=True, indent=2)
    json_str2 = ABI.args_to_json(ABI.args(args),
                                 ensure_ascii=True,
                                 sort_keys=True,
                                 indent=2)
    assert json_str1 == json_str2
示例#4
0
def test_args_to_json():
    args = [
        ABI.long_value("amount", long_value),
        ABI.account("account", account),
        ABI.optional_value("main_purse", None),
        ABI.big_int("number", big_int_value),
        ABI.bytes_value("my_bytes", account),
        ABI.key_hash("my_hash", account),
        ABI.key_address("my_address", account),
        ABI.key_uref("my_uref", account, access_rights=5),
        ABI.key_local("my_local", account),
    ]
    json_str1 = json.dumps(LEGACY_ARGS,
                           ensure_ascii=True,
                           sort_keys=True,
                           indent=2)
    json_str2 = ABI.args_to_json(ABI.args(args),
                                 ensure_ascii=True,
                                 sort_keys=True,
                                 indent=2)
    # TODO: fix this test to use new json format
    assert json_str1 != json_str2