function syncAndExpectNodeReassignment(server, firstNotification, between,
                                       secondNotification, url) {
  let deferred = Promise.defer();
  function onwards() {
    let nodeFetched = false;
    function onFirstSync() {
      _("First sync completed.");
      Svc.Obs.remove(firstNotification, onFirstSync);
      Svc.Obs.add(secondNotification, onSecondSync);

      do_check_eq(Service.clusterURL, "");

      // Track whether we fetched node/weave. We want to wait for the second
      // sync to finish so that we're cleaned up for the next test, so don't
      // run_next_test in the node handler.
      nodeFetched = false;

      // Verify that the client requests a node reassignment.
      // Install a node handler to watch for these requests.
      installNodeHandler(server, function () {
        nodeFetched = true;
      });

      // Allow for tests to clean up error conditions.
      between();
    }
    function onSecondSync() {
      _("Second sync completed.");
      Svc.Obs.remove(secondNotification, onSecondSync);
      Service.scheduler.clearSyncTriggers();

      // Make absolutely sure that any event listeners are done with their work
      // before we proceed.
      waitForZeroTimer(function () {
        _("Second sync nextTick.");
        do_check_true(nodeFetched);
        Service.startOver();
        server.stop(deferred.resolve);
      });
    }

    Svc.Obs.add(firstNotification, onFirstSync);
    Service.sync();
  }

  // Make sure that it works!
  let request = new RESTRequest(url);
  request.get(function () {
    do_check_eq(request.response.status, 401);
    Utils.nextTick(onwards);
  });
  yield deferred.promise;
}
/**
 * Make a test request to `url`, then watch the result of two syncs
 * to ensure that a node request was made.
 * Runs `between` between the two. This can be used to undo deliberate failure
 * setup, detach observers, etc.
 */
Make a test request to `url`, then watch the result of two syncs
to ensure that a node request was made.
Runs `between` between the two. This can be used to undo deliberate failure
setup, detach observers, etc.
Make a test request to ` url ` then watch the result of two syncs to ensure that a node request was made . Runs ` between ` between the two . This can be used to undo deliberate failure setup detach observers etc .
function syncAndExpectNodeReassignment(server, firstNotification, between,
                                       secondNotification, url) {
  let deferred = Promise.defer();
  function onwards() {
    let nodeFetched = false;
    function onFirstSync() {
      _("First sync completed.");
      Svc.Obs.remove(firstNotification, onFirstSync);
      Svc.Obs.add(secondNotification, onSecondSync);
      do_check_eq(Service.clusterURL, "");
      nodeFetched = false;
      installNodeHandler(server, function () {
        nodeFetched = true;
      });
      between();
    }
    function onSecondSync() {
      _("Second sync completed.");
      Svc.Obs.remove(secondNotification, onSecondSync);
      Service.scheduler.clearSyncTriggers();
      waitForZeroTimer(function () {
        _("Second sync nextTick.");
        do_check_true(nodeFetched);
        Service.startOver();
        server.stop(deferred.resolve);
      });
    }
    Svc.Obs.add(firstNotification, onFirstSync);
    Service.sync();
  }
  let request = new RESTRequest(url);
  request.get(function () {
    do_check_eq(request.response.status, 401);
    Utils.nextTick(onwards);
  });
  yield deferred.promise;
}
function syncAndExpectNodeReassignment ( server , firstNotification , between , secondNotification , url ) { let deferred = Promise . defer ( ) ; function onwards ( ) { let nodeFetched = false ; function onFirstSync ( ) { _ ( "First sync completed." ) ; Svc . Obs . remove ( firstNotification , onFirstSync ) ; Svc . Obs . add ( secondNotification , onSecondSync ) ; do_check_eq ( Service . clusterURL , "" ) ; nodeFetched = false ; installNodeHandler ( server , function ( ) { nodeFetched = true ; } ) ; between ( ) ; } function onSecondSync ( ) { _ ( "Second sync completed." ) ; Svc . Obs . remove ( secondNotification , onSecondSync ) ; Service . scheduler . clearSyncTriggers ( ) ; waitForZeroTimer ( function ( ) { _ ( "Second sync nextTick." ) ; do_check_true ( nodeFetched ) ; Service . startOver ( ) ; server . stop ( deferred . resolve ) ; } ) ; } Svc . Obs . add ( firstNotification , onFirstSync ) ; Service . sync ( ) ; } let request = new RESTRequest ( url ) ; request . get ( function ( ) { do_check_eq ( request . response . status , 401 ) ; Utils . nextTick ( onwards ) ; } ) ; yield deferred . promise ; }
Make a test request to `url`, then watch the result of two syncs
 to ensure that a node request was made.
Make a test request to ` url ` then watch the result of two syncs to ensure that a node request was made .
// Track whether we fetched node/weave. We want to wait for the second // sync to finish so that we're cleaned up for the next test, so don't // run_next_test in the node handler. // Verify that the client requests a node reassignment. // Install a node handler to watch for these requests. // Allow for tests to clean up error conditions. // Make absolutely sure that any event listeners are done with their work // before we proceed. // Make sure that it works!