def test_generate_trytes_and_multisqueeze(profile): file = 'tests/test_files/generateTrytesAndMultiSqueeze' with open(file, 'r') as f: reader = csv.DictReader(f) for count, line in enumerate(reader): trytes = line['trytes'] hashes1 = line['Kerl_squeeze1'] hashes2 = line['Kerl_squeeze2'] hashes3 = line['Kerl_squeeze3'] trits = conv.trytes_to_trits(trytes) kerl = Kerl() kerl.absorb(trits) trits_out = [] kerl.squeeze(trits_out) trytes_out = conv.trits_to_trytes(trits_out) assert hashes1 == trytes_out, f'line:{count + 2} {hashes1}!={trytes_out}' trits_out = [] kerl.squeeze(trits_out) trytes_out = conv.trits_to_trytes(trits_out) assert hashes2 == trytes_out, f'line:{count + 2} {hashes2}!={trytes_out}' trits_out = [] kerl.squeeze(trits_out) trytes_out = conv.trits_to_trytes(trits_out) assert hashes3 == trytes_out, f'line:{count + 2} {hashes3}!={trytes_out}' if profile: break
def test_absorb_0_length(): inp = ( 'G9JYBOMPUXHYHKSNRNMMSSZCSHOFYOYNZRSZMAAYWDYEIMVVOGKPJBVBM9TDPULSFUNMTVXRKFIDOHUXX' + 'VYDLFSZYZTWQYTE9SPYYWYTXJYQ9IFGYOLZXWZBKWZN9QOOTBQMWMUBLEWUEEASRHRTNIQWJQNDWRYLCA' ) trits = conv.trytes_to_trits(inp) kerl = Kerl() with pytest.raises(ValueError) as e: kerl.absorb(trits, length=0) assert str(e) == 'trits length of 0 must be greater than zero'
def test_correct_first(): inp = 'EMIDYNHBWMBCXVDEFOFWINXTERALUKYYPPHKP9JJFGJEIUY9MUDVNFZHMMWZUYUSWAIOWEVTHNWMHANBH' trits = conv.trytes_to_trits(inp) kerl = Kerl() kerl.absorb(trits) trits_out = [] kerl.squeeze(trits_out) trytes_out = conv.trits_to_trytes(trits_out) expected = 'EJEAOOZYSAWFPZQESYDHZCGYNSTWXUMVJOVDWUNZJXDGWCLUFGIMZRMGCAZGKNPLBRLGUNYWKLJTYEAQX' assert trytes_out == expected
def test_output_greater_243(): inp = '9MIDYNHBWMBCXVDEFOFWINXTERALUKYYPPHKP9JJFGJEIUY9MUDVNFZHMMWZUYUSWAIOWEVTHNWMHANBH' trits = conv.trytes_to_trits(inp) kerl = Kerl() kerl.absorb(trits) trits_out = [] kerl.squeeze(trits_out, length=486) trytes_out = conv.trits_to_trytes(trits_out) expected = ( 'G9JYBOMPUXHYHKSNRNMMSSZCSHOFYOYNZRSZMAAYWDYEIMVVOGKPJBVBM9TDPULSFUNMTVXRKFIDOHUXX' + 'VYDLFSZYZTWQYTE9SPYYWYTXJYQ9IFGYOLZXWZBKWZN9QOOTBQMWMUBLEWUEEASRHRTNIQWJQNDWRYLCA' ) assert trytes_out == expected
def test_generate_multitrytes_and_hash(profile): file = 'tests/test_files/generateMultiTrytesAndHash' with open(file, 'r') as f: reader = csv.DictReader(f) for count, line in enumerate(reader): trytes = line['multiTrytes'] hashes = line['Kerl_hash'] trits = conv.trytes_to_trits(trytes) kerl = Kerl() kerl.absorb(trits) trits_out = [] kerl.squeeze(trits_out) trytes_out = conv.trits_to_trytes(trits_out) assert hashes == trytes_out, f'line:{count + 2} {hashes}!={trytes_out}' if profile: break
def test_input_greater_243(): inp = ( 'G9JYBOMPUXHYHKSNRNMMSSZCSHOFYOYNZRSZMAAYWDYEIMVVOGKPJBVBM9TDPULSFUNMTVXRKFIDOHUXX' + 'VYDLFSZYZTWQYTE9SPYYWYTXJYQ9IFGYOLZXWZBKWZN9QOOTBQMWMUBLEWUEEASRHRTNIQWJQNDWRYLCA' ) trits = conv.trytes_to_trits(inp) kerl = Kerl() kerl.absorb(trits) trits_out = [] kerl.squeeze(trits_out, length=486) trytes_out = conv.trits_to_trytes(trits_out) expected = ( 'LUCKQVACOGBFYSPPVSSOXJEKNSQQRQKPZC9NXFSMQNRQCGGUL9OHVVKBDSKEQEBKXRNUJSRXYVHJTXBPD' + 'WQGNSCDCBAIRHAQCOWZEBSNHIJIGPZQITIBJQ9LNTDIBTCQ9EUWKHFLGFUVGGUWJONK9GBCDUIMAYMMQX' ) assert trytes_out == expected
from kerl import conv from kerl.kerl import Kerl dir_path = os.path.dirname(__file__) start = time.time() file = os.path.join(dir_path, '../tests/test_files/generateTrytesAndHashes') with open(file, 'r') as f: reader = csv.DictReader(f) for count, line in enumerate(reader): trytes = line['trytes'] hashes = line['Kerl_hash'] trits = conv.trytes_to_trits(trytes) kerl = Kerl() kerl.absorb(trits) trits_out = [] kerl.squeeze(trits_out) trytes_out = conv.trits_to_trytes(trits_out) assert hashes == trytes_out, 'line:' + str( count + 2) + ' ' + hashes + '!=' + trytes_out file = os.path.join(dir_path, '../tests/test_files/generateMultiTrytesAndHash') with open(file, 'r') as f: reader = csv.DictReader(f) for count, line in enumerate(reader): trytes = line['multiTrytes'] hashes = line['Kerl_hash']