Exemple #1
0
 def test_create_account_password(self):
     bts = Hive(node=get_hive_nodes(),
                 nobroadcast=True,
                 unsigned=True,
                 data_refresh_time_seconds=900,
                 keys={"active": wif, "owner": wif2, "memo": wif3},
                 num_retries=10)
     core_unit = "STM"
     name = ''.join(random.choice(string.ascii_lowercase) for _ in range(12))
     key5 = PrivateKey()
     bts.txbuffer.clear()
     tx = bts.create_account(
         name,
         creator="test",   # 1.2.7
         password="******",
         additional_owner_keys=[format(key5.pubkey, core_unit)],
         additional_active_keys=[format(key5.pubkey, core_unit)],
         additional_posting_keys=[format(key5.pubkey, core_unit)],
         additional_owner_accounts=["test1"],  # 1.2.0
         additional_active_accounts=["test1"],
         storekeys=False,
     )
     if isinstance(tx["operations"][0], list):
         self.assertEqual(
             tx["operations"][0][0],
             "account_create"
         )
         op = tx["operations"][0][1]
     else:
         self.assertEqual(
             tx["operations"][0]["type"],
             "account_create_operation"
         )
         op = tx["operations"][0]["value"]        
     role = "active"
     self.assertIn(
         format(key5.pubkey, core_unit),
         [x[0] for x in op[role]["key_auths"]])
     self.assertIn(
         format(key5.pubkey, core_unit),
         [x[0] for x in op[role]["key_auths"]])
     self.assertIn(
         "test1",
         [x[0] for x in op[role]["account_auths"]])
     role = "owner"
     self.assertIn(
         format(key5.pubkey, core_unit),
         [x[0] for x in op[role]["key_auths"]])
     self.assertIn(
         format(key5.pubkey, core_unit),
         [x[0] for x in op[role]["key_auths"]])
     self.assertIn(
         "test1",
         [x[0] for x in op[role]["account_auths"]])
     self.assertEqual(
         op["creator"],
         "test")
Exemple #2
0
 def test_create_account(self):
     bts = Hive(node=self.nodelist.get_hive_nodes(),
                nobroadcast=True,
                unsigned=True,
                data_refresh_time_seconds=900,
                keys={
                    "active": wif,
                    "owner": wif,
                    "memo": wif
                },
                num_retries=10)
     core_unit = "STM"
     name = ''.join(
         random.choice(string.ascii_lowercase) for _ in range(12))
     key1 = PrivateKey()
     key2 = PrivateKey()
     key3 = PrivateKey()
     key4 = PrivateKey()
     key5 = PrivateKey()
     bts.txbuffer.clear()
     tx = bts.create_account(
         name,
         creator="test",  # 1.2.7
         owner_key=format(key1.pubkey, core_unit),
         active_key=format(key2.pubkey, core_unit),
         posting_key=format(key3.pubkey, core_unit),
         memo_key=format(key4.pubkey, core_unit),
         additional_owner_keys=[format(key5.pubkey, core_unit)],
         additional_active_keys=[format(key5.pubkey, core_unit)],
         additional_posting_keys=[format(key5.pubkey, core_unit)],
         additional_owner_accounts=["test1"],  # 1.2.0
         additional_active_accounts=["test2"],
         additional_posting_accounts=["test3"],
         storekeys=False,
     )
     self.assertEqual(tx["operations"][0][0], "account_create")
     op = tx["operations"][0][1]
     role = "active"
     self.assertIn(format(key5.pubkey, core_unit),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn(format(key5.pubkey, core_unit),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn("test2", [x[0] for x in op[role]["account_auths"]])
     role = "posting"
     self.assertIn(format(key5.pubkey, core_unit),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn(format(key5.pubkey, core_unit),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn("test3", [x[0] for x in op[role]["account_auths"]])
     role = "owner"
     self.assertIn(format(key5.pubkey, core_unit),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn(format(key5.pubkey, core_unit),
                   [x[0] for x in op[role]["key_auths"]])
     self.assertIn("test1", [x[0] for x in op[role]["account_auths"]])
     self.assertEqual(op["creator"], "test")
    try:
        if node is None or node.is_running():
            node_client = Hive(node = [node_url], no_broadcast = False, 
                keys = keys
            )

            logger.info("Chain prefix is: {}".format(node_client.prefix))
            logger.info("Chain ID is: {}".format(node_client.get_config()["HIVE_CHAIN_ID"]))

            # create test account
            logger.info("Creating account: {}".format(accounts[0]['name']))
            node_client.create_account(accounts[0]['name'], 
                owner_key=accounts[0]['public_key'], 
                active_key=accounts[0]['public_key'], 
                posting_key=accounts[0]['public_key'],
                memo_key=accounts[0]['public_key'],
                store_keys = False,
                creator=args.creator,
                asset='TESTS'
            )
            hive_utils.common.wait_n_blocks(node_client.rpc.url, 5)

            transfer_to_vesting(node_client, args.creator, accounts, "300.000", 
                "TESTS"
            )

            transfer_assets_to_accounts(node_client, args.creator, accounts, 
                "400.000", "TESTS",
            )

            transfer_assets_to_accounts(node_client, args.creator, accounts,