Skip to content

Commit

Permalink
Tests: use pytezos key in account
Browse files Browse the repository at this point in the history
  • Loading branch information
spalmer25 committed Jan 29, 2024
1 parent 23119d2 commit aa618af
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
2 changes: 1 addition & 1 deletion test/python/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
DEFAULT_ACCOUNT = Account(
"m/44'/1729'/0'/0'",
SigScheme.ED25519,
"edpkuXX2VdkdXzkN11oLCb8Aurdo1BTAtQiK8ZY9UPj2YMt3AHEpcY"
"edsk2tUyhVvGj9B1S956ZzmaU4bC9J7t8xVBH52fkAoZL25MHEwacd"
)

EMPTY_PATH = BipPath.from_string("m")
26 changes: 20 additions & 6 deletions test/python/utils/account.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from enum import IntEnum
from typing import Union
import base58
from pytezos import pytezos
import pytezos
from bip_utils.bip.bip32.bip32_path import Bip32Path, Bip32PathParser
from bip_utils.bip.bip32.bip32_key_data import Bip32KeyIndex
from utils.helper import BytesReader
Expand Down Expand Up @@ -126,16 +126,31 @@ class Account:
def __init__(self,
path: Union[BipPath, str, bytes],
sig_scheme: SigScheme,
public_key: str):
key: str):
self.path: BipPath = \
BipPath.from_string(path) if isinstance(path, str) else \
BipPath.from_bytes(path) if isinstance(path, bytes) else \
path
self.sig_scheme: SigScheme = sig_scheme
self.public_key: str = public_key
self.key: pytezos.Key = pytezos.pytezos.using(key=key).key

@property
def public_key_hash(self) -> str:
"""public_key_hash of the account."""
return self.key.public_key_hash()

@property
def public_key(self) -> str:
"""public_key of the account."""
return self.key.public_key()

@property
def secret_key(self) -> str:
"""secret_key of the account."""
return self.key.secret_key()

def __repr__(self) -> str:
return self.public_key
return self.public_key_hash

@property
def base58_decoded(self) -> bytes:
Expand Down Expand Up @@ -206,8 +221,7 @@ def check_signature(self,
SigScheme.BIP32_ED25519
] \
else Signature.from_tlv(signature)
ctxt = pytezos.using(key=self.public_key)
assert ctxt.key.verify(signature.value, message), \
assert self.key.verify(signature.value, message), \
f"Fail to verify signature {signature}, \n\
with account {self} \n\
and message {message.hex()}"

0 comments on commit aa618af

Please sign in to comment.