Example #1
0
    def test_marshalling(self):
        # Create an account and convert it to bytes
        in_name = 'Love that hard c**k!'
        account = Account('Visual')
        account.generateKeys()
        logging.debug('Before marshal %s', account)
        buffer = account.toBytes()
#        print('test_marshalling:',buffer.hex())
        logging.debug('Marshalled buffer: %s', buffer.hex())
        # Create a new account from the bytes
        new_account = Account('')
        new_account.fromBytes(buffer)
        logging.debug('Unmarshalled %s', account)
        # Check if they have the content
        self.assertTrue(new_account.equals(account))

        # Different names should be okay, if all else is the same
        new_name = 'resurected!'
        new_account.setName(new_name)
        self.assertEqual(new_name, new_account.getName(),'Account name not set correctly!')
        self.assertTrue(new_account.equals(account), "Names should not affect Account equality!")
Example #2
0
    def test_newAccount(self, mock_object1, mockobject2):
        # Create a new accounts
        name = 'test new account'
        account = Account(name)

        # Generate the keys
        account.generateKeys()

        private_key = account.getPrivateKey()
        public_key = account.getPublicKey()
        address = account.getAddress()
        b58address = account.getB58Address()
        set_name = account.getName()

        logging.debug('new %s', account)

        self.assertEqual(private_key.hex(), '1bf1cd4065d7ad80f01b271dcf3121112e97e2553b25a5dad5bfd5cc540f654c', "Incorrect private key!")
        self.assertEqual(public_key.hex(), '1bf1cd4065d7ad80f01b271dcf3121112e97e2553b25a5dad5bfd5cc540f654c', "Incorrect public key!")
        self.assertEqual(address.hex(),'2447daf348074b76b36fbc9ec15f154f5d487a37', "Incorrect address!")
        self.assertEqual(b58address, '14JqQVsxQDSewkkQrJuvCbhZuSHWC2CunJ', "Incorrect b58 address!")
        self.assertEqual(name, set_name, "Incorrect name!")