Exemplo n.º 1
0
def test_account_from_keystore_without_address_and_uuid():
    keystore = dict(KEYSTORE)
    keystore.pop("address")
    keystore.pop("id")
    account = Account(keystore)
    assert account.address is None

    account.unlock(PASSWORD)
    assert account.address == privatekey_to_address(PRIVKEY)
    assert account.uuid is None
    account.uuid = new_uuid = UUID(hex="1234567890abcdef1234567890abcdef")
    assert str(new_uuid) in repr(account)
Exemplo n.º 2
0
def test_account_from_keystore():
    keystore = dict(KEYSTORE)
    account = Account(keystore)
    assert account.locked
    assert account.privkey is None
    assert account.uuid == KEYSTORE["id"]
    assert account.address == decode_hex(KEYSTORE["address"])

    with pytest.raises(ValueError):
        account.unlock("wrong-password")
    assert account.locked

    account.unlock(PASSWORD)
    account.unlock("wrong-password")  # ignored as the account is not locked
    assert not account.locked
    assert account.privkey == PRIVKEY
    assert account.pubkey == privatekey_to_publickey(PRIVKEY)

    account.lock()
    assert account.locked
    assert account.privkey is None
    assert account.pubkey is None