def test_not_equal(self): a1 = Account('a1') a1.generateKeys() a2 = Account('a1') a2.generateKeys() self.assertFalse(a1.equals(a2),"Accounts should be different!")
def createNewAccount(self, name): if name != '' and name in self.name_to_account: debugging.error("There is already an account named %s. Please use a different name.", name) account = Account(name) account.generateKeys() self.__addAccount(account) return account
def test_signature(self): message = b'Suck my dick.' account = Account('Felatio') account.generateKeys() signature = account.sign(message) logging.debug('signature: %s',signature.hex()) sig_valid = accounts.isValid( account.getPublicKey(), message, signature ) self.assertTrue(sig_valid, "Signature not valid!")
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!")
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!")