def tearDown(self): try: self.remote_ctrl.delete_account(Alice.name, Alice.password, Alice.lastword()) ec, message = mvs_rpc.add_node(self.remote_ip + ':5251') self.assertEqual(ec, 0, message) except: print 'unable to connect remote url:' + self.remote_ip MVSTestCaseBase.tearDown(self)
def fork_test( ): origin = "origin" popback = "popback" # backup check point _, (height, _) = mvs_rpc.get_info() data_base_script(origin) # run testcase run_testcase() # make this node partion with the others peers = mvs_rpc.getpeerinfo()[1] for peer in peers: mvs_rpc.ban_node(peer) try: # popblock ec, _ = mvs_rpc.pop_block(height + 1) assert (ec == 0) assert( mvs_rpc.get_info()[1][0] == height) # check database data_base_script(popback) finally: for peer in peers: mvs_rpc.add_node(peer) # check origin and popback f_origin = open('./tools/%s/result.txt' % origin) f_popback= open('./tools/%s/result.txt' % popback) while True: line1 = f_origin.readline() line2 = f_popback.readline() assert (line1 == line2) if not (line1 or line2): break f_origin.close() f_popback.close() print "fork test passed!"
def fork(self): try: ming_round = 6 expect_hight = self.remote_ming(ming_round) ec, message = mvs_rpc.add_node(self.remote_ip + ':5251') self.assertEqual(ec, 0, message) import time new_height = 0 # wait until the fork complete timeout = 300 while new_height < expect_hight: # self.partion_height + ming_round: time.sleep(1) ec, message = mvs_rpc.get_info() self.assertEqual(ec, 0, message) new_height = message[0] timeout -= 1 self.assertGreater(timeout, 0, "wait fork timeout error!") except: print 'unable to connect remote url:' + self.remote_ip