A used motor is always gonna be a bit of a gamble.
But, there's things you can do to reduce the gamble before you buy.
Is the used engine running and in a vehicle?
If so, go see a cold start. Doors or start clearly?
Pull the oil cap, is it clean inside? No sludge?
Pull the plugs, inspect the plug tips.
Do a compression test. (a gauge is sub $50)
Does the overall condition suggest neglect? Or looked after?
If it's not in a vehicle,
Inspect plugs
Turn the engine over by hand. Does it turn over freely? If not, pass.
Check inside oil cap, check dipstick. Any sign of sludge or water? If yes, pass
Overall condition? If it looks neglected, reconsider your life choices.
I wouldn't buy an engine sight unseen, or if seller wasn't willing to let me check the above.
If buying unseen, only way would be from a reputable seller who would honour a warranty, and cover return shipping.
Potentially, depending on the failure.
You'll know a soon as you pull the head off.
I put a used engine in mine. It was put off the car when i bought it.
Checked all of the above. Installed it as is (resealed the sump before installing), then found it had no compression when i started it.
Blown head gasket.
I already new the bottom end was OK from resting sump seal, so I put a new head gasket and seal kit in it, along with a bunch of new sensors.
My logic being, if i decided to rebuild my original engine, I could resell the running used engine and recover the costs.
If i didn't do a rebuild, the used engine was in good shape for the foreseeable future.