def test_block_bodies_request_valid_with_full_response(): headers_bundle = mk_headers((2, 3), (8, 4), (0, 1), (0, 0)) headers, bodies, transactions_roots, trie_data_dicts, uncles_hashes = zip( *headers_bundle) transactions_bundles = tuple(zip(transactions_roots, trie_data_dicts)) bodies_bundle = tuple(zip(bodies, transactions_bundles, uncles_hashes)) request = BlockBodiesRequest(headers) request.validate_response(bodies, bodies_bundle)
def test_block_bodies_request_with_fully_invalid_response(): headers_bundle = mk_headers((2, 3), (8, 4), (0, 1), (0, 0)) headers, _, _, _, _ = zip(*headers_bundle) wrong_headers_bundle = mk_headers((3, 2), (4, 8), (1, 0), (0, 0)) w_headers, w_bodies, w_transactions_roots, w_trie_data_dicts, w_uncles_hashes = zip( *wrong_headers_bundle) w_transactions_bundles = tuple(zip(w_transactions_roots, w_trie_data_dicts)) w_bodies_bundle = tuple( zip(w_bodies, w_transactions_bundles, w_uncles_hashes)) request = BlockBodiesRequest(headers) with pytest.raises(ValidationError): request.validate_response(w_bodies, w_bodies_bundle)
def test_block_bodies_request_empty_response_is_valid(): headers_bundle = mk_headers((2, 3), (8, 4), (0, 1), (0, 0)) headers, _, _, _, _ = zip(*headers_bundle) request = BlockBodiesRequest(headers) request.validate_response(tuple(), tuple())