Merge tempoxylophone/pyhmy:master

pull/35/head
MaxMustermann2 2 years ago
commit 7959415bb4
  1. 5
      .gitignore
  2. 2
      Makefile
  3. 11
      pyhmy/util.py
  4. 1
      tests/bech32-pyhmy/test_bech32.py
  5. 5
      tests/util-pyhmy/test_util.py

5
.gitignore vendored

@ -130,4 +130,7 @@ dmypy.json
.pyre/
# IDE
.idea
.idea
# VIM
*.swp

@ -29,7 +29,7 @@ dev:
python3 -m pip install pytest-ordering
test:
python3 -m py.test -r s -s tests
python3 -m pytest -r s -s tests
install:
python3 -m pip install -e .

@ -22,6 +22,7 @@ from .account import (
from .bech32.bech32 import (
bech32_decode,
bech32_encode,
convertbits
)
@ -96,6 +97,16 @@ def convert_one_to_hex(addr):
address = '0x' + ''.join('{:02x}'.format(x) for x in buf)
return to_checksum_address(address)
def convert_hex_to_one(addr):
"""
Given a hex address, convert it to a one address
"""
if is_valid_address(addr):
return addr
checksum_addr = to_checksum_address(addr)
data = bytearray.fromhex(checksum_addr[2:] if checksum_addr.startswith("0x") else checksum_addr)
buf = convertbits(data, 8, 5)
return bech32_encode("one", buf)
def is_active_shard(endpoint, delay_tolerance=60):
"""

@ -7,3 +7,4 @@ def test_encode():
def test_decode():
bech32.decode('one', 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9')

@ -47,6 +47,11 @@ def test_convert_one_to_hex():
assert util.convert_one_to_hex('0xebcd16e8c1d8f493ba04e99a56474122d81a9c58') == '0xeBCD16e8c1D8f493bA04E99a56474122D81A9c58'
assert util.convert_one_to_hex('one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9') == '0xeBCD16e8c1D8f493bA04E99a56474122D81A9c58'
def test_convert_hex_to_one():
assert util.convert_hex_to_one('0xebcd16e8c1d8f493ba04e99a56474122d81a9c58') == 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9'
assert util.convert_hex_to_one('one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9') == 'one1a0x3d6xpmr6f8wsyaxd9v36pytvp48zckswvv9'
def test_get_bls_build_variables():
assert isinstance(util.get_bls_build_variables(), dict)

Loading…
Cancel
Save