Ejemplo n.º 1
0
def test_validate_commit_format(connected_clients):
    alice, bob, charlie, david, eric, fred = connected_clients
    try:
        secret = lib.create_secret()
        params = {
            "handle": alice.handle,
            "sends": [],
            "commit": "invalidformat",
            "revokes": None,
            "next_revoke_secret_hash": secret["secret_hash"]
        }
        params = auth.sign_json(params, keys.wif_to_privkey(alice.client_wif))
        api.mph_sync(**params)
        assert False
    except jsonschema.exceptions.ValidationError:
        assert True
Ejemplo n.º 2
0
def test_pubkey_missmatch(connected_clients):
    alice, bob, charlie, david, eric, fred = connected_clients
    try:
        secret = lib.create_secret()
        handle = alice.handle
        wif = keys.generate_wif(netcode=etc.netcode)
        params = {
            "handle": handle,
            "sends": [],
            "commit": None,
            "revokes": None,
            "next_revoke_secret_hash": secret["secret_hash"]
        }
        params = auth.sign_json(params, keys.wif_to_privkey(wif))
        api.mph_sync(**params)
        assert False
    except err.ClientPubkeyMissmatch:
        assert True
Ejemplo n.º 3
0
def test_validate_handles_exist(connected_clients):
    alice, bob, charlie, david, eric, fred = connected_clients
    try:
        secret = lib.create_secret()
        params = {
            "handle": alice.handle,
            "sends": [{
                "payee_handle": "deadbeef",
                "amount": 1337,
                "token": "deadbeef"
            }],
            "commit": None,
            "revokes": None,
            "next_revoke_secret_hash": secret["secret_hash"]
        }
        params = auth.sign_json(params, keys.wif_to_privkey(alice.client_wif))
        api.mph_sync(**params)
        assert False
    except err.HandlesNotFound:
        assert True
Ejemplo n.º 4
0
def test_send_exceeds_max(connected_clients):
    alice, bob, charlie, david, eric, fred = connected_clients
    try:
        secret = lib.create_secret()
        params = {
            "handle": alice.handle,
            "sends": [{
                "payee_handle": bob.handle,
                "amount": 1000000,
                "token": "deadbeef"
            }],
            "commit": None,
            "revokes": None,
            "next_revoke_secret_hash": secret["secret_hash"]
        }
        params = auth.sign_json(params, keys.wif_to_privkey(alice.client_wif))
        api.mph_sync(**params)
        assert False
    except err.PaymentExceedsSpendable:
        assert True