'Test whether the order book of two nodes are being synchronized'

@blocking_call_on_reactor_thread
@inlineCallbacks
def test_orderbook_sync(self):

    def check_orderbook_size():
        if ((len(ask_community.order_book.bids) == 1) and (len(bid_community.order_book.asks) == 1)):
            check_lc.stop()
            test_deferred.callback(None)
    test_deferred = Deferred()
    bid_session = (yield self.create_session(1))
    ask_community = self.market_communities[self.session]
    bid_community = self.market_communities[bid_session]
    ask_community.create_ask(10, 'DUM1', 2, 'DUM2', 3600)
    bid_community.create_bid(1, 'DUM1', 2, 'DUM2', 3600)
    ask_community.add_discovered_candidate(Candidate(bid_session.get_dispersy_instance().lan_address, tunnel=False))
    check_lc = LoopingCall(check_orderbook_size)
    check_lc.start(0.2)
    (yield test_deferred)
