def test_finalizeOps_changeproposer_new(self):
     proposal = dexstore.proposal(proposer="init5")
     dexstore.transfer("init1", 1, "DST", append_to=proposal)
     tx = dexstore.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.90747")
     self.assertEqual(
         getOperationNameForId(prop["proposed_ops"][0]["op"][0]),
         "transfer")
 def test_finalizeOps_proposal2(self):
     proposal = dexstore.new_proposal()
     # proposal = dexstore.proposal()
     dexstore.transfer("init1", 1, "DST", append_to=proposal)
     tx = dexstore.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")
 def test_update_memo_key(self):
     tx = dexstore.update_memo_key(
         "DST55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n")
     self.assertEqual(getOperationNameForId(tx["operations"][0][0]),
                      "account_update")
     op = tx["operations"][0][1]
     self.assertEqual(
         op["new_options"]["memo_key"],
         "DST55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n")
Example #4
0
 def test_account_upgrade(self):
     account = Account("init0")
     pprint(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.100")
 def test_finalizeOps_combined_proposal(self):
     parent = dexstore.new_tx()
     proposal = dexstore.new_proposal(parent)
     dexstore.transfer("init1", 1, "DST", append_to=proposal)
     dexstore.transfer("init1", 1, "DST", 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")
 def test_transfer(self):
     tx = dexstore.transfer("1.2.101",
                            1.33,
                            "DST",
                            memo="Foobar",
                            account="init0")
     self.assertEqual(getOperationNameForId(tx["operations"][0][0]),
                      "transfer")
     op = tx["operations"][0][1]
     self.assertIn("memo", op)
     self.assertEqual(op["from"], "1.2.100")
     self.assertEqual(op["to"], "1.2.101")
     amount = Amount(op["amount"])
     self.assertEqual(float(amount), 1.33)
 def test_allow(self):
     tx = dexstore.allow(
         "DST55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n",
         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(
         ["DST55VCzsb47NZwWe5F3qyQKedX9iHBHMVVFSc96PDvV7wuj7W86n", '1'],
         op["owner"]["key_auths"])
     self.assertEqual(op["owner"]["weight_threshold"], 1)
 def test_create_account(self):
     name = ''.join(
         random.choice(string.ascii_lowercase) for _ in range(12))
     key1 = PrivateKey()
     key2 = PrivateKey()
     key3 = PrivateKey()
     key4 = PrivateKey()
     tx = dexstore.create_account(
         name,
         registrar="init0",  # 1.2.100
         referrer="init1",  # 1.2.101
         referrer_percent=33,
         owner_key=format(key1.pubkey, "DST"),
         active_key=format(key2.pubkey, "DST"),
         memo_key=format(key3.pubkey, "DST"),
         additional_owner_keys=[format(key4.pubkey, "DST")],
         additional_active_keys=[format(key4.pubkey, "DST")],
         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, "DST"),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn(format(key4.pubkey, "DST"),
                   [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, "DST"),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn(format(key4.pubkey, "DST"),
                   [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.100")
     self.assertEqual(op["registrar"], "1.2.100")
     self.assertEqual(op["referrer"], "1.2.101")
     self.assertEqual(op["referrer_percent"], 33 * 100)
 def test_approvecommittee(self):
     tx = dexstore.approvecommittee("1.5.0")
     self.assertEqual(getOperationNameForId(tx["operations"][0][0]),
                      "account_update")
     op = tx["operations"][0][1]
     self.assertIn("0:11", op["new_options"]["votes"])
 def test_approvewitness(self):
     tx = dexstore.approvewitness("1.6.1")
     self.assertEqual(getOperationNameForId(tx["operations"][0][0]),
                      "account_update")
     op = tx["operations"][0][1]
     self.assertIn("1:0", op["new_options"]["votes"])