From 14350452f04b68e8030647ce4bccd875b0982fbc Mon Sep 17 00:00:00 2001 From: scgbckbone Date: Fri, 16 Jun 2023 18:29:31 +0200 Subject: [PATCH] truncated address - add one more char to first part to view regtest segwit version (cherry picked from commit a3b466fc71904f96a3b0d308a0901338b124283b) --- shared/utils.py | 2 +- testing/helpers.py | 6 ++++++ testing/test_address_explorer.py | 5 +++-- testing/test_multisig.py | 9 +++++---- 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/shared/utils.py b/shared/utils.py index 8307b0f1..ff647d44 100644 --- a/shared/utils.py +++ b/shared/utils.py @@ -629,6 +629,6 @@ def truncate_address(addr): # - 16 chars screen width # - but 2 lost at left (menu arrow, corner arrow) # - want to show not truncated on right side - return addr[0:5] + '⋯' + addr[-6:] + return addr[0:6] + '⋯' + addr[-6:] # EOF diff --git a/testing/helpers.py b/testing/helpers.py index baf57a1e..d867ff57 100644 --- a/testing/helpers.py +++ b/testing/helpers.py @@ -253,4 +253,10 @@ def sign_msg(key, msg, addr_fmt, b64 = False): else: return sig +def detruncate_address(s): + if s[0] == "↳": + s = s[1:] + start, end = s.split('⋯') + return start, end + # EOF diff --git a/testing/test_address_explorer.py b/testing/test_address_explorer.py index 358805e6..f4cba051 100644 --- a/testing/test_address_explorer.py +++ b/testing/test_address_explorer.py @@ -5,6 +5,7 @@ from ckcc_protocol.constants import * from pycoin.key.BIP32Node import BIP32Node from pycoin.contrib.segwit_addr import encode as sw_encode from pycoin.encoding import a2b_hashed_base58, hash160 +from helpers import detruncate_address @pytest.fixture @@ -175,7 +176,7 @@ def test_stub_menu(sim_execfile, goto_address_explorer, need_keypress, cap_menu, validate_address(expected_addr, sk) # validate that stub is correct - [start, end] = m[_id][1:6], m[_id][7:] + start, end = detruncate_address(m[_id]) assert expected_addr.startswith(start) assert expected_addr.endswith(end) @@ -317,7 +318,7 @@ def test_account_menu(way, account_num, sim_execfile, pick_menu_item, goto_addre validate_address(expected_addr, sk) # validate that stub is correct - [start, end] = m[_id][1:6], m[_id][7:] + start, end = detruncate_address(m[_id]) assert expected_addr.startswith(start) assert expected_addr.endswith(end) diff --git a/testing/test_multisig.py b/testing/test_multisig.py index 3f1c3c20..7d47fd14 100644 --- a/testing/test_multisig.py +++ b/testing/test_multisig.py @@ -10,8 +10,8 @@ import time, pytest, os, random, json, shutil, pdb, io, base64 from psbt import BasicPSBT, BasicPSBTInput, BasicPSBTOutput from ckcc.protocol import CCProtocolPacker, MAX_TXN_LEN from pprint import pprint -from helpers import B2A, fake_dest_addr, swab32, xfp2str -from helpers import str_to_path, slip132undo +from helpers import B2A, fake_dest_addr, xfp2str, detruncate_address +from helpers import str_to_path, slip132undo, swab32 from struct import unpack, pack from constants import * from pycoin.key.BIP32Node import BIP32Node @@ -1892,8 +1892,9 @@ def test_ms_addr_explorer(descriptor, change, M, N, addr_fmt, make_multisig, cle assert int(subpath.split('/')[-2]) == chng_idx #print('../0/%s => \n %s' % (idx, B2A(script))) - assert addr[:5] == expect[:5] - assert addr[-6:] == expect[-6:] + start, end = detruncate_address(addr) + assert expect.startswith(start) + assert expect.endswith(end) def test_dup_ms_wallet_bug(goto_home, pick_menu_item, need_keypress, import_ms_wallet, clear_ms, M=2, N=3):