コード例 #1
0
 def test_finalizeOps_proposal2(self):
     bts = self.bts
     proposal = bts.new_proposal()
     # proposal = bts.proposal()
     self.bts.transfer("init1", 1, "TEST", append_to=proposal)
     tx = bts.tx().json()  # default tx buffer
     ops = tx["operations"]
     self.assertEqual(len(ops), 1)
     self.assertEqual(getOperationNameForId(ops[0][0]), "proposal_create")
     prop = ops[0][1]
     self.assertEqual(len(prop["proposed_ops"]), 1)
     self.assertEqual(
         getOperationNameForId(prop["proposed_ops"][0]["op"][0]),
         "transfer")
コード例 #2
0
 def test_finalizeOps_changeproposer_new(self):
     bts = self.bts
     proposal = bts.proposal(proposer="init5")
     bts.transfer("init1", 1, "TEST", append_to=proposal)
     tx = bts.tx().json()
     ops = tx["operations"]
     self.assertEqual(len(ops), 1)
     self.assertEqual(getOperationNameForId(ops[0][0]), "proposal_create")
     prop = ops[0][1]
     self.assertEqual(len(prop["proposed_ops"]), 1)
     self.assertEqual(prop["fee_paying_account"], "1.2.11")
     self.assertEqual(
         getOperationNameForId(prop["proposed_ops"][0]["op"][0]),
         "transfer")
コード例 #3
0
 def test_finalizeOps_combined_proposal(self):
     bts = self.bts
     parent = bts.new_tx()
     proposal = bts.new_proposal(parent)
     self.bts.transfer("init1", 1, "TEST", append_to=proposal)
     self.bts.transfer("init1", 1, "TEST", append_to=parent)
     tx = parent.json()
     ops = tx["operations"]
     self.assertEqual(len(ops), 2)
     self.assertEqual(getOperationNameForId(ops[0][0]), "proposal_create")
     self.assertEqual(getOperationNameForId(ops[1][0]), "transfer")
     prop = ops[0][1]
     self.assertEqual(len(prop["proposed_ops"]), 1)
     self.assertEqual(
         getOperationNameForId(prop["proposed_ops"][0]["op"][0]),
         "transfer")
コード例 #4
0
 def test_approvecommittee(self):
     bts = self.bts
     tx = bts.approvecommittee("init0")
     self.assertEqual(getOperationNameForId(tx["operations"][0][0]),
                      "account_update")
     op = tx["operations"][0][1]
     self.assertIn("0:11", op["new_options"]["votes"])
コード例 #5
0
    def ops(self, start=None, stop=None, **kwargs):
        """ Yields all operations (including virtual operations) starting from
            ``start``.

            :param int start: Starting block
            :param int stop: Stop at this block
            :param str mode: We here have the choice between
             "head" (the last block) and "irreversible" (the block that is
             confirmed by 2/3 of all block producers and is thus irreversible)
            :param bool only_virtual_ops: Only yield virtual operations

            This call returns a list that only carries one operation and
            its type!
        """

        for block in self.blocks(start=start, stop=stop, **kwargs):
            for tx in block["transactions"]:
                for op in tx["operations"]:
                    # Replace opid by op name
                    op[0] = getOperationNameForId(op[0])
                    yield {
                        "block_num": block["block_num"],
                        "op": op,
                        "timestamp": block["timestamp"]
                    }
コード例 #6
0
 def test_update_memo_key(self):
     bts = self.bts
     tx = bts.update_memo_key(
         "TEST55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n")
     self.assertEqual(getOperationNameForId(tx["operations"][0][0]),
                      "account_update")
     op = tx["operations"][0][1]
     self.assertEqual(
         op["new_options"]["memo_key"],
         "TEST55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n")
コード例 #7
0
 def test_account_upgrade(self):
     account = Account("witness-account")
     tx = account.upgrade()
     ops = tx["operations"]
     op = ops[0][1]
     self.assertEqual(len(ops), 1)
     self.assertEqual(getOperationNameForId(ops[0][0]), "account_upgrade")
     self.assertTrue(op["upgrade_to_lifetime_member"])
     self.assertEqual(
         op["account_to_upgrade"],
         "1.2.1",
     )
コード例 #8
0
 def test_transfer(self):
     bts = self.bts
     tx = bts.transfer("1.2.8",
                       1.33,
                       core_unit,
                       memo="Foobar",
                       account="1.2.7")
     self.assertEqual(getOperationNameForId(tx["operations"][0][0]),
                      "transfer")
     op = tx["operations"][0][1]
     self.assertIn("memo", op)
     self.assertEqual(op["from"], "1.2.7")
     self.assertEqual(op["to"], "1.2.8")
     amount = Amount(op["amount"])
     self.assertEqual(float(amount), 1.33)
コード例 #9
0
 def test_allow(self):
     bts = self.bts
     tx = bts.allow(
         "TEST55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n",
         weight=1,
         threshold=1,
         permission="owner")
     self.assertEqual(getOperationNameForId(tx["operations"][0][0]),
                      "account_update")
     op = tx["operations"][0][1]
     self.assertIn("owner", op)
     self.assertIn(
         ["TEST55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n", '1'],
         op["owner"]["key_auths"])
     self.assertEqual(op["owner"]["weight_threshold"], 1)
コード例 #10
0
 def test_create_account(self):
     bts = self.bts
     name = ''.join(
         random.choice(string.ascii_lowercase) for _ in range(12))
     key1 = PrivateKey()
     key2 = PrivateKey()
     key3 = PrivateKey()
     key4 = PrivateKey()
     tx = bts.create_account(
         name,
         registrar="init0",  # 1.2.7
         referrer="init1",  # 1.2.8
         referrer_percent=33,
         owner_key=format(key1.pubkey, core_unit),
         active_key=format(key2.pubkey, core_unit),
         memo_key=format(key3.pubkey, core_unit),
         additional_owner_keys=[format(key4.pubkey, core_unit)],
         additional_active_keys=[format(key4.pubkey, core_unit)],
         additional_owner_accounts=["committee-account"],  # 1.2.0
         additional_active_accounts=["committee-account"],
         proxy_account="init0",
         storekeys=False)
     self.assertEqual(getOperationNameForId(tx["operations"][0][0]),
                      "account_create")
     op = tx["operations"][0][1]
     role = "active"
     self.assertIn(format(key4.pubkey, core_unit),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn(format(key4.pubkey, core_unit),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn("1.2.0", [x[0] for x in op[role]["account_auths"]])
     role = "owner"
     self.assertIn(format(key4.pubkey, core_unit),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn(format(key4.pubkey, core_unit),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn("1.2.0", [x[0] for x in op[role]["account_auths"]])
     self.assertEqual(op["options"]["voting_account"], "1.2.6")
     self.assertEqual(op["registrar"], "1.2.6")
     self.assertEqual(op["referrer"], "1.2.7")
     self.assertEqual(op["referrer_percent"], 33 * 100)