Beispiel #1
0
    def test_44_get_storage(self):
        script_hash = ""
        key = self.m_getstorage_contract_key

        logger.open("restful/44_get_storage.log", "44_get_storage")
        (result, response) = RestfulApi().getstorage(script_hash, key)
        logger.close(not result)
Beispiel #2
0
    def test_48_get_storage(self):
        script_hash = self.m_getstorage_contract_addr
        key = self.m_getstorage_contract_key + "1111"

        logger.open("restful/48_get_storage.log", "48_get_storage")
        (result, response) = RestfulApi().getstorage(script_hash, key)
        logger.close(result)
Beispiel #3
0
    def test_54_get_contract_state(self):
        script_hash = self.m_contractaddr_wrong

        logger.open("restful/54_get_contract_state.log",
                    "54_get_contract_state")
        (result, response) = RestfulApi().getcontract(script_hash)
        logger.close(not result)
Beispiel #4
0
 def test_04_get_conn_count(self):
     stop_nodes([1, 2, 3, 4, 5, 6])
     logger.open("restful/04_get_conn_count.log", "04_get_conn_count")
     (result, response) = RestfulApi().getconnectioncount()
     logger.close(result and int(response["result"]) == 0)
     start_nodes([1, 2, 3, 4, 5, 6], Config.DEFAULT_NODE_ARGS, True, True)
     time.sleep(10)
Beispiel #5
0
    def test_17_consensus(self):
        result = False
        logger.open("17_consensus.log", "17_consensus")
        storage_key = ByteToHex(b'Test Key 17')
        storage_value = ByteToHex(b'Test Value 17')
        try:
            (result,
             response) = invoke_function(self.m_contract_addr,
                                         "put",
                                         "",
                                         "1",
                                         argvs=[{
                                             "type": "bytearray",
                                             "value": storage_key
                                         }, {
                                             "type": "bytearray",
                                             "value": storage_value
                                         }],
                                         node_index=self.m_current_node)
            if not result:
                raise Error("invoke_function put error...")

            result = check_node_state([0, 1, 2, 3, 4, 5, 6])
        except Exception as e:
            print(e.msg)
            result = False
        logger.close(result)
Beispiel #6
0
    def test_67_get_blk_hgt_by_txhash(self):
        hash = self.m_txhash_wrong

        logger.open("restful/67_get_blk_hgt_by_txhash.log",
                    "67_get_blk_hgt_by_txhash")
        (result, response) = RestfulApi().getblockheightbytxhash(hash)
        logger.close(not result)
Beispiel #7
0
    def test_08_consensus(self):
        stopnodes = self.m_stop_2_nodes
        stop_nodes(stopnodes)
        result = False
        logger.open("08_consensus.log", "08_consensus")
        try:
            (result,
             response) = transfer(self.m_contract_addr,
                                  Config.NODES[self.m_current_node]["address"],
                                  Config.NODES[1]["address"], self.AMOUNT,
                                  self.m_current_node)
            if not result:
                raise Error("transfer error...")

            (result,
             response) = RPCApi().getblockheightbytxhash(response["txhash"])
            if not result:
                raise Error("not a valid block...")

        except Exception as e:
            print(e.msg)
            result = False
        logger.close(result)

        start_nodes(stopnodes, Config.DEFAULT_NODE_ARGS)
        time.sleep(3)
Beispiel #8
0
    def test_13_consensus(self):
        result = False
        logger.open("13_consensus.log", "13_consensus")
        storage_key = ByteToHex(b'Test Key 13')
        storage_value = ByteToHex(b'Test Value 13')
        try:
            for i in range(1, 4):
                self.init_bft_node(i)
                time.sleep(30)
                for j in range(10):
                    (result, response) = invoke_function(
                        self.m_contract_addr,
                        "put",
                        "",
                        "1",
                        argvs=[{
                            "type": "bytearray",
                            "value": storage_key
                        }, {
                            "type": "bytearray",
                            "value": storage_value
                        }],
                        node_index=self.m_current_node)
                    if not result:
                        raise Error("invoke_function put error...")
                    time.sleep(10)

        except Exception as e:
            print(e.msg)
            result = False
        logger.close(result)
Beispiel #9
0
    def test_10_consensus(self):
        result = False
        storage_key = ByteToHex(b'Test Key 10')
        storage_value = ByteToHex(b'Test Value 10')
        logger.open("10_consensus.log", "10_consensus")
        try:
            for i in range(1, 4):
                self.init_bft_node(i)
                time.sleep(30)
                (result,
                 response) = invoke_function(self.m_contract_addr,
                                             "put",
                                             "",
                                             "1",
                                             argvs=[{
                                                 "type": "bytearray",
                                                 "value": storage_key
                                             }, {
                                                 "type": "bytearray",
                                                 "value": storage_value
                                             }],
                                             node_index=self.m_current_node)
                if not result:
                    raise Error("invoke_function error...")

                (result, response) = RPCApi().getblockheightbytxhash(
                    response["txhash"])
                if not result:
                    raise Error("not a valid block...")

        except Exception as e:
            print(e.msg)
            result = False
        logger.close(result)
Beispiel #10
0
 def setUp(self):
     logger.open("test_rpc/" + self._testMethodName + ".log",
                 self._testMethodName)
     API.node().stop_all_nodes()
     API.node().start_nodes([0, 1, 2, 3, 4, 5, 6], Config.DEFAULT_NODE_ARGS,
                            True, True)
     time.sleep(5)
Beispiel #11
0
    def test_main(self):
        result = False
        logger.open("TestGover7.log", "TestGover7")
        try:
            if (not pause(
                    "ensure that node A and node B is in the nodes network and node A has more than 10000 ont."
            )):
                raise Error("pre-condition unsatisfied")

            (wallet_A_address, wallet_B_address, vote_price,
             node_B_puiblic_key, blocks_per_round,
             punish_ratio) = get_config()
            consensus_rounds = (int)(getblockcount() / blocks_per_round)

            # step 1 wallet A vote for node B
            (result, response) = vote_for_peer(wallet_A_address,
                                               [node_B_puiblic_key],
                                               [vote_price])
            print(response)
            #if not result:
            #	raise Error("vote error")

            # step 2 wallet A unvote in the second round
            while (True):
                if (getblockcount() / blocks_per_round -
                        consensus_rounds == 1):
                    (result,
                     response) = unvote_for_peer(wallet_A_address,
                                                 [node_B_puiblic_key],
                                                 [vote_price])
                    break
                else:
                    time.sleep(5)
                    continue
            #if not result:
            #	raise Error("unvote error")

            # step 3 wallet A withdraw ont in the third round
            while (True):
                if (getblockcount() / blocks_per_round -
                        consensus_rounds == 2):
                    (result, response) = withdraw_ont(wallet_A_address,
                                                      [node_B_puiblic_key],
                                                      [vote_price])
                    break
                else:
                    time.sleep(5)
                    continue
            #if not result:
            #	raise Error("withdraw_ont error")

            # this should be failed
            (result, response) = withdraw_ont(wallet_A_address,
                                              [node_B_puiblic_key], ["1"])
            #if not result:
            #	raise Error("withdraw_ont error")

        except Exception as e:
            print(e.msg)
        logger.close(result)
Beispiel #12
0
    def test_gov_16(self):
        result = False
        logger.open("TestGover16.log", "TestGover16")
        try:
            (wallet_A_address, wallet_B_address, vote_price,
             node_B_puiblic_key, blocks_per_round,
             punish_ratio) = get_config()

            invoke_function_update("updateGlobalParam", "2000000000", "10000",
                                   "32", "10", "50", "50", "50", "50")

            # step 1 wallet A vote for node B
            (result,
             response) = vote_for_peer_index(Config.NODES[8]["address"],
                                             [node_B_puiblic_key], ["90000"],
                                             8)
            print(response)
            #if not result:
            #	raise Error("vote_for_peer error")

            # step 1 wallet A vote for node B
            (result, response) = vote_for_peer_index(wallet_A_address,
                                                     [node_B_puiblic_key],
                                                     ["10001"])
            print(response)
            #if not result:
            #	raise Error("vote_for_peer error")

        except Exception as e:
            print(e.msg)
        logger.close(result)
Beispiel #13
0
	def test_main(self):
		result = False
		logger.open("TestGover14.log", "TestGover14")
		try:
			if (not pause("ensure that node A and node B is in the nodes network and node A has more than 10000 ont.")):
				raise Error("pre-condition unsatisfied")

			(wallet_A_address, wallet_B_address, vote_price, node_B_puiblic_key, blocks_per_round, punish_ratio) = get_config()			
			'''
			# to ensure that the following operations are in the same round
			while(True):
				if getblockcount() % blocks_per_round <= 2:
					time.sleep(1)
					continue
				else:
					break
			'''

			# step 1 wallet A vote for node B
			(result, response) = vote_for_peer(wallet_A_address, ["03e05d01e5df2c85e6a9a5526c70d080b6c7dce0fa7c66f8489c18b8569dc269dc"], ["190000"])
			print (response)
			#if not result:
			#	raise Error("vote_for_peer error")

			# step 1 wallet A vote for node B
			(result, response) = vote_for_peer(wallet_A_address, ["03e05d01e5df2c85e6a9a5526c70d080b6c7dce0fa7c66f8489c18b8569dc269dc"], ["10000"])
			print (response)
			#if not result:
			#	raise Error("vote_for_peer error")
			
			
		
		except Exception as e:
			print(e.msg)
		logger.close(result)
Beispiel #14
0
    def test_12_consensus(self):
        result = False
        logger.open("12_consensus.log", "12_consensus")
        storage_key = ByteToHex(b'Test Key 12')
        storage_value = ByteToHex(b'Test Value 12')
        try:
            for i in range(1, 4):
                self.init_bft_node(i)
                time.sleep(30)

                #A节点是Admin节点
                (result, response) = init_admin(self.m_contract_addr,
                                                Config.ontID_A)
                if not result:
                    raise Error("init_admin error...")

                (result,
                 response) = bind_role_function(self.m_contract_addr,
                                                Config.ontID_A,
                                                Config.roleA_hex, ["auth_put"])
                if not result:
                    raise Error("bind_role_function error...")

                (result, response) = invoke_function(self.m_contract_addr,
                                                     "auth_put",
                                                     Config.ontID_B,
                                                     "1",
                                                     argvs=[{
                                                         "type":
                                                         "bytearray",
                                                         "value":
                                                         storage_key
                                                     }, {
                                                         "type":
                                                         "bytearray",
                                                         "value":
                                                         storage_value
                                                     }])
                if not result:
                    raise Error("invoke_function put error...")

                (result, response) = invoke_function(self.m_contract_addr,
                                                     "get",
                                                     Config.ontID_B,
                                                     "1",
                                                     argvs=[{
                                                         "type":
                                                         "bytearray",
                                                         "value":
                                                         storage_key
                                                     }])
                if response["result"]["Result"] != '':
                    result = False
                    raise Error("invoke_function get error...")

        except Exception as e:
            print(e.msg)
            result = False
        logger.close(result)
Beispiel #15
0
    def test_38_post_raw_tx(self):
        rawtxdata = self.m_signed_txhash_right
        action = "sendrawtransaction"
        version = ""

        logger.open("restful/38_post_raw_tx.log", "38_post_raw_tx")
        (result, response) = RestfulApi().postrawtx(rawtxdata, action, version)
        logger.close(result)
Beispiel #16
0
    def test_41_post_raw_tx(self):
        rawtxdata = ""
        action = "sendrawtransaction"
        version = "1.0.0"

        logger.open("restful/41_post_raw_tx.log", "41_post_raw_tx")
        (result, response) = RestfulApi().postrawtx(rawtxdata, action, version)
        logger.close(not result)
Beispiel #17
0
    def test_40_post_raw_tx(self):
        rawtxdata = self.m_signed_txhash_wrong
        action = "sendrawtransaction"
        version = "1.0.0"

        logger.open("restful/40_post_raw_tx.log", "40_post_raw_tx")
        (result, response) = RestfulApi().postrawtx(rawtxdata, action, version)
        logger.close(not result)
Beispiel #18
0
	def setUp(self):
		logger.open("test_restful/" + self._testMethodName+".log",self._testMethodName)
		if self._testMethodName == "test_init":
			return

		API.node().stop_all_nodes()
		API.node().start_nodes([0, 1, 2, 3, 4, 5, 6], Config.DEFAULT_NODE_ARGS, True, True)
		time.sleep(10)
Beispiel #19
0
    def test_main(self):
        result = False
        logger.open("TestGover2.log", "TestGover2")
        try:
            if (not pause(
                    "ensure that node A is not in the nodes network and node B is in the nodes network and node A has more than 10000 ont."
            )):
                raise Error("pre-condition unsatisfied")

            (wallet_A_address, wallet_B_address, vote_price,
             node_B_puiblic_key, blocks_per_round,
             punish_ratio) = get_config()
            block_count = getblockcount()
            # to ensure that the following operations are in the same round
            '''
			while(True):
				if getblockcount() % blocks_per_round <= 2:
					time.sleep(5)
					continue
				else:
					break
			
			# step 1 wallet A vote for node B
			(result, response) = vote_for_peer(wallet_A_address, [node_B_puiblic_key], [vote_price])
			print (response)
			#if not result:
			#	raise Error("vote error")
			
			# step 2 wallet A unvote in the same round
			(result, response) = unvote_for_peer(wallet_A_address, [node_B_puiblic_key], [vote_price])
			#if not result:
			#	raise Error("vote error")
			
			# wait until the next two blocks
			print (getblockcount(), block_count)
			while(True):
				if getblockcount() - block_count == 0:
					print (getblockcount(), block_count)
					time.sleep(5)
				else:
					break

			# step 3 wallet A withdraw ont
			(result, response) = withdraw_ont(wallet_A_address, [node_B_puiblic_key], [vote_price])
			#if not result:
			#	raise Error("vote error")
			'''
            # this should be failed
            (result, response) = unvote_for_peer(wallet_A_address,
                                                 [node_B_puiblic_key], ["10"])
            (result, response) = withdraw_ont(wallet_A_address,
                                              [node_B_puiblic_key], ["10"])
            #if not result:
            #	raise Error("vote error")

        except Exception as e:
            print(e.msg)
        logger.close(result)
Beispiel #20
0
    def test_53_get_contract_state(self):
        (contractaddr_right,
         txhash_right) = deploy_contract_full("tasks/A.neo", "name", "desc", 0)

        script_hash = contractaddr_right
        logger.open("restful/53_get_contract_state.log",
                    "53_get_contract_state")
        (result, response) = RestfulApi().getcontract(script_hash)
        logger.close(not result)
Beispiel #21
0
    def test_onto_1(self):
        result = False
        logger.open("test_onto_1.log", "test_onto_1")
        try:
            (result, response) = init_admin(self.CONTRACT_ADDRESS_CORRECT,
                                            self.ontID_A)

        except Exception as e:
            print(e.msg)
        logger.close(result)
Beispiel #22
0
    def test_gov_11(self):
        result = False
        logger.open("TestGover11.log", "TestGover11")
        try:
            (wallet_A_address, wallet_B_address, vote_price,
             node_B_puiblic_key, blocks_per_round,
             punish_ratio) = get_config()
            vote_price = "20000"
            # step 1 wallet A vote for node B
            (result, response) = vote_for_peer_index(wallet_A_address,
                                                     [node_B_puiblic_key],
                                                     [vote_price])
            print(response)
            #if not result:
            #	raise Error("vote_for_peer error")

            # step 2 wait until the second round
            invoke_function_consensus(Config.NODES[0]["pubkey"])
            time.sleep(5)
            (result, response) = quit_node_index(node_B_puiblic_key,
                                                 wallet_B_address, 7)

            # step 3 wallet A withdraw ont in the third round
            invoke_function_consensus(Config.NODES[0]["pubkey"])
            time.sleep(5)
            (result, response) = withdraw_ont_index(wallet_A_address,
                                                    [node_B_puiblic_key],
                                                    [vote_price])
            #if not result:
            #	raise Error("withdraw_ont error")

            (result, response) = unvote_for_peer_index(wallet_A_address,
                                                       [node_B_puiblic_key],
                                                       [vote_price])
            # step 3 wallet A withdraw ont in the fifth round
            invoke_function_consensus(Config.NODES[0]["pubkey"])
            time.sleep(5)
            invoke_function_consensus(Config.NODES[0]["pubkey"])
            time.sleep(5)

            (result, response) = withdraw_ont_index(wallet_A_address,
                                                    [node_B_puiblic_key],
                                                    [vote_price])
            #if not result:
            #	raise Error("withdraw_ont error")

            # this should be failed
            (result, response) = withdraw_ont(wallet_A_address,
                                              [node_B_puiblic_key], ["1"])
            #if not result:
            #	raise Error("withdraw_ont error")

        except Exception as e:
            print(e.msg)
        logger.close(result)
Beispiel #23
0
    def test_gov_14(self):
        result = False
        logger.open("TestGover14.log", "TestGover14")
        try:
            (wallet_A_address, wallet_B_address, vote_price,
             node_B_puiblic_key, blocks_per_round,
             punish_ratio) = get_config()
            invoke_function_update("updateGlobalParam", "2000000000", "10000",
                                   "32", "1", "50", "50", "50", "50")
            # step 1 wallet A vote for node B
            (result, response) = vote_for_peer_index(wallet_A_address,
                                                     [node_B_puiblic_key],
                                                     [vote_price])
            print(response)
            #if not result:
            #	raise Error("vote_for_peer error")

            # step 2 wait until the second round
            invoke_function_consensus(Config.NODES[0]["pubkey"])
            time.sleep(5)
            (result, response) = black_node([node_B_puiblic_key])

            # step 3 wallet A withdraw ont in the third round
            # should failed
            (result, response) = withdraw_ont_index(wallet_A_address,
                                                    [node_B_puiblic_key],
                                                    [vote_price])
            #if not result:
            #	raise Error("withdraw_ont error")

            (result, response) = unvote_for_peer_index(wallet_A_address,
                                                       [node_B_puiblic_key],
                                                       [vote_price])

            # step 4 wallet A withdraw ont in the forth round
            invoke_function_consensus(Config.NODES[0]["pubkey"])
            time.sleep(5)
            (result,
             response) = withdraw_ont_index(wallet_A_address,
                                            [node_B_puiblic_key],
                                            [str(int(punish_ratio * 3000))])
            #if not result:
            #	raise Error("withdraw_ont error")

            # this should be failed
            (result, response) = withdraw_ont_index(wallet_A_address,
                                                    [node_B_puiblic_key],
                                                    ["1"])
            #if not result:
            #	raise Error("withdraw_ont error")

        except Exception as e:
            print(e.msg)
        logger.close(result)
Beispiel #24
0
    def test_main(self):
        result = False
        logger.open("TestGover1.log", "TestGover1")
        try:
            if (not pause(
                    "ensure that node A is not in the nodes network and node B is in the nodes network and node A has more than 10000 ont."
            )):
                raise Error("pre-condition unsatisfied")

            (wallet_A_address, wallet_B_address, vote_price,
             node_B_puiblic_key, blocks_per_round,
             punish_ratio) = get_config()

            block_count = getblockcount()

            # step 1 before vote get balance of wallet A B
            balance_of_wallet_A_1 = getbalance_ont(wallet_A_address)
            balance_of_wallet_B_1 = getbalance_ont(wallet_B_address)
            print("A:", balance_of_wallet_A_1)
            print("B:", balance_of_wallet_B_1)

            # step 2 wallet A vote for node B
            (result, response) = vote_for_peer(wallet_A_address,
                                               [node_B_puiblic_key],
                                               [vote_price])
            #if not result:
            #	raise Error("vote error")

            # wait until the next two blocks
            while (True):
                if getblockcount() - block_count <= 1:
                    print(getblockcount(), block_count)
                    time.sleep(5)
                else:
                    break

            # step 3 after vote get balance of wallet A B
            balance_of_wallet_A_2 = getbalance_ont(wallet_A_address)
            balance_of_wallet_B_2 = getbalance_ont(wallet_B_address)
            print("2A:", balance_of_wallet_A_2)
            print("2B:", balance_of_wallet_B_2)

            # step 4 compare
            if balance_of_wallet_B_1 != balance_of_wallet_B_2:
                raise Error("balance of wallte B changed.")

            if balance_of_wallet_A_1 - balance_of_wallet_A_2 != int(
                    vote_price):
                raise Error("the decrease of balance of wallet A is not %s." %
                            vote_price)

        except Exception as e:
            print(e.msg)
        logger.close(result)
Beispiel #25
0
    def test_01_get_gen_blk_time(self):
        stop_all_nodes()
        start_nodes([0, 1, 2, 3, 4, 5, 6],
                    Config.DEFAULT_NODE_ARGS,
                    True,
                    True,
                    config="config-dbft-1.json")
        time.sleep(10)

        logger.open("restful/01_get_gen_blk_time.log", "01_get_gen_blk_time")
        (result, response) = RestfulApi().getgenerateblocktime()
        logger.close(result)
Beispiel #26
0
 def setUp(self):
     logger.open("test_consensus/" + self._testMethodName + ".log",
                 self._testMethodName)
     self.m_checknode = 4
     time.sleep(2)
     print("stop all")
     API.node().stop_all_nodes()
     print("start all")
     API.node().start_nodes([0, 1, 2, 3, 4, 5, 6], Config.DEFAULT_NODE_ARGS,
                            True, True)
     for i in range(0, 7):
         API.native().regid_with_publickey(i)
     API.native().init_ont_ong()
Beispiel #27
0
    def test_main(self):
        result = False
        logger.open("TestGover12.log", "TestGover12")
        try:
            if (not pause(
                    "ensure that node A and node B is in the nodes network and node A has more than 10000 ont."
            )):
                raise Error("pre-condition unsatisfied")

            (wallet_A_address, wallet_B_address, vote_price,
             node_B_puiblic_key, blocks_per_round,
             punish_ratio) = get_config()
            '''
			# to ensure that the following operations are in the same round			
			while(True):
				if getblockcount() % blocks_per_round <= 2:
					time.sleep(1)
					continue
				else:
					break
			'''
            # step 1 wallet A vote for node B
            (result, response) = vote_for_peer(wallet_A_address,
                                               [node_B_puiblic_key],
                                               [vote_price])
            print(response)
            #if not result:
            #	raise Error("vote error")

            # step 2 black node b
            if (not pause("black node over?")):
                pass
            #if not result:
            #	raise Error("black_node error")

            # step 3 withdraw ont
            (result, response) = withdraw_ont(wallet_A_address,
                                              [node_B_puiblic_key],
                                              [vote_price])
            #if not result:
            #	raise Error("withdraw_ont error")

            # this should be failed
            (result, response) = withdraw_ont(wallet_A_address,
                                              [node_B_puiblic_key], ["1"])
            #if not result:
            #	raise Error("withdraw_ont error")

        except Exception as e:
            print(e.msg)
        logger.close(result)
Beispiel #28
0
	def setUp(self):
		logger.open("test_governance/" + self._testMethodName + ".log",self._testMethodName)
		# return
		time.sleep(2)
		print("stop all")
		API.node().stop_all_nodes()
		print("start all")
		API.node().start_nodes([0,1,2,3,4,5,6,7,8], Config.DEFAULT_NODE_ARGS, True, True)

		for i in range(9):
			API.native().regid_with_publickey(i, sleep=0)
		
		API.native().init_ont_ong()
				
		API.native().transfer_ont(Config.NODES[0]["address"], Config.NODES[7]["address"], "1000000", 0)
		API.native().transfer_ong(Config.NODES[0]["address"], Config.NODES[7]["address"], "1000000000000", 0)
		API.native().transfer_ont(Config.NODES[0]["address"], Config.NODES[8]["address"], "1000000", 0)
		API.native().transfer_ong(Config.NODES[0]["address"], Config.NODES[8]["address"], "1000000000000", 0)
		try:
			# create role and bind ONTID with role
			(process, response) = API.native().bind_role_function("0700000000000000000000000000000000000000", ByteToHex(bytes(Config.NODES[0]["ontid"], encoding = "utf8")), ByteToHex(b"roleA"),["registerCandidate"], sleep=1)
			if not process:
				raise Error("bind_role_function error")

			(process, response) = API.native().bind_user_role("0700000000000000000000000000000000000000",ByteToHex(bytes(Config.NODES[0]["ontid"], encoding = "utf8")), ByteToHex(b"roleA"),[ByteToHex(bytes(Config.NODES[7]["ontid"], encoding = "utf8"))], sleep=1)
			if not process:
				raise Error("bind_user_role error")

			(process, response) = API.native().bind_user_role("0700000000000000000000000000000000000000",ByteToHex(bytes(Config.NODES[0]["ontid"], encoding = "utf8")), ByteToHex(b"roleA"),[ByteToHex(bytes(Config.NODES[8]["ontid"], encoding = "utf8"))], sleep=1)
			if not process:
				raise Error("bind_user_role error")

			(process, response) = API.native().register_candidate(Config.NODES[7]["pubkey"], Config.NODES[7]["address"] ,"10000", ByteToHex(bytes(Config.NODES[7]["ontid"], encoding = "utf8")), "1", 7, sleep=1)
			if not process:
				raise Error("register_candidate error")
			
			(process, response) = API.native().approve_candidate(Config.NODES[7]["pubkey"], sleep=1)
			if not process:
				raise Error("approve_candidate error")

			(process, response) = API.native().register_candidate(Config.NODES[8]["pubkey"], Config.NODES[8]["address"] ,"10000", ByteToHex(bytes(Config.NODES[8]["ontid"], encoding = "utf8")), "1", 8, sleep=1)
			if not process:
				raise Error("register_candidate error")
			
			(process, response) = API.native().approve_candidate(Config.NODES[8]["pubkey"], sleep=1)
			if not process:
				raise Error("invoke_function_aapprove_candidatepprove error")
				
			API.node().wait_gen_block()
		except Exception as e:
			logger.print(e.args[0])
Beispiel #29
0
 def test_75_no_url(self):
     request = {
         "TYPE": "restful",
         "REQUEST": {
             "api": ""
         },
         "RESPONSE": {
             "Error": 0,
         }
     }
     task = Task(name="75_no_url", ijson=request)
     logger.open("restful/75_no_url.log", "75_no_url")
     (result, response) = run_single_task(task)
     logger.close(not result)
Beispiel #30
0
 def test_74_get_conn_count1(self):
     request = {
         "TYPE": "restful",
         "REQUEST": {
             "api": "/api/v1/get_conn_count1"
         },
         "RESPONSE": {
             "Error": 0,
         }
     }
     task = Task(name="74_get_conn_count1", ijson=request)
     logger.open("restful/74_get_conn_count1.log", "74_get_conn_count1")
     (result, response) = run_single_task(task)
     logger.close(not result)