def test_receive_newblock(): app = AppMock() eth = eth_service.ChainService(app) proto = eth_protocol.ETHProtocol(PeerMock(app), eth) d = eth_protocol.ETHProtocol.newblock.decode_payload( newblk_rlp.decode('hex')) eth.on_receive_newblock(proto, **d)
def receive_blocks(rlp_data, leveldb=False, codernitydb=False): app = AppMock() if leveldb: app.db = leveldb_service.LevelDB(app) if codernitydb: app.db = codernitydb_service.CodernityDB(app) eth = eth_service.ChainService(app) proto = eth_protocol.ETHProtocol(PeerMock(app), eth) b = eth_protocol.ETHProtocol.blocks.decode_payload(rlp_data) eth.on_receive_blocks(proto, b)
def receive_blockheaders(rlp_data, leveldb=False, codernitydb=False): app = AppMock() if leveldb: app.db = leveldb_service.LevelDB( os.path.join(app.config['app']['dir'], app.config['db']['path'])) # if codernitydb: # app.db = codernitydb_service.CodernityDB( # os.path.join(app.config['app']['dir'], app.config['db']['path'])) eth = eth_service.ChainService(app) proto = eth_protocol.ETHProtocol(PeerMock(app), eth) b = eth_protocol.ETHProtocol.blockheaders.decode_payload(rlp_data) eth.on_receive_blockheaders(proto, b)