forked from ethereum/py-evm
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement round trip awaitable API for retrieving block headers
- Loading branch information
1 parent
ab94167
commit 5f6bb64
Showing
4 changed files
with
108 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
tests/p2p/test_peer_block_header_request_and_response_api.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import asyncio | ||
|
||
import pytest | ||
|
||
from eth.rlp.headers import BlockHeader | ||
|
||
from p2p.peer import ETHPeer | ||
from peer_helpers import ( | ||
get_directly_linked_peers, | ||
) | ||
|
||
|
||
@pytest.mark.asyncio | ||
async def test_eth_peer_get_headers(request, event_loop): | ||
peer, remote = await get_directly_linked_peers(request, event_loop, peer1_class=ETHPeer, peer2_class=ETHPeer) | ||
header = BlockHeader(difficulty=100, block_number=0, gas_limit=3000000) | ||
|
||
async def send_headers(): | ||
remote.sub_proto.send_block_headers((header,)) | ||
await asyncio.sleep(0) | ||
|
||
asyncio.ensure_future(send_headers()) | ||
response = await peer.get_block_headers(0, 1, 0, False) | ||
|
||
assert len(response) == 1 | ||
assert response[0] == header |