Skip to content

Commit

Permalink
Add sanity metadata test
Browse files Browse the repository at this point in the history
  • Loading branch information
lsankar4033 committed Aug 18, 2020
1 parent 1ed2d02 commit a41983b
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 39 deletions.
36 changes: 0 additions & 36 deletions old_tests/reqresp/metadata.py

This file was deleted.

32 changes: 32 additions & 0 deletions tests/reqresp/metadata.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from eth2spec.utils.ssz.ssz_typing import uint64, Bitvector, Container
from sclients import connect_rumor

from ..utils import parse_chunk_response, with_rumor

class Metadata(Container):
seq_number: uint64
attnets: Bitvector[64]


@with_rumor
async def run(rumor, args):
peer_id = await connect_rumor(rumor, args['client'], args['enr'])

logs = []
return_code = 0

req_call = rumor.rpc.metadata.req.raw(peer_id, '', raw=True, compression='snappy')
await req_call
await req_call.next()
resp = await req_call.next()

(resp_data, l) = parse_chunk_response(resp)
logs.extend(l)
if resp_data is None:
return_code = 1

else:
# TODO: sanity checks on metadata
metadata = Metadata.decode_bytes(bytes.fromhex(resp_data))

return (return_code, logs)
3 changes: 0 additions & 3 deletions tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ async def wrapped_run_fn(args):
return wrapped_run_fn

def parse_chunk_response(resp):
if not(resp['result_code'] == 0):
return (None, [f"request error: {resp['msg']}"])

if 'data' not in resp:
return (None, [f"request error: 'data' field not in response"])

Expand Down

0 comments on commit a41983b

Please sign in to comment.