示例#1
0
	def test_base_001_gover(self):
		process = False

		try:

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

			# step 1 before vote get balance of wallet A B
			print("*******", API.rpc().getbalance(wallet_A_address))
			balance_of_wallet_A_1 = int(API.rpc().getbalance(wallet_A_address)[1]["result"]["ont"]) 
			balance_of_wallet_B_1 = int(API.rpc().getbalance(wallet_B_address)[1]["result"]["ont"]) 

			# step 2 wallet A vote for node B
			(process, response) = API.native().vote_for_peer(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(process, "vote_for_peer error")

			API.node().wait_gen_block()

			# step 3 after vote get balance of wallet A B
			balance_of_wallet_A_2 = int(API.rpc().getbalance(wallet_A_address)[1]["result"]["ont"]) 
			balance_of_wallet_B_2 = int(API.rpc().getbalance(wallet_B_address)[1]["result"]["ont"]) 

			# step 4 compare
			self.ASSERT(balance_of_wallet_B_1 == balance_of_wallet_B_2, "balance of wallte B changed.")

			self.ASSERT(balance_of_wallet_A_1 - balance_of_wallet_A_2 == int(vote_price), "the decrease of balance of wallet A is not %s." % vote_price)

		except Exception as e:
			logger.print(e.args[0])
示例#2
0
	def test_normal_014_gover(self):
		process = False
		try:
			(wallet_A_address, wallet_B_address, vote_price, node_B_puiblic_key, blocks_per_round, punish_ratio) = test_api.get_config()
			vote_price = "20000"

			API.native().update_global_param("2000000000","10000","32","10","50","50","50","50")
			API.node().wait_gen_block()

			# step 1 wallet A vote for node B
			(process, response) = API.native().vote_for_peer(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(process, "vote_for_peer error")
			API.node().wait_gen_block()
			
			# step 2 wait until the second round
			API.native().commit_dpos()
			time.sleep(10)

			(process, response) = API.native().black_node([node_B_puiblic_key])
			self.ASSERT(process, "black_node error")
			API.node().wait_gen_block()

			# step 3 wallet A withdraw ont in the third round
			# should failed
			(process, response) = API.native().withdraw_ont(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(not process, "withdraw_ont1 error")

			# step 4 wallet A withdraw ont in the forth round
			API.native().commit_dpos()
			time.sleep(10)

			API.native().commit_dpos()
			time.sleep(10)

			API.native().commit_dpos()
			time.sleep(10)

			(process, response) = API.native().withdraw_ont(wallet_A_address, [node_B_puiblic_key], [str(int(punish_ratio*int(vote_price)))], 8)
			self.ASSERT(process, "withdraw_ont2 error")

			# this should be failed
			(process, response) = API.native().withdraw_ont(wallet_A_address, [node_B_puiblic_key], ["1"], 8)
			self.ASSERT(not process, "withdraw_ont3 error")


		except Exception as e:
			logger.print(e.args[0])
示例#3
0
	def test_normal_010_gover(self):
		process = False
		try:
			(wallet_A_address, wallet_B_address, vote_price, node_B_puiblic_key, blocks_per_round, punish_ratio) = test_api.get_config()
			
			# step 1 wallet A vote for node B
			(process, response) = API.native().vote_for_peer(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(process, "vote_for_peer error")
			API.node().wait_gen_block()
			time.sleep(5)

			# step 2 wait until the second round
			API.native().commit_dpos()
			time.sleep(5)

			(process, response) = API.native().quit_node(node_B_puiblic_key, wallet_B_address, 7)
			self.ASSERT(process, "quit_node error")
			API.node().wait_gen_block()
			time.sleep(5)
			
			# step 3 wallet A withdraw ont in the third round
			API.native().commit_dpos()
			time.sleep(5)
			
			(process, response) = API.native().withdraw_ont(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(not process, "withdraw_ont1 error")
			API.node().wait_gen_block()
			time.sleep(5)

			# step 3 wallet A withdraw ont in the forth round
			API.native().commit_dpos()
			time.sleep(5)
			
			(process, response) = API.native().withdraw_ont(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(process, "withdraw_ont2 error")

			(process, response) = API.native().withdraw_ont(wallet_A_address, [node_B_puiblic_key], ["1"], 8)
			self.ASSERT(not process, "withdraw_ont3 error")
			
		except Exception as e:
			logger.print(e.args[0])
示例#4
0
	def test_normal_008_gover(self):
		process = False

		try:
			(wallet_A_address, wallet_B_address, vote_price, node_B_puiblic_key, blocks_per_round, punish_ratio) = test_api.get_config()
			vote_price = "20000"

			API.rpc().getbalance(wallet_A_address)
			
			# step 1 wallet A vote for node B
			(process, response) = API.native().vote_for_peer(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(process, "vote_for_peer error")
			API.node().wait_gen_block()
			time.sleep(15)
			test_api.nodeCountCheck(response, 9)

			API.rpc().getbalance(wallet_A_address)

			# step 2 wallet A unvote in the second round
			API.native().commit_dpos()
			time.sleep(15)

			(process, response) = API.native().unvote_for_peer(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(process, "unvote_for_peer error")
			API.node().wait_gen_block()
			time.sleep(15)
			test_api.nodeCountCheck(response, 9)

			# step 3 wallet A withdraw ont in the third round
			API.native().commit_dpos()
			time.sleep(15)
			
			(process, response) = API.native().withdraw_ont(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(not process, "withdraw_ont1 error")
			API.node().wait_gen_block()
			test_api.nodeCountCheck(response, 9)

			API.rpc().getbalance(wallet_A_address)

			API.native().commit_dpos()
			time.sleep(5)

			API.native().commit_dpos()
			time.sleep(5)

			(process, response) = API.native().withdraw_ont(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(process, "withdraw_ont2 error")

			# this should be failed
			(process, response) = API.native().withdraw_ont(wallet_A_address, [node_B_puiblic_key], ["1"], 8)
			self.ASSERT(not process, "withdraw_ont3 error")

		except Exception as e:
			logger.print(e.args[0])
示例#5
0
	def test_normal_006_gover(self):
		process = False
		try:
			(wallet_A_address, wallet_B_address, vote_price, node_B_puiblic_key, blocks_per_round, punish_ratio) = test_api.get_config()
			# step 1 wallet A vote for node B
			(process, response) = API.native().vote_for_peer(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(process, "vote_for_peer error")

			# step 2 wallet A unvote in the same round
			(process, response) = API.native().unvote_for_peer(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(process, "unvote_for_peer error")

			# step 3 wallet A withdraw ont
			(process, response) = API.native().withdraw_ont(wallet_A_address, [node_B_puiblic_key], [vote_price], 8)
			self.ASSERT(process, "withdraw_ont error")
			
			# this should be failed
			(process, response) = API.native().withdraw_ont(wallet_A_address, [node_B_puiblic_key], ["1"])
			self.ASSERT(not process, "withdraw_ont error")

		except Exception as e:
			logger.print(e.args[0])
示例#6
0
	def test_normal_017_gover(self):
		process = False
		try:
			(wallet_A_address, wallet_B_address, vote_price, node_B_puiblic_key, blocks_per_round, punish_ratio) = test_api.get_config()		
			
			API.native().update_global_param("2000000000","10000","32","10","50","50","50","50")
			API.node().wait_gen_block()
			
			# step 1 wallet A vote for node B
			(process, response) = API.native().vote_for_peer(Config.NODES[8]["address"], [node_B_puiblic_key], ["90000"], 8)
			self.ASSERT(process, "vote_for_peer1 error")
			
			(process, response) = API.native().unvote_for_peer(Config.NODES[8]["address"], [node_B_puiblic_key], ["10000"], 8)
			self.ASSERT(process, "unvote_for_peer error")

			API.native().commit_dpos()
			API.node().wait_gen_block()
			time.sleep(10)
			
			(process, response) = API.native().vote_for_peer(wallet_A_address, [node_B_puiblic_key], ["10001"], 8)
			self.ASSERT(process, "vote_for_peer2 error")

			API.native().commit_dpos()
			API.node().wait_gen_block()
			time.sleep(10)
			API.native().commit_dpos()
			API.node().wait_gen_block()
			time.sleep(10)

			(process, response) = API.native().withdraw_ont(Config.NODES[8]["address"], [node_B_puiblic_key], ["10000"], 8)
			self.ASSERT(process, "withdraw_ont error")
			
			(process, response) = API.native().vote_for_peer(wallet_A_address, [node_B_puiblic_key], ["1000"], 8)
			self.ASSERT(process, "vote_for_peer3 error")
			
		except Exception as e:
			logger.print(e.args[0])
示例#7
0
	def test_abnormal_016_gover(self):
		process = False

		try:
			(wallet_A_address, wallet_B_address, vote_price, node_B_puiblic_key, blocks_per_round, punish_ratio) = test_api.get_config()		

			API.native().update_global_param("2000000000","10000","32","10","50","50","50","50")

			time.sleep(15)

			# step 1 wallet A vote for node B
			(process, response) = API.native().vote_for_peer(Config.NODES[8]["address"], [node_B_puiblic_key], ["90000"], 8)
			self.ASSERT(process, "vote_for_peer error")

			# step 1 wallet A vote for node B
			(process, response) = API.native().vote_for_peer(wallet_A_address, [node_B_puiblic_key], ["10001"])
			self.ASSERT(not process, "vote_for_peer error")

		except Exception as e:
			logger.print(e.args[0])