In general, the rules and norms of a test - what is expected, what sources can be evaluated, if any, etc - should be known before the test is taken. This usually takes the form of a syllabus or verbal instructions at exam time.
A typical set of norms is along the lines of: open book, open notes, no cooperation; closed book, open/limited notes (like 1-page hand-written sheet, or index card, or "anything that fits on a letter-sized sheet", etc); closed book, closed notes; and so on. In an electronic lab, there is usually also a policy on general internet use, and you noted no internet access - so obviously some rules and norms were in place.
These rules and norms are what makes fairness and useful evaluation possible in the academic context. If no one cared when or how you did the work, then of course the rules would reflect that; if people do care specifically to know how, when, and/or who did the work, then the rules are made to reflect that. We don't know what rules were in place at the time, but as a student it's your job to find out what they are - and if you don't know, ask as early on as possible so there are no possible misunderstandings.
I will close with my general advice on all matters of honesty: if you feel like you need to hide it, you should think very carefully about what exactly it is that you are doing. If you pretended to be busy during the exam so it didn't look like you finished impossibly quickly, that suggests that at the time you thought something was fishy - or ambiguous - about what you were doing then.
In the future you should ask in advance what the rules are if you don't know them, and if an unexpected scenario comes up - ask the person in charge right then!
I cannot really offer advice on what to do now, though, as that is going to be a pretty personal decision. If you have a good relationship with the teacher I'd especially advise you to contact them to talk about the issue, noting how you thought it wasn't against the rules but now you are concerned that you should have said something at the time and had no idea that the solution you had - which was your work in full - was going to be on the test.
As a final note, if you wonder why using the solution might not have been allowable: the solution you had was not completed in a verified time limit, and you obviously would have had access to the internet, other people's potential help, etc, in preparing your solution. No other students had such an opportunity, so when the person is grading it would certainly not be fair for other student's work to be compared to yours when your work was not prepared in the same environment (and the grader has no idea you had advantages the other student's did not have in the exam).
Ultimately how you handle the current (past) situation is up to you, but I hope in the future that you'll act differently so you don't end up in such an uncomfortable position - when in doubt, ask.