Implement mocks on generic tx, block

This commit is contained in:
lash 2022-05-09 19:25:31 +00:00
parent e264ed5c37
commit dd1879bb91
Signed by: lash
GPG Key ID: 21D2E7BB88C2A746
2 changed files with 13 additions and 5 deletions

View File

@ -115,7 +115,7 @@ class StateFilter(SyncFilter):
queue_adapter = self.__get_adapter(block, force_reload=True)
continue
logg.info('filter registered {} for {} in {}'.format(tx.status.name, tx.hash, block))
logg.info('filter registered {} for {} in {}'.format(tx.status_name, tx.hash, block))
if self.throttler != None:
self.throttler.dec(tx.hash)

View File

@ -7,6 +7,11 @@ from chainqueue.cache import CacheTokenTx
from chainlib.status import Status as TxStatus
from chainlib.chain import ChainSpec
from chainlib.error import RPCException
from chainlib.tx import (
Tx,
TxResult,
)
from chainlib.block import Block
class MockCacheAdapter(CacheTokenTx):
@ -34,14 +39,17 @@ class MockDispatcher:
pass
class MockTx:
class MockTx(Tx):
def __init__(self, tx_hash, status=TxStatus.SUCCESS):
self.hash = tx_hash
self.status = status
result = TxResult()
result.status = status
super(MockTx, self).__init__(result=result)
self.set_hash(tx_hash)
class MockBlock:
class MockBlock(Block):
def __init__(self, number):
super(MockBlock, self).__init__()
self.number = number