I'm assuming from my experience with Canadian academia that this is a test that is taken in class, you turn it in at the end of the period, and then your professor either gives them back, graded, or allows you to come to their office and see your graded test.

You really need to find out whether your friend should have had a copy of the exam. Yes, if you saw a copy of an exam that was not released after the exam, it *could* be considered a form of cheating and you *might* get in trouble. 

If it was released to the class (or is a take home exam everyone had a chance to see), then there is no issue.

To be clear, I sincerely doubt you will get in trouble here. What you did is reasonable and expected, but at the very least, you should be prepared to explain the situation and know where the test came from. Maybe the professor would like to know whose leaking their tests.

I have had classes where professors kept their tests well-hidden enough that if someone had a copy, I would immediately have suspected them of wrongdoing. Without more details; it's impossible to know how your situation fits in.