Use mock conn and process method from headsyncer in testsyncer

This commit is contained in:
nolash
2021-04-15 15:27:19 +02:00
parent 987a18fd6b
commit 6201420ad2
3 changed files with 22 additions and 17 deletions

View File

@@ -12,6 +12,13 @@ from chainsyncer.error import NoBlockForYou
logg = logging.getLogger().getChild(__name__)
class MockConn:
def do(self, o):
pass
class MockTx:
def __init__(self, index, tx_hash):
@@ -19,6 +26,10 @@ class MockTx:
self.index = index
def apply_receipt(self, rcpt):
self.rcpt = rcpt
class MockBlock:
def __init__(self, number, txs):
@@ -54,13 +65,3 @@ class TestSyncer(HistorySyncer):
block_txs.append(add_0x(os.urandom(32).hex()))
return MockBlock(block_height, block_txs)
# TODO: implement mock conn instead, and use HeadSyncer.process
def process(self, conn, block):
i = 0
for tx in block.txs:
self.process_single(conn, block, block.tx(i))
self.backend.reset_filter()
i += 1
self.backend.set(block.number + 1, 0)