test_account.py (1030B)
1 # standard imports 2 import unittest 3 import copy 4 5 # local imports 6 from taint.account import Account 7 8 # test imports 9 from tests.base import TestBase 10 11 12 class TestAccount(TestBase): 13 14 def test_account_compare(self): 15 alice = self.alice 16 alice_again = copy.copy(self.alice) 17 self.assertTrue(alice.is_same(alice_again)) 18 19 alice_alias = Account(self.chain_spec, self.alice.account_src) 20 self.assertTrue(alice.is_same(alice_alias)) 21 22 self.assertFalse(alice.is_same(self.bob)) 23 24 25 def test_connect_accounts(self): 26 self.alice.connect(self.bob) 27 self.assertEqual(self.alice.tags.get(), self.bob.tags.get()) 28 29 30 31 def test_serialize(self): 32 self.alice.tags.create(b'xyzzy') 33 z = self.alice.tags.get() 34 35 b = self.alice.serialize() 36 self.assertEqual(b[len(b)-32:], self.alice.account) 37 38 new_alice = Account.from_serialized(b, self.chain_spec) 39 self.assertTrue(new_alice.is_same(self.alice)) 40 41 42 if __name__ == '__main__': 43 unittest.main()