def METHOD_NAME(harness, referenceContacts, referenceContactIds, contactsCountAfterClear):
    try:
        contactsCountAfterRestore = GetContactsCount().run(harness).count
        log.debug(f"Contacts after restore: {contactsCountAfterRestore}")
        assert (len(referenceContacts) + contactsCountAfterClear) == contactsCountAfterRestore
        log.debug("Get user data from device for comparison")
        resp = GetContactsWithOffsetAndLimit(0, contactsCountAfterRestore).run(harness)
        for e in resp.entries:
            id = e["id"]
            log.debug(f"Compare contact id: {id}")
            assert referenceContacts[id] == e
            assert id in referenceContactIds
    except TransactionError:
        return False
    else:
        return True