def BLOCK(self, result, info=""): if not result: self.m_result = "block" raise Error(info)
def test_main(self): result = False logger.open("TestGover13.log", "TestGover13") 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 ''' 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_for_peer error") # step 2 wait until the second round while(True): if (getblockcount() / blocks_per_round - consensus_rounds == 1): (result, response) = black_node([node_B_puiblic_key]) #if not result: # raise Error("black_node error") break else: print(getblockcount()) time.sleep(5) continue # step 3 wallet A withdraw ont in the third round while(True): if (getblockcount() / blocks_per_round - consensus_rounds == 2): # should failed (result, response) = withdraw_ont(wallet_A_address, [node_B_puiblic_key], [vote_price]) break else: print(getblockcount()) time.sleep(5) continue #if not result: # raise Error("withdraw_ont error") # step 4 wallet A withdraw ont in the forth round while(True): if (getblockcount() / blocks_per_round - consensus_rounds == 3): (result, response) = withdraw_ont(wallet_A_address, [node_B_puiblic_key], [str(int(punish_ratio*3000))]) break else: print(getblockcount()) 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)
def ASSERT(self, result, info=""): self.m_assertcount = self.m_assertcount + 1 if not result: self.m_result = "fail" raise Error(info)