Used engines are a coin flip. It’s been my experience that roughly 35-40% of every used engine, transmission, or rear axle I’ve dealt with had issues from comparatively small to serious and in some cases outright scrap metal in spite of claims to the contrary.
There’s not a mechanic on the face of the Earth who can tell you that a used engine is good to go and will have no problems.
Knowing that an engine has had a verifiable compression done with good readings and if the shop is willing to stand behind that used engine for a certain period of time or miles can at least help the situation.
A used engine should also receive new front and rear crank seals before installation along with a new timing belt kit if applicable. Also throw in a new torque converter seal on auto trans models.
As to cost, there’s no way of knowing. The price can vary widely based on cost, markup, labor rates, locale, and so on. A late model Benz engine is going to cost far more than a late model Ford Escort engine as the type of car is unknown.
If the car is very high miles and has rust it may not be worth doing anything to at all.