Open Zanion opened 4 years ago
I'll add automated tests over this weekend to complete the PR prior to approval/merge. I intend to create a test directory in root using pytest unless you have a different convention.
Thanks for the pull request. I'll try to find somebody to code review this after the U.S. winter holiday season. I did have one question though: the pipenv changes for dependency management seem unrelated to the bug being addressed. Would it be possible to separate those changes into another pull request, so they can be considered and reviewed separately?
Not a problem, thank you. I rebased and cherry-picked just the tests without the Pipenv additions. I added documentation above for running the included automated tests with natively installed pytest.
Summary
The simulator was failing to encode messages consistently with known reliably correct simulators see: Issue 5
Identified root error being that the rotor was being stepped on each keystroke from the left rotor rightwards, this is backwards from reality. The Enigma machine steps the first rotor by the entrywheel which is the rightmost rotor from perspective of the operator. The simulator had the stepping execution reversed in code accordingly and is now producing the correct encodings.
Reference: http://users.telenet.be/d.rijmenants/en/enigmatech.htm
TC1 Settings:
Rotors: I, II, III Initial position: M, E, U Ring setting: A, A, A Reflector: UKW-B Input: AAAAA Expected result: GDXTZ
Double Stepping Mid-Rotor
Additionally added lacking double-step functionality for the mid-rotor. The middle rotor will advance on the next step of the first rotor a second time if the middle rotor notch is aligned with the pawl.
Reference: http://users.telenet.be/d.rijmenants/en/enigmatech.htm
TC2 Settings:
Tested based on sequence for doublesteps from: http://users.telenet.be/d.rijmenants/en/enigmatech.htm
Rotors: III, II, I Initial position: K, D, O Ring setting: A, A, A Reflector: UKW-B
Verified window sequence: KDO->KDP->KDQ->KER->LFS->LFT->LFU
Testing
The tests to validate the functionality depend upon pytest being installed on the system. They can be executed from the project directory and ran with the pytest command: