My food delivery app has modafinil from any of the local pharmacies or I can get it at the mall on the way back from the gym. In fact, I can get most medications this way and I don’t have to pay the 30$ it would cost me to see my doctor if I was in my home country.
How do you know? Do they have a lab certification/ is there a regulating body?
Then when you receive you order, you'd sacrifice a pill to carefully weigh it, check the coating matches, packaging and so on. If you ordered a whole bunch, you would check batch numbers and sample each batch for testing.
Obviously this isn't foolproof, but if someone is going to sell a counterfeit they aren't going to practically spend a lot of time in making it a perfect one.
I suppose someone could create fraudulent drugs, but honestly, it's probably cheaper just to sell you the real deal. And just like other businesses they want your repeat business.
I know they are the real drug in my case because I take them for mildly high blood pressure. It's trivial to measure blood pressure, and I can see that they have the same effect as the American drugs of the same dosage.
The funny thing is, I mostly do it because I don't want to go to the doctor every six months to say "mother may I" for a very mild and safe statin. My insurance would pay for everything, but it's such a pain to do.