Skip to content

Commit

Permalink
rename to check32m
Browse files Browse the repository at this point in the history
add tests
  • Loading branch information
matt-o-how authored and hoffmang9 committed Jan 18, 2021
1 parent 19674ac commit 1fcec88
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/cmds/init.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

from src.ssl.create_ssl import generate_selfsigned_cert
from src.wallet.derive_keys import master_sk_to_wallet_sk, master_sk_to_pool_sk
from src.util.chech32 import encode_puzzle_hash
from src.util.chech32m import encode_puzzle_hash


def make_parser(parser: ArgumentParser):
Expand Down
2 changes: 1 addition & 1 deletion src/cmds/keys.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from blspy import AugSchemeMPL, G1Element, G2Element

from src.cmds.init import check_keys
from src.util.chech32 import encode_puzzle_hash
from src.util.chech32m import encode_puzzle_hash
from src.util.keychain import (
generate_mnemonic,
bytes_to_mnemonic,
Expand Down
2 changes: 1 addition & 1 deletion src/cmds/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from src.util.config import str2bool
from src.util.config import load_config
from src.util.default_root import DEFAULT_ROOT_PATH
from src.util.chech32 import encode_puzzle_hash
from src.util.chech32m import encode_puzzle_hash


def make_parser(parser):
Expand Down
2 changes: 1 addition & 1 deletion src/farmer/farmer.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from src.types.sized_bytes import bytes32
from src.util.ints import uint64
from src.wallet.derive_keys import master_sk_to_farmer_sk, master_sk_to_pool_sk
from src.util.chech32 import decode_puzzle_hash
from src.util.chech32m import decode_puzzle_hash

log = logging.getLogger(__name__)

Expand Down
2 changes: 1 addition & 1 deletion src/rpc/wallet_rpc_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from blspy import PrivateKey

from src.util.byte_types import hexstr_to_bytes
from src.util.chech32 import encode_puzzle_hash, decode_puzzle_hash
from src.util.chech32m import encode_puzzle_hash, decode_puzzle_hash
from src.util.keychain import (
generate_mnemonic,
bytes_to_mnemonic,
Expand Down
2 changes: 1 addition & 1 deletion src/rpc/wallet_rpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from src.wallet.transaction_record import TransactionRecord
from src.util.ints import uint64, uint32
from src.types.sized_bytes import bytes32
from src.util.chech32 import decode_puzzle_hash
from src.util.chech32m import decode_puzzle_hash


class WalletRpcClient(RpcClient):
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/setup_nodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from src.server.start_wallet import service_kwargs_for_wallet
from src.server.start_service import Service
from src.util.ints import uint16, uint32
from src.util.chech32 import encode_puzzle_hash
from src.util.chech32m import encode_puzzle_hash

from tests.time_out_assert import time_out_assert_custom_interval

Expand Down
38 changes: 38 additions & 0 deletions tests/test_chech32m.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
from src.util.chech32m import bech32_encode, bech32_decode, decode_puzzle_hash


def test_valid_imports():
test_strings = [
"A1LQFN3A",
"a1lqfn3a",
"an83characterlonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11sg7hg6",
"abcdef1l7aum6echk45nj3s0wdvt2fg8x9yrzpqzd3ryx",
"11llllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllllludsr8",
"split1checkupstagehandshakeupstreamerranterredcaperredlc445v",
"?1v759aa",
]
for test_str in test_strings:
hrp, data = bech32_decode(test_str)
assert data is not None


def test_invalid_imports():
test_strings = [
f"{0x20}1xj0phk",
f"{0x7F}1g6xzxy",
f"{0x80}1vctc34",
"an84characterslonghumanreadablepartthatcontainsthetheexcludedcharactersbioandnumber11d6pts4",
"qyrz8wqd2c9m",
"1qyrz8wqd2c9m",
"y1b0jsk6g",
"lt1igcx5c0",
"in1muywd",
"mm1crxm3i",
"au1s5cgom",
"M1VUXWEZ",
"16plkw9",
"1p2gdwpf",
]
for test_str in test_strings:
hrp, data = bech32_decode(test_str)
assert data is None
2 changes: 1 addition & 1 deletion tests/wallet/rpc/test_wallet_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# from tests.setup_nodes import setup_simulators_and_wallets, bt
# from src.consensus.block_rewards import calculate_base_fee, calculate_block_reward
# from tests.time_out_assert import time_out_assert
# from src.util.chech32 import encode_puzzle_hash
# from src.util.chech32m import encode_puzzle_hash
# from src.rpc.wallet_rpc_client import WalletRpcClient
# from src.rpc.wallet_rpc_api import WalletRpcApi
# from src.rpc.rpc_server import start_rpc_server
Expand Down

0 comments on commit 1fcec88

Please sign in to comment.