Various harm-reduction organisations like DanceSafe[1] offer testing kits that can be used to determine the primary agent and any significant adulterants[2].
There are also testing labs which process anonymous samples sent by post and determine the active agents. For example, http://www.ecstasydata.org/ Due to the complicated issues of the legality of illegal drug analysis, they can provide only ratios of active agents, rather than quantifiable values[3].
A quick look doesn't turn up any testing kits for LSD detection (or rather, the only ones that do are intended for testing people, rather than the drug itself)
if it's shrooms, you can tell whether something looks like mushrooms right? that means there's three options:
1) it'll kill you
2) it'll do nothing or make you nauseous
3) it's the real thing
nobody's gonna sell you poisonous mushrooms or they'll be in big trouble and be out of clientele really fast.
shrooms that look like proper shrooms but do nothing, I don't know if they even exist.
in both (unlikely) cases, it's not harder or more expensive to obtain mushrooms that actually do what they're supposed to do, than to get poisonous or ineffective ones, so what would be the incentive to do that?? shrooms is shrooms. they're not even that hard to tell apart, if you got a book with pictures.
it's a whole different thing if you got a blotter (LSD) with a drop of god-knows-what impregnated on it. then you need to be careful and really know who you're buying from.
People have died trying to pick psychedelic mushrooms in the wild and getting it wrong. Then again, that danger exists with regular food mushrooms in the wild as well. You just really need to know what you're doing.
From a dealer, you're very unlikely to get toadstools, for the reasons you described, but non-psychedelic mushrooms (even from the grocery store) are frequently dosed with cheap and often legal, but dangerous "research chemicals" and sold as psilocybin mushrooms. This was done with LSD back when it was cheap and readily available as well.
The one time I tried 'LSD', it wasn't.