לב אליהו חכמה ומוסר עמ' רסב
בשם החפץ חיים ז"ל: "נודע בשערים בעלה בשבתו עם זקני ארץ". התורה נקראת "אשת חיל", א"כ מי הוא הבעל של "אשת חיל? - הת"ח העוסק בתורה! והנה יש לך ת"ח כשמדברים אתו בד"ת מביא הרבה מאמרים של תנאים ואמוראים, וחושבים שהוא בקי בש"ס, אבל האמת הוא שגמרא זו הוא יודע, שהקצות מביאה, וגמרא זו הוא יודע מהנתיבות, והשלישית מהפני יהושע, כל זה בעולם הזה. אבל "נודע בשערים" - היינו שערים המצויינים בהלכה – "בעלה" של האשת חיל מתי הוא נודע אם הוא באמת ת"ח שלמד ובקי בש"ס או לא? - שם "בשבתו עם זקני ארץ" - לעולם הבא, ויאמרו לו אמור מה שלמדת וכו,.
The following was quoted in the name of the Chafetz Chaim: "Her husband is known in the gates, when he sits among the elders of the land." (Mishlei 31:23).
The Torah is called "Eishes Chayil, woman of valour". If so, who is her husband? Obviously the Torah scholar who is immersed in Torah learning!
There is one type of scholar who when you speak with him in words of Torah, he quotes numerous sayings from the Mishna and Gemara, and others think he must be fluent in the whole Talmud. However the truth is that he onlt knows the Gemaras from other Sefarim where he's seen them quoted in turn. That's in "Olam Hazeh, this world."
But "Noda Bashearim, Known in the gates", refers to the gates of the experts in Halacha (Jewish practice).
"Her husband" - when do we know if the husband of the "Eishes Chayil, woman of valour" is truly a learned scholar or not?
"when he sits among the elders of the land." - this refers to the World to Come where he is asked to relate what he has learned.
Elsewhere, it is brought as a story as you mention it:
לב אליהו ח"א עמ' רא
בשביבי לב מובא שהגה"צ ר' אלי' לופיאן התארח אצל הח"ח בש"ק, ופירש הח"ח את הפס' ב'אשת חיל' – נודע בשערים בעלה בשבתו עם זקני ארץ, שיש מי שבעוה"ז מתפאר בידיעותיו בש"ס וראשונים, ולמעשה יודע זאת לא ממקור הדברים בפנים, אלא שראם בספרים שונים שציטטו גמ' זו ותוס' זה וכו', וכיגיע לאחר פטירתו יבחנוהו פמליא של מעלה, ואז יתבעו ממנו 'ערוך מה שלמדת' דף על דף..., וזה מ"ש הפס' 'נודע בשערים בעלה', מתי יתוודע בעלה של התורה, 'בשבתו עם זקני ארץ', הם הבי"ד של מעלה.