File tree Expand file tree Collapse file tree 2 files changed +21
-4
lines changed
framework/src/test/java/org/tron/core Expand file tree Collapse file tree 2 files changed +21
-4
lines changed Original file line number Diff line number Diff line change 44import static org .tron .keystore .Wallet .generateRandomBytes ;
55
66import com .google .protobuf .ByteString ;
7+ import org .junit .AfterClass ;
78import org .junit .Assert ;
9+ import org .junit .BeforeClass ;
810import org .junit .Test ;
911import org .tron .common .utils .ByteArray ;
1012import org .tron .core .capsule .BlockCapsule ;
13+ import org .tron .core .config .args .Args ;
1114import org .tron .core .services .jsonrpc .JsonRpcApiUtil ;
1215import org .tron .protos .Protocol .Block ;
1316import org .tron .protos .Protocol .BlockHeader ;
1619
1720public class ApiUtilTest {
1821
22+
23+ @ BeforeClass
24+ public static void init () {
25+ Args .setParam (new String []{}, "config-localtest.conf" );
26+ }
27+
28+ @ AfterClass
29+ public static void clear () {
30+ Args .clearParam ();
31+ }
32+
1933 @ Test
2034 public void testGetBlockID () {
2135 byte [] mockedHash = generateRandomBytes (128 );
Original file line number Diff line number Diff line change 1616import java .io .File ;
1717import java .io .IOException ;
1818import java .util .Collection ;
19+ import java .util .Objects ;
1920import java .util .concurrent .ExecutorService ;
2021import java .util .concurrent .Executors ;
2122import java .util .concurrent .TimeUnit ;
@@ -123,10 +124,12 @@ public static void init() throws Exception {
123124
124125 @ AfterClass
125126 public static void destroy () {
126- Collection <PeerConnection > peerConnections = ReflectUtils
127- .invokeMethod (tronNetDelegate , "getActivePeer" );
128- for (PeerConnection peer : peerConnections ) {
129- peer .getChannel ().close ();
127+ if (Objects .nonNull (tronNetDelegate )) {
128+ Collection <PeerConnection > peerConnections = ReflectUtils
129+ .invokeMethod (tronNetDelegate , "getActivePeer" );
130+ for (PeerConnection peer : peerConnections ) {
131+ peer .getChannel ().close ();
132+ }
130133 }
131134 Args .clearParam ();
132135 context .destroy ();
You can’t perform that action at this time.
0 commit comments