Пример #1
0
 def test_get_block_info_nonexistent_id(self, node: str, client: HttpRequest):
     client.host = node
     for id in [-1, 0, random.randint(10**6, 10**9)]:
         req = Request(params=["database_api", "get_block", [id]])
         resp = client.send_post_request(payload=req, resp_type=BlockResponse)
         assert not resp.id
         assert not resp.result
Пример #2
0
 def test_check_blocks_generation_with_interval(self, node: str, client: HttpRequest):
     client.host = node
     req = Request(params=["database_api", "get_dynamic_global_properties", []])
     resp = client.send_post_request(payload=req, resp_type=DynamicGlobalPropertiesResponse)
     block_number = resp.result.head_block_number
     while True:
         resp = client.send_post_request(payload=req, resp_type=DynamicGlobalPropertiesResponse)
         if resp.result.head_block_number != block_number:
             block_number = resp.result.head_block_number
             block_time = resp.result.time
             break
     start = time.time()
     for _ in range(5):
         resp = client.send_post_request(payload=req, resp_type=DynamicGlobalPropertiesResponse)
         if (time.time() - start) < BLOCKS_PRODUCTION_INTERVAL:
             assert resp.result.head_block_number == block_number
             assert resp.result.time == block_time
         else:
             block_number += 1
             assert resp.result.head_block_number == block_number
             block_time = datetime.strptime(block_time, BASE_FORMAT) + timedelta(
                 seconds=BLOCKS_PRODUCTION_INTERVAL)
             block_time = block_time.strftime(BASE_FORMAT)
             assert resp.result.time == block_time
             start = time.time()
         time.sleep(1)
Пример #3
0
 def test_get_next_blocks_info(self, node: str, client: HttpRequest):
     client.host = node
     timestamp = datetime.strptime(FIRST_BLOCK_TIMESTAMP, BASE_FORMAT)
     block_id = None
     for idx in range(2, 12):
         timestamp += timedelta(seconds=BLOCKS_PRODUCTION_INTERVAL)
         req = Request(params=["database_api", "get_block", [idx]])
         resp = client.send_post_request(payload=req, resp_type=BlockResponse)
         assert resp.result.timestamp == timestamp.strftime(BASE_FORMAT)
         if block_id:
             assert resp.result.previous == block_id
         block_id = resp.result.block_id
Пример #4
0
 def test_get_block_info_no_id(self, node: str, client: HttpRequest):
     client.host = node
     req = Request(params=["database_api", "get_block", []])
     client.send_post_request(payload=req, expected_code=StatusCode.BAD_REQUEST)
Пример #5
0
 def test_get_first_block_info(self, node: str, client: HttpRequest):
     client.host = node
     req = Request(params=["database_api", "get_block", [1]])
     resp = client.send_post_request(payload=req, resp_type=BlockResponse)
     assert resp.result.timestamp == FIRST_BLOCK_TIMESTAMP
     assert not int(resp.result.previous)
Пример #6
0
 def client(self, logger):
     return HttpRequest(scheme=get_config()['scheme'], logger=logger)
Пример #7
0
 def test_request_no_params(self, node: str, client: HttpRequest):
     client.host = node
     req = Request(params=[])
     client.send_post_request(payload=req, expected_code=StatusCode.BAD_REQUEST)