We analyze a discrimination problem of a single-qubit unitary gate with two candidates, where the candidates are not provided with their classical description, but their quantum sample is. More precisely, there are three unitary quantum gates—one target and one sample for each of the two candidates—whose classical description is unknown except for their dimension. The target gate is chosen equally among the candidates. We obtain the optimal protocol that maximizes the expected success probability, assuming the Haar distribution for the candidates. This problem is originally introduced in Ref.  which provides a protocol achieving 7/8 in the expected success probability based on the "unitary comparison" protocol of Ref. . The optimality of the protocol has been an open question since then. We prove the optimality of the comparison protocol, implying that only one of the two samples (one for each candidate) is needed to achieve an optimal discrimination. The optimization includes protocols outside the scope of quantum testers due to the dynamic ordering of the sample and target gates within a given protocol.