示例#1
0
    def setUp(self):
        self.setUpQuamash()
        QLocale.setDefault(QLocale("en_GB"))
        self.identities_registry = IdentitiesRegistry({})

        self.application = Application(self.qapplication, self.lp, self.identities_registry)
        self.application.preferences['notifications'] = False

        self.endpoint = BMAEndpoint("", "127.0.0.1", "", 50005)
        self.node = Node("test_currency", [self.endpoint],
                         "", "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk",
                         nice_blockchain.bma_blockchain_current, Node.ONLINE,
                         time.time(), {}, "duniter", "0.14.0", 0)
        self.network = Network.create(self.node)
        self.bma_access = BmaAccess.create(self.network)
        self.community = Community("test_currency", self.network, self.bma_access)

        self.wallet = Wallet(0, "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
                             "Wallet 1", self.identities_registry)
        self.wallet.init_cache(self.application, self.community)

        # Salt/password : "******"
        # Pubkey : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ
        self.account = Account("testsakia", "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
                               "john", [self.community], [self.wallet], [], self.identities_registry)
示例#2
0
    def test_load_save_wallet(self):
        wallet = Wallet(0, "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
                        "Wallet 1", self.identities_registry)

        json_data = wallet.jsonify()
        wallet_from_json = Wallet.load(json_data, self.identities_registry)
        self.assertEqual(wallet.walletid, wallet_from_json.walletid)
        self.assertEqual(wallet.pubkey, wallet_from_json.pubkey)
        self.assertEqual(wallet.name, wallet_from_json.name)
        self.assertEqual(wallet._identities_registry,
                         wallet_from_json._identities_registry)
示例#3
0
    def setUp(self):
        self.setUpQuamash()
        QLocale.setDefault(QLocale("en_GB"))
        self.identities_registry = IdentitiesRegistry({})

        self.application = Application(self.qapplication, self.lp,
                                       self.identities_registry)
        self.application.preferences['notifications'] = False

        self.mock_new_community = init_new_community.get_mock(self.lp)

        self.endpoint = BMAEndpoint("", "127.0.0.1", "", 50010)
        self.node = Node(self.mock_new_community.peer(),
                         "",
                         "HnFcSms8jzwngtVomTTnzudZx7SHUQY8sVE1y8yBmULk",
                         None,
                         Node.ONLINE,
                         time.time(), {},
                         "duniter",
                         "0.14.0",
                         0,
                         session=aiohttp.ClientSession())
        self.network = Network.create(self.node)
        self.bma_access = BmaAccess.create(self.network)
        self.community = Community("test_currency", self.network,
                                   self.bma_access)

        self.wallet = Wallet(0, "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
                             "Wallet 1", self.identities_registry)

        # Salt/password : "******"
        # Pubkey : 7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ
        self.account = Account("testsakia",
                               "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
                               "john", [self.community], [self.wallet], [],
                               self.identities_registry)
        self.account.notifications['warning_certifying_first_time'] = False
        self.password_asker = PasswordAskerDialog(self.account)
        self.password_asker.password = "******"
        self.password_asker.remember = True
示例#4
0
 def test_prepare_tx_base_0(self):
     community = MagicMock("sakia.core.Community")
     community.currency = "test_currency"
     cache = MagicMock("sakia.core.txhistory.TxHistory")
     cache.available_sources = [{
         "pubkey": "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
         "type": "D",
         "noffset": 2,
         "identifier":
         "FCAD5A388AC8A811B45A9334A375585E77071AA9F6E5B6896582961A6C66F365",
         "amount": 15,
         "base": 0
     }, {
         "pubkey": "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
         "type": "D",
         "noffset": 4,
         "identifier":
         "A0AC57E2E4B24D66F2D25E66D8501D8E881D9E6453D1789ED753D7D426537ED5",
         "amount": 85,
         "base": 0
     }, {
         "pubkey": "FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn",
         "type": "T",
         "noffset": 4,
         "identifier":
         "7518C700E78B56CC21FB1DDC6CBAB24E0FACC9A798F5ED8736EA007F38617D67",
         "amount": 11,
         "base": 1
     }]
     wallet = Wallet(0, "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ",
                     "Wallet 1", self.identities_registry)
     wallet.caches["test_currency"] = cache
     tx = wallet.prepare_tx(
         "FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn",
         BlockUID(32, "000005E0F228038E4DDD4F6CA4ACB01EC88FBAF8"), 99, "",
         community)
     self.assertEqual(tx.version, 3)
     self.assertEqual(tx.blockstamp.number, 32)
     self.assertEqual(tx.blockstamp.sha_hash,
                      "000005E0F228038E4DDD4F6CA4ACB01EC88FBAF8")
     self.assertEqual(len(tx.issuers), 1)
     self.assertEqual(tx.issuers[0],
                      "7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ")
     self.assertEqual(len(tx.inputs), 2)
     self.assertEqual(
         tx.inputs[0].origin_id,
         "FCAD5A388AC8A811B45A9334A375585E77071AA9F6E5B6896582961A6C66F365")
     self.assertEqual(tx.inputs[0].source, "D")
     self.assertEqual(tx.inputs[0].index, 2)
     self.assertEqual(
         tx.inputs[1].origin_id,
         "A0AC57E2E4B24D66F2D25E66D8501D8E881D9E6453D1789ED753D7D426537ED5")
     self.assertEqual(tx.inputs[1].source, "D")
     self.assertEqual(tx.inputs[1].index, 4)
     self.assertEqual(len(tx.outputs), 2)
     self.assertEqual(tx.outputs[0].amount, 99)
     self.assertEqual(tx.outputs[0].base, 0)
     self.assertEqual(
         pypeg2.compose(tx.outputs[0].conditions, output.Condition),
         "SIG(FADxcH5LmXGmGFgdixSes6nWnC4Vb4pRUBYT81zQRhjn)")
     self.assertEqual(tx.outputs[1].amount, 1)
     self.assertEqual(tx.outputs[1].base, 0)
     self.assertEqual(
         pypeg2.compose(tx.outputs[1].conditions, output.Condition),
         "SIG(7Aqw6Efa9EzE7gtsc8SveLLrM7gm6NEGoywSv4FJx6pZ)")
     self.assertEqual(len(tx.unlocks), 2)
     self.assertEqual(tx.unlocks[0].index, 0)
     self.assertEqual(tx.unlocks[0].parameters[0].index, 0)
     self.assertEqual(tx.unlocks[1].index, 1)
     self.assertEqual(tx.unlocks[0].parameters[0].index, 0)