Exemplo n.º 1
0
    def test_generate_multi_trytes_and_hash(self):
        filepath =\
          join(
            dirname(__file__),
            'test_vectors/generate_multi_trytes_and_hash.csv',
          )

        with open(filepath, 'r') as f:
            reader = DictReader(f)
            for count, line in enumerate(reader):
                trytes = line['multiTrytes']
                hashes = line['Kerl_hash']

                trits = trytes_to_trits(trytes)

                kerl = Kerl()
                kerl.absorb(trits)
                trits_out = []
                kerl.squeeze(trits_out)

                trytes_out = trits_to_trytes(trits_out)

                self.assertEqual(
                    hashes,
                    trytes_out,
                    msg='line {count}: {hashes} != {trytes}'.format(
                        count=count + 2,
                        hashes=hashes,
                        trytes=trytes_out,
                    ),
                )
Exemplo n.º 2
0
    def test_correct_first(self):
        # noinspection SpellCheckingInspection
        inp = ('EMIDYNHBWMBCXVDEFOFWINXTERALUKYYPPHKP9JJ'
               'FGJEIUY9MUDVNFZHMMWZUYUSWAIOWEVTHNWMHANBH')

        trits = trytes_to_trits(inp)

        kerl = Kerl()
        kerl.absorb(trits)
        trits_out = []
        kerl.squeeze(trits_out)

        trytes_out = trits_to_trytes(trits_out)

        # noinspection SpellCheckingInspection
        self.assertEqual(
            trytes_out,
            'EJEAOOZYSAWFPZQESYDHZCGYNSTWXUMVJOVDWUNZ'
            'JXDGWCLUFGIMZRMGCAZGKNPLBRLGUNYWKLJTYEAQX',
        )