You still need to add the waved line at the bottom. Also note that usually you can wrap the node around the environment content be replacing \node {..}; with \node \bgroup and \egroup;, however, this didn't worked for the listings environment. Most likely some of the verbatim trickery causes issues. (This is funny because verbatim should work inside a TikZ node)
Here's a method that doesn't require loading TikZ explicitly. (Although mdframed uses tikz behind the scenes. This is, however, the package for framing boxes.
Best Answer
You can use
TikZ
:Zooming in your example picture reveals that you might wish a “dashed” instead of a “dotted” frame. In this case, just replace
dotted
withdashed
: