99import com .typesafe .config .ConfigFactory ;
1010import com .typesafe .config .ConfigObject ;
1111import java .io .IOException ;
12+ import java .lang .reflect .Field ;
1213import java .nio .file .Path ;
1314import java .util .Collections ;
1415import java .util .HashMap ;
1516import java .util .Map ;
17+ import java .util .concurrent .atomic .AtomicBoolean ;
1618import org .junit .After ;
1719import org .junit .Assert ;
1820import org .junit .Rule ;
@@ -57,7 +59,13 @@ public void testTronError() {
5759 }
5860
5961 @ Test
60- public void ZksnarkInitTest () {
62+ public void ZksnarkInitTest () throws IllegalAccessException , NoSuchFieldException {
63+ Field field = ZksnarkInitService .class .getDeclaredField ("initialized" );
64+ field .setAccessible (true );
65+ AtomicBoolean atomicBoolean = (AtomicBoolean ) field .get (null );
66+ boolean originalValue = atomicBoolean .get ();
67+ atomicBoolean .set (false );
68+
6169 try (MockedStatic <JLibrustzcash > mock = mockStatic (JLibrustzcash .class )) {
6270 mock .when (() -> JLibrustzcash .librustzcashInitZksnarkParams (any ()))
6371 .thenAnswer (invocation -> {
@@ -66,6 +74,8 @@ public void ZksnarkInitTest() {
6674 TronError thrown = assertThrows (TronError .class ,
6775 ZksnarkInitService ::librustzcashInitZksnarkParams );
6876 assertEquals (TronError .ErrCode .ZCASH_INIT , thrown .getErrCode ());
77+ } finally {
78+ atomicBoolean .set (originalValue );
6979 }
7080 }
7181
0 commit comments