def _check_orphans_no_tips(cursor):
 orphans_with_tips = cursor.all('\n        WITH valid_tips AS (SELECT * FROM current_tips WHERE amount > 0)\n        SELECT username\n          FROM (SELECT tipper AS username FROM valid_tips\n                UNION\n                SELECT tippee AS username FROM valid_tips) foo\n         WHERE NOT EXISTS (SELECT 1 FROM elsewhere WHERE participant=username)\n    ')
 assert (len(orphans_with_tips) == 0), orphans_with_tips

def _check_orphans_no_tips ( cursor ) : orphans_with_tips = cursor . all ( '\n        WITH valid_tips AS (SELECT * FROM current_tips WHERE amount > 0)\n        SELECT username\n          FROM (SELECT tipper AS username FROM valid_tips\n                UNION\n                SELECT tippee AS username FROM valid_tips) foo\n         WHERE NOT EXISTS (SELECT 1 FROM elsewhere WHERE participant=username)\n    ' ) assert ( len ( orphans_with_tips ) == 0 ) , orphans_with_tips
finds participants * without elsewhere account attached * having non zero outstanding tip this should not happen because when we remove the last elsewhere account in take_over we also zero out all tips .