1111import org .tron .common .utils .ReflectUtils ;
1212import org .tron .core .Constant ;
1313import org .tron .core .config .DefaultConfig ;
14- // import org.tron.core.net.TronNetService;
15- // import org.tron.p2p.P2pConfig;
14+ import org .tron .core .net .TronNetService ;
15+ import org .tron .p2p .P2pConfig ;
1616
1717public class DynamicArgsTest {
1818 protected TronApplicationContext context ;
@@ -39,18 +39,31 @@ public void destroy() {
3939 public void get () {
4040 CommonParameter parameter = Args .getInstance ();
4141 Assert .assertFalse (parameter .isDynamicConfigEnable ());
42-
42+ Assert . assertEquals ( 600 , parameter . getDynamicConfigCheckInterval ());
4343 }
4444
4545 @ Test
4646 public void start () {
4747 dynamicArgs .init ();
4848 Assert .assertEquals (0 , (long ) ReflectUtils .getFieldObject (dynamicArgs , "lastModified" ));
4949
50- dynamicArgs .run ();
51- // TronNetService tronNetService = context.getBean(TronNetService.class);
52- // ReflectUtils.setFieldValue(tronNetService, "p2pConfig", new P2pConfig());
53- // dynamicArgs.reload();
50+ TronNetService tronNetService = context .getBean (TronNetService .class );
51+ ReflectUtils .setFieldValue (tronNetService , "p2pConfig" , new P2pConfig ());
52+ File config = new File (Constant .TESTNET_CONF );
53+ if (!config .exists ()) {
54+ try {
55+ config .createNewFile ();
56+ } catch (Exception e ) {
57+ return ;
58+ }
59+ dynamicArgs .run ();
60+ try {
61+ config .delete ();
62+ } catch (Exception e ) {
63+ return ;
64+ }
65+ }
66+
5467 dynamicArgs .close ();
5568 }
5669}
0 commit comments