Solution (source code)

= Solution

At the boundary null $\pi_1=\pi_0=\pi$, $\bar\pi=\pi$. Independence of the binomial proportions gives
$$
\mathbb ET=0,
\qquad
\operatorname{Var}T=1,
$$
asymptotically, so $T\Rightarrow N(0,1)$. For the composite null $\delta<0$, the mean moves to the nonrejection side, making the boundary the least favorable case.