That the cop claims to be your friend is not more illegal than a salesman claiming that he has "the best offer" for you because he likes you (in fact didn't you see any film about the good cop/bad cop routine?)
The term you are looking for is Entrapment. The (very simplified) basic idea is that police officers can promote the comission of a crime to catch criminals but cannot "trap" innocent people into it; the difference being that their persuassion should not turn otherwise innocent people into criminals.
An extreme example would be if the cop threatens the target into commiting a crime.
For the more usual situation when a cop promotes a crime to catch the criminal, I saw it explained (just for illustration purposes, it is not that you are safe when the cop insists a third time) as it follows:
- Legal:
Cop) Oh boy! The place where I work is full of cash and they don't even have alarms or store it in a safe box. If someone helps me, we could go this night and take all of it. Are you interested?
Target) I don't know.
Cop) Trust me, it will be easy, nobody is there at night and it will be just a couple of hours.
Target) Ok, count me in.
- Illegal
Cop) Oh boy! The place where I work is full of cash and they don't even have alarms or store it in a safe box. If someone helps me, we could go this night and take all of it. Are you interested?
Target) I am not a thief.
Cop) Come on, it will be easy, the place is insured and nobody will be hurt.
Target) Not interested.
Cop) We can get 5000 US$ each one, just for a night of work. Didn't you told me that you had troubles with your bank? You could solve those overnight!
Target) Maybe you are right, but I have no experience with these things...
Cop) Do not worry, I will tell you what you need to do.
Target) Ok, count me in.
Note that it is not only "the cop insisted a lot". For the drug dealer example, if the cop insisted a lot but, when agreed, the boy produced the drug by himself in 15 minutes, it could be interpreted as that the guy knew where to get it and had done it before. OTOH, if the guy had told "I do not know where to buy drugs" and the cop had told him "go talk with X so he sells you the drug", then it could be considered entrampment.
In any case, this is generic information only, entrapment is difficult to prove and will depend on the views of the judge/jury so, no matter how enticing that criminal offer is, just don't do it.