Skip to content

Instantly share code, notes, and snippets.

@sz332
Created September 26, 2021 08:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sz332/0dc70c244b4877eed01c69bafa7a6fb8 to your computer and use it in GitHub Desktop.
Save sz332/0dc70c244b4877eed01c69bafa7a6fb8 to your computer and use it in GitHub Desktop.
---------------------------- MODULE statemachine ----------------------------
EXTENDS TLC, Sequences, Integers
(* --algorithm statemachine
fair process webProcess = 1
variables
machineState = "Starting",
run = TRUE;
accessAttemptState = "NULL";
begin P:
while run do
Start:
if machineState = "Starting" then
machineState := "LoginScreen";
else
skip;
end if;
LoginScreen:
if machineState = "LoginScreen" then
machineState := "TotpScreen";
accessAttemptState := "Undecided";
else
skip;
end if;
TotpScreen:
if machineState = "TotpScreen" then
either
machineState := "LoggedInScreen";
or
machineState := "SmsScreen";
accessAttemptState := "Cancelled";
end either;
else
skip;
end if;
SmsScreen:
if machineState = "SmsScreen" then
machineState := "LoggedInScreen";
else
skip;
end if;
LoggedInScreen:
if machineState = "LoggedInScreen" then
machineState := "Stop";
else
skip;
end if;
Stop:
if machineState = "Stop" then
assert accessAttemptState = "Undecided" \/ accessAttemptState = "Cancelled";
run := FALSE;
else
skip;
end if;
end while;
end process;
end algorithm; *)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment