Skip to content

Commit c890d52

Browse files
committed
Clean up unnecessary test output
1 parent f7779b5 commit c890d52

File tree

7 files changed

+61
-22
lines changed

7 files changed

+61
-22
lines changed

GNUmakefile

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -716,10 +716,11 @@ clean:
716716
@rm -rf MANIFEST *.png build dist auto *.egg-info $(shell find . -name '__pycache__' )
717717

718718

719-
# Run only tests with a prefix containing the target string, eg test-blah
719+
# Run only tests with a prefix containing the target string, eg test-api
720720
test-%:
721-
slip39/*$*_test.py
721+
$(PY3TEST) $(shell find slip39 -name '*$**_test.py')
722722

723+
# Run all tests with names matching the target string
723724
unit-%:
724725
$(PY3TEST) -k $*
725726

slip39/api_passphrase_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_passphrase():
5757
groups = groups,
5858
master_secret = SEED_FF,
5959
)
60-
print( json.dumps( details_nonpass.groups, indent=4 ))
60+
#print( json.dumps( details_nonpass.groups, indent=4 ))
6161
assert details_nonpass.groups == {
6262
"First": (
6363
1,
@@ -127,7 +127,7 @@ def test_passphrase():
127127
master_secret = SEED_FF,
128128
passphrase = badpass,
129129
)
130-
print( json.dumps( details_badpass.groups, indent=4 ))
130+
#print( json.dumps( details_badpass.groups, indent=4 ))
131131
assert details_badpass.groups == {
132132
"First": (
133133
1,

slip39/api_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ def test_addresses():
389389
paths = '.../0/-2',
390390
format = 'Bech32',
391391
))
392-
print( json.dumps( addrs, indent=4, default=str ))
392+
#print( json.dumps( addrs, indent=4, default=str ))
393393
assert addrs == [
394394
(
395395
"BTC",

slip39/communications_test.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
log = logging.getLogger( __package__ )
1919

20+
# Disable printing of details unless something goes wrong...
21+
print_NOOP = lambda *args, **kwds: None
22+
print = print_NOOP
23+
2024
# If we find a DKIM key, lets use it. Otherwise, we'll just use the pre-defined pre-signed email.Message
2125
dkim_keys = list( Path( __file__ ).resolve().parent.parent.glob( 'licensing.dominionrnd.com.*.key' ))
2226
dkim_key = None

slip39/invoice/multipayout_test.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ def test_solcx_smoke():
102102
if goerli_xprvkey:
103103
# the Account.address/.key
104104
goerli_src = account( goerli_xprvkey, crypto='ETH', path="m/0/0" )
105-
print( f"Goerli Ethereum Testnet src ETH address: {goerli_src.address}" )
105+
#print( f"Goerli Ethereum Testnet src ETH address: {goerli_src.address}" )
106106
# Just addresses
107107
goerli_destination = tuple(
108108
a.address
109109
for a in accounts( goerli_xprvkey, crypto="ETH", paths=f"m/0/1-{goerli_targets}" )
110110
)
111-
print( f"Goerli Ethereum Testnet dst ETH addresses: {json.dumps( goerli_destination, indent=4 )}" )
111+
#print( f"Goerli Ethereum Testnet dst ETH addresses: {json.dumps( goerli_destination, indent=4 )}" )
112112

113113
web3_testers += [(
114114
"Goerli",
@@ -135,13 +135,13 @@ def test_solcx_smoke():
135135

136136
# the Account.address/.key
137137
ganache_src = account( ganache_xprvkey, crypto='ETH', path="m/0/0" )
138-
print( f"Goerli Ethereum Testnet src ETH address: {ganache_src.address}" )
138+
#print( f"Goerli Ethereum Testnet src ETH address: {ganache_src.address}" )
139139
# Just addresses
140140
ganache_destination = tuple(
141141
a.address
142142
for a in accounts( ganache_xprvkey, crypto="ETH", paths=f"m/0/1-{ganache_targets}" )
143143
)
144-
print( f"Ganache Ethereum Testnet dst ETH addresses: {json.dumps( ganache_destination, indent=4 )}" )
144+
#print( f"Ganache Ethereum Testnet dst ETH addresses: {json.dumps( ganache_destination, indent=4 )}" )
145145

146146
web3_testers += [(
147147
"Ganache",

slip39/output_test.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def test_Region():
4242
assert card_qr.y1 == 1.125
4343

4444
elements = list( card.elements() )[1:]
45-
print( json.dumps( elements, indent=4 ))
45+
#print( json.dumps( elements, indent=4 ))
4646
assert len( elements ) == 4
4747
assert elements[0]['type'] == 'I'
4848

@@ -54,7 +54,7 @@ def test_Region():
5454
)
5555

5656
elements = list( card.elements() )[1:]
57-
print( json.dumps( elements, indent=4 ))
57+
#print( json.dumps( elements, indent=4 ))
5858
assert elements[-1]['type'] == 'T'
5959
assert elements[-1]['font'] == 'helvetica'
6060
assert elements[-1]['size'] == approx( 14.4 )

slip39/recovery_test.py

Lines changed: 45 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@
2727

2828
groups_example = dict( one = (1,1), two = (1,1), fam = (2,4), fren = (3,5) )
2929

30+
# Disable printing of details unless something goes wrong...
31+
print_NOOP = lambda *args, **kwds: None
32+
print = print_NOOP
3033

3134
def noise( mag ):
3235
return mag * ( random.random() * 2 - 1 )
@@ -200,7 +203,7 @@ def test_recover_bip39():
200203
details_slip39 = create(
201204
"bip39 recovery test -- all ones in SLIP-39", 2, groups_example, SEED_ONES,
202205
)
203-
print( json.dumps( details_slip39.groups, indent=4 ))
206+
#print( json.dumps( details_slip39.groups, indent=4 ))
204207
assert details_slip39.groups == {
205208
"one": (
206209
1,
@@ -493,10 +496,12 @@ def test_signal_draw():
493496
# a DFT so that the recovered signal is produced at a higher sample rate. This allows us to
494497
# analyze a signal in 8-bit values, but produce a recovered signal over 2x 4-bit hex nibbles, or
495498
# 8x 1-bit bits.
496-
print()
497-
print( ''.join( signal_draw( s ) for s in range( -128, 128 )))
498-
print( ''.join( signal_draw( s, pos=True ) for s in range( -128, 128 )))
499-
print( ''.join( signal_draw( s, neg=True ) for s in range( -128, 128 )))
499+
assert ''.join( signal_draw( s ) for s in range( -128, 128 )) \
500+
== ',,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,.....................................____________________________________~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'""""""""""""""""""""""""""""""""""""'
501+
assert ''.join( signal_draw( s, pos=True ) for s in range( -128, 128 )) \
502+
== ' ,,,,,,,,,,,,,,,,,,,..................__________________~~~~~~~~~~~~~~~~~~~‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'""""""""""""""""""'
503+
assert ''.join( signal_draw( s, neg=True ) for s in range( -128, 128 )) \
504+
== ',,,,,,,,,,,,,,,,,,..................__________________~~~~~~~~~~~~~~~~~~~‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'\'""""""""""""""""""" '
500505

501506
for entropy in (
502507
SEED_HIGH, SEED_MID, SEED_LOW,
@@ -529,10 +534,25 @@ def test_signal_draw():
529534
print( "Signal from DFT x 8 deduced (for bin output):" )
530535
sigR8 = signal_recover_real( dfts, scale=8, integer=True )
531536
print( f"{entropy_bin}" )
532-
print( ''.join( signal_draw( s ) * 8 for s in sigR ) + " (low-frequency, expanded x8)" )
533-
print( ''.join( signal_draw( s ) for s in sigR8 ) + " (scaled x8)" )
534-
print( ''.join( signal_draw( s, neg=False ) for s in sigR8 ))
535-
print( ''.join( signal_draw( s, neg=True ) for s in sigR8 ))
537+
sigRx8_1 = ''.join( signal_draw( s ) * 8 for s in sigR ) + " (low-frequency, expanded x8)"
538+
print( sigRx8_1 )
539+
sigR8_1 = ''.join( signal_draw( s ) for s in sigR8 ) + " (scaled x8)"
540+
print( sigR8_1 )
541+
sigR8_pos = ''.join( signal_draw( s, neg=False ) for s in sigR8 )
542+
print( sigR8_pos )
543+
sigR8_neg = ''.join( signal_draw( s, neg=True ) for s in sigR8 )
544+
print( sigR8_neg )
545+
546+
# Validate the very last set of renderings
547+
assert sigRx8_1 \
548+
== '""""""""\'\'\'\'\'\'\'\'~~~~~~~~........,,,,,,,,........~~~~~~~~\'\'\'\'\'\'\'\'""""""""\'\'\'\'\'\'\'\'~~~~~~~~........,,,,,,,,........~~~~~~~~\'\'\'\'\'\'\'\'""""""""\'\'\'\'\'\'\'\'~~~~~~~~........,,,,,,,,........~~~~~~~~\'\'\'\'\'\'\'\'""""""""\'\'\'\'\'\'\'\'~~~~~~~~........,,,,,,,,........~~~~~~~~\'\'\'\'\'\'\'\' (low-frequency, expanded x8)'
549+
assert sigR8_1 \
550+
== '""""""""\'\'\'\'‾‾‾~~~___....,,,,,,,,,,,,,,,....___~~~‾‾‾\'\'\'\'"""""""""""""""\'\'\'\'‾‾‾~~~___....,,,,,,,,,,,,,,,....___~~~‾‾‾\'\'\'\'"""""""""""""""\'\'\'\'‾‾‾~~~___....,,,,,,,,,,,,,,,....___~~~‾‾‾\'\'\'\'"""""""""""""""\'\'\'\'‾‾‾~~~___....,,,,,,,,,,,,,,,....___~~~‾‾‾\'\'\'\'""""""" (scaled x8)'
551+
assert f"{sigR8_pos}\n{sigR8_neg}" \
552+
== '''\
553+
""""""''‾‾~~__.,, ,,.__~~‾‾''"""""""""""''‾‾~~__.,, ,,.__~~‾‾''"""""""""""''‾‾~~__.,, ,,.__~~‾‾''"""""""""""''‾‾~~__.,, ,,.__~~‾‾''"""""
554+
"''‾~~__..,,,,,,,,,,,..__~~‾''" "''‾~~__..,,,,,,,,,,,..__~~‾''" "''‾~~__..,,,,,,,,,,,..__~~‾''" "''‾~~__..,,,,,,,,,,,..__~~‾''" \
555+
'''
536556

537557

538558
def test_denoise_mags():
@@ -541,7 +561,14 @@ def test_denoise_mags():
541561
symbols = 32
542562
stride = 8
543563
threshold = 200/100
544-
for npct in range( 10 ):
564+
565+
# Test thru some percentage signal to noise; too high, and we'll overflow our symbols
566+
noise_pct = 40
567+
568+
snr_dB_strides = {}
569+
for npct in range( noise_pct ):
570+
print()
571+
print( f"For {npct:2d}% noise:" )
545572
seed_noisy = [ 128 + noise( 128 * npct/100 ) for _ in range( symbols ) ] # median 1% noise floor
546573
for i in range( len( seed_noisy )):
547574
seed_noisy[i] += math.cos( math.pi * 2 * i / (32 / 16) ) * 16 # max frequency bin
@@ -570,6 +597,14 @@ def test_denoise_mags():
570597
signal = signal_entropy( SEED_NOISY, stride=stride, symbols=symbols, threshold=threshold )
571598
print( f"{signal}" )
572599

600+
snr_dB_strides[npct] = (signal.dB, signal.stride)
601+
602+
for npct,(dB,stride) in snr_dB_strides.items():
603+
print( f"{npct:02d}%: {stride:2d} bits/symbol, at {dB:7.2f}dB" )
604+
605+
# We should find the signal at all these noise levels
606+
assert all( dBS[1] == 8 for dBS in snr_dB_strides.values() )
607+
573608

574609
def test_signal_entropy():
575610
# See if we can detect patterns of bits in various frequency bins. With 8x 8-bit real-valued
@@ -584,7 +619,6 @@ def test_signal_entropy():
584619
#
585620
# We can estimate what perfect noise looks like across all energy bins, and compare our signal
586621
# against that baseline. So, our signal has some noise added to it.
587-
588622
print()
589623
SEED_SINE = bytes([
590624
# 255, 255, 255, 255,

0 commit comments

Comments
 (0)