1414import org .tron .common .application .Application ;
1515import org .tron .common .application .ApplicationFactory ;
1616import org .tron .common .application .TronApplicationContext ;
17- import com .google .gson .JsonObject ;
18- import com .google .gson .JsonParser ;
19- import java .io .BufferedReader ;
20- import java .io .InputStreamReader ;
21- import java .net .HttpURLConnection ;
22- import java .net .URL ;
23- import java .util .stream .Collectors ;
24- import org .tron .common .utils .JsonUtilTest ;
2517import org .tron .common .utils .PublicMethod ;
2618import org .tron .core .Constant ;
2719import org .tron .core .config .DefaultConfig ;
@@ -42,18 +34,8 @@ public class WalletApiTest {
4234 public static void init () throws IOException {
4335 Args .setParam (new String []{ "-d" , temporaryFolder .newFolder ().toString (),
4436 "--p2p-disable" , "true" }, Constant .TEST_CONF );
45- int rpcPort = PublicMethod .chooseRandomPort ();
46- Args .getInstance ().setRpcPort (rpcPort );
37+ Args .getInstance ().setRpcPort (PublicMethod .chooseRandomPort ());
4738 Args .getInstance ().setRpcEnable (true );
48-
49- // http request for /wallet/xx on FullNode
50- Args .getInstance ().setFullNodeHttpPort (rpcPort + 1 );
51- Args .getInstance ().setFullNodeHttpEnable (true );
52-
53- // http request for /walletsolidity/xx on FullNode
54- Args .getInstance ().setSolidityHttpPort (rpcPort + 2 );
55- Args .getInstance ().setSolidityNodeHttpEnable (true );
56-
5739 context = new TronApplicationContext (DefaultConfig .class );
5840 appT = ApplicationFactory .create (context );
5941 appT .startup ();
@@ -71,49 +53,6 @@ public void listNodesTest() {
7153 .getNodesList ().isEmpty ());
7254 }
7355
74- @ Test
75- public void getPaginatedNowWitnessListTest () {
76- try {
77- String url = "http://127.0.0.1:" + Args .getInstance ().getFullNodeHttpPort () +
78- "/wallet/getpaginatednowwitnesslist" ;
79- HttpURLConnection connection = (HttpURLConnection ) new URL (url ).openConnection ();
80- connection .setRequestMethod ("POST" );
81- connection .setRequestProperty ("Content-Type" , "application/json" );
82- connection .setDoOutput (true );
83-
84- // Create JSON payload
85- String jsonPayload = "{\" offset\" : 0, \" limit\" : 1000, \" visible\" : true}" ;
86- connection .getOutputStream ().write (jsonPayload .getBytes ());
87- connection .getOutputStream ().flush ();
88-
89- Assert .assertEquals ("HTTP response code should be 200" , 200 , connection .getResponseCode ());
90- } catch (Exception e ) {
91- Assert .fail ("HTTP request failed: " + e .getMessage ());
92- }
93- }
94-
95- @ Test
96- public void getPaginatedNowWitnessListSolidityTest () {
97- try {
98- String url = "http://127.0.0.1:" + Args .getInstance ().getSolidityHttpPort () +
99- "/walletsolidity/getpaginatednowwitnesslist" ;
100- HttpURLConnection connection = (HttpURLConnection ) new URL (url ).openConnection ();
101- connection .setRequestMethod ("POST" );
102- connection .setRequestProperty ("Content-Type" , "application/json" );
103- connection .setDoOutput (true );
104-
105- // Create JSON payload
106- String jsonPayload = "{\" offset\" : 0, \" limit\" : 1000, \" visible\" : true}" ;
107- connection .getOutputStream ().write (jsonPayload .getBytes ());
108- connection .getOutputStream ().flush ();
109-
110- Assert .assertEquals ("HTTP response code should be 200" , 200 , connection .getResponseCode ());
111- } catch (Exception e ) {
112- Assert .fail ("HTTP solidity request failed: " + e .getMessage ());
113- }
114- }
115-
116-
11756 @ After
11857 public void destroy () {
11958 Args .clearParam ();
0 commit comments