fix on header
This commit is contained in:
parent
b01db15b77
commit
d0314ac70c
1 changed files with 12 additions and 14 deletions
|
@ -246,6 +246,7 @@ class IntegrationTestCase(AsyncioTestCase):
|
||||||
self.ledger: Optional[Ledger] = None
|
self.ledger: Optional[Ledger] = None
|
||||||
self.wallet: Optional[Wallet] = None
|
self.wallet: Optional[Wallet] = None
|
||||||
self.account: Optional[Account] = None
|
self.account: Optional[Account] = None
|
||||||
|
self.log = logging.getLogger(__name__).getChild(self.__class__.__name__)
|
||||||
|
|
||||||
async def asyncSetUp(self):
|
async def asyncSetUp(self):
|
||||||
self.conductor = Conductor(seed=self.SEED)
|
self.conductor = Conductor(seed=self.SEED)
|
||||||
|
@ -284,20 +285,17 @@ class IntegrationTestCase(AsyncioTestCase):
|
||||||
|
|
||||||
async def on_header(self, height):
|
async def on_header(self, height):
|
||||||
if self.ledger.config.get('use_go_hub'):
|
if self.ledger.config.get('use_go_hub'):
|
||||||
# If client isn't connected yet (which happens in some test for some reason?)
|
server = self.conductor.spv_node.server
|
||||||
# just default to localhost
|
while True:
|
||||||
host = self.ledger.network.client.server[0] if self.ledger.network.client else "127.0.0.1"
|
# self.log.warning('server.db.db_height: %s, self.ledger.headers.height: %s', server.db.db_height, self.ledger.headers.height)
|
||||||
port = "50051"
|
if server.db.db_height >= height and \
|
||||||
server = f"{host}:{port}"
|
server._go_hub_height == server.db.db_height == server._es_height:
|
||||||
async with grpc.aio.insecure_channel(server) as channel:
|
|
||||||
stub = hub_pb2_grpc.HubStub(channel)
|
|
||||||
try:
|
|
||||||
async for res in stub.HeightSubscribe(hub_pb2.UInt32Value(value=height)):
|
|
||||||
if res.value < height:
|
|
||||||
print(f"??? {res.value} < {height}")
|
|
||||||
return True
|
return True
|
||||||
except grpc.aio.AioRpcError as error:
|
# self.log.warning('Waiting for header %s', height)
|
||||||
raise RPCError(error.code(), error.details())
|
await server.synchronized.wait()
|
||||||
|
server.es_synchronized.clear()
|
||||||
|
server.go_hub_synchronized.clear()
|
||||||
|
server.synchronized.clear()
|
||||||
if self.ledger.headers.height < height:
|
if self.ledger.headers.height < height:
|
||||||
await self.ledger.on_header.where(
|
await self.ledger.on_header.where(
|
||||||
lambda e: e.height == height
|
lambda e: e.height == height
|
||||||
|
|
Loading…
Add table
Reference in a new issue