I’ve pulled engines out of wrecking yards where they have been sitting in the mud for 25-30 years and found the interior of them to be in excellent condition, as to corrosion.
The chief exception has been where there was an aluminum part in the cooling system, they always turn out to be unuseable, but the iron is usually good, as long as the engine was not disassembled in any way.
If the engine is sealed and the air cleaner is in place, the engine can often run as well as it ever did with some minor work. Especially if the gas tank and carb were empty.