jstests/replsets/libs/initial_sync_test.js
/**
     * Transition from the current State to `newState` if it's a valid transition, otherwise throw
     * an error.
     */
Transition from the current State to `newState` if it's a valid transition, otherwise throw
an error.
Transition from the current State to ` newState ` if it ' s a valid transition otherwise throw an error .
function transitionIfAllowed(newState) {
        if (AcceptableTransitions[currState].includes(newState)) {
            jsTestLog(`Transitioning to: "${newState}"`, true);
            currState = newState;
        } else {
            throw new Error(`Can't transition to State "${newState}" from State "${currState}"`);
        }
    }
function transitionIfAllowed ( newState ) { if ( AcceptableTransitions [ currState ] . includes ( newState ) ) { jsTestLog ( ` ${ newState } ` , true ) ; currState = newState ; } else { throw new Error ( ` ${ newState } ${ currState } ` ) ; } }
Transition from the current State to `newState` if it's a valid transition, otherwise throw
 an error.
Transition from the current State to ` newState ` if it ' s a valid transition otherwise throw an error .
// Transitioning to a disallowed State is likely a bug in the code, so we throw an // error here instead of silently failing.