Is the early stopping of xgboost using correct
That's not cheating. If your test set is a representative sample of the future data you'll want to make predictions on, you'll want to have the lowest possible error there!

If you maximized performance on the training set, instead, you might overfit. It's fairly easy for a boosted algorithm to inadvertently memorize its training data rather than learn a meaningful mapping of inputs to output.

Per the comment below, the "test set" you describe is actually functioning like a validation set here.