Im pretty sure in the UK you cant get busted for buying pills as the drug has to be in or connected to your possesion. Im pretty sure cops selling pills is entrapment if they are the ones initiating the sale. With the swap gig sounds shady but would probably hold up in court if they really didnt like you.
Nah Im sorry but entrapment in the UK doenst apply! If your at a gig and somebody buys/sells your pills and your then busted then your screwed.
Seriously though thinking about it - the cop that sold you the beans are not going to then arrest you, are they? They would simply have another cop standing behind you and as soon as the deal is done they would arrest you and the 'seller' would walk away.