| 1 |
import os |
| 2 |
|
| 3 |
from electrum.simple_config import SimpleConfig |
| 4 |
from electrum.wallet import Abstract_Wallet |
| 5 |
from electrum.daemon import Daemon |
| 6 |
|
| 7 |
from . import ElectrumTestCase |
| 8 |
from . import restore_wallet_from_text__for_unittest |
| 9 |
|
| 10 |
|
| 11 |
class TestContacts(ElectrumTestCase): |
| 12 |
TESTNET = True |
| 13 |
|
| 14 |
def setUp(self): |
| 15 |
super().setUp() |
| 16 |
self.config = SimpleConfig({'electrum_path': self.electrum_path}) |
| 17 |
self.wallet_path = os.path.join(self.electrum_path, "somewallet1") |
| 18 |
|
| 19 |
async def test_saving_contacts(self): |
| 20 |
text = 'cross end slow expose giraffe fuel track awake turtle capital ranch pulp' |
| 21 |
d = restore_wallet_from_text__for_unittest(text, path=self.wallet_path, config=self.config) |
| 22 |
w = d['wallet'] |
| 23 |
w.contacts["myNNuLYNgHE92nGQuJd5mXo6gy9gKXEDyQ"] = ("address", "alice") |
| 24 |
w.contacts["tb1q4syjltptqwhe62t3u5gwz9nsw87kmcwx003z05"] = ("address", "bob") |
| 25 |
self.assertEqual(2, len(w.contacts)) |
| 26 |
await w.stop() |
| 27 |
del w |
| 28 |
|
| 29 |
w = Daemon._load_wallet(self.wallet_path, password=None, config=self.config) |
| 30 |
self.assertEqual(2, len(w.contacts)) |
| 31 |
w.contacts["n4STqqWPrvkapAyvXY2wJzfoKMnuJbDWoH"] = ("address", "carol") |
| 32 |
self.assertEqual(3, len(w.contacts)) |