def test_connect_test_str_list2(self): str_list = "" for node in self.nodes: str_list += node + "," str_list = str_list[:-1] rpc = HiveNodeRPC(urls=str_list) self.assertIn(rpc.url, self.nodes + self.nodes_hiveit) rpc.next() self.assertIn(rpc.url, self.nodes + self.nodes_hiveit)
def test_num_retries(self): with self.assertRaises(NumRetriesReached): HiveNodeRPC(urls="https://wrong.link.com", num_retries=2, timeout=1) with self.assertRaises(NumRetriesReached): HiveNodeRPC(urls="https://wrong.link.com", num_retries=3, num_retries_call=3, timeout=1) nodes = [ "https://httpstat.us/500", "https://httpstat.us/501", "https://httpstat.us/502", "https://httpstat.us/503", "https://httpstat.us/505", "https://httpstat.us/511", "https://httpstat.us/520", "https://httpstat.us/522", "https://httpstat.us/524" ] with self.assertRaises(NumRetriesReached): HiveNodeRPC(urls=nodes, num_retries=0, num_retries_call=0, timeout=1)
def test_error_handling_appbase(self): rpc = HiveNodeRPC(urls=self.nodes_hiveit, num_retries=2, num_retries_call=3) with self.assertRaises(exceptions.NoMethodWithName): rpc.get_wrong_command() with self.assertRaises(exceptions.NoApiWithName): rpc.get_block({"block_num": 1}, api="wrong_api")
def test_error_handling(self): rpc = HiveNodeRPC(urls=self.nodes_hiveit, num_retries=2, num_retries_call=3) with self.assertRaises(exceptions.NoMethodWithName): rpc.get_wrong_command() with self.assertRaises(exceptions.UnhandledRPCError): rpc.get_accounts("test")
def setUpClass(cls): nodelist = NodeList() nodelist.update_nodes(hive_instance=Hive( node=nodelist.get_nodes(normal=True, appbase=True), num_retries=3)) cls.nodes = nodelist.get_nodes() if "https://api.hive.blog" in cls.nodes: cls.nodes.remove("https://api.hive.blog") cls.nodes_hiveit = ["https://api.hive.blog"] cls.appbase = Hive(node=cls.nodes, nobroadcast=True, keys={ "active": wif, "owner": wif, "memo": wif }, num_retries=10) cls.rpc = HiveNodeRPC(urls=cls.nodes_hiveit) # from getpass import getpass # self.bts.wallet.unlock(getpass()) set_shared_hive_instance(cls.nodes_hiveit) cls.appbase.set_default_account("test")