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 ;
1725import org .tron .common .utils .PublicMethod ;
1826import org .tron .core .Constant ;
1927import org .tron .core .config .DefaultConfig ;
@@ -34,8 +42,18 @@ public class WalletApiTest {
3442 public static void init () throws IOException {
3543 Args .setParam (new String []{ "-d" , temporaryFolder .newFolder ().toString (),
3644 "--p2p-disable" , "true" }, Constant .TEST_CONF );
37- Args .getInstance ().setRpcPort (PublicMethod .chooseRandomPort ());
45+ int rpcPort = PublicMethod .chooseRandomPort ();
46+ Args .getInstance ().setRpcPort (rpcPort );
3847 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+
3957 context = new TronApplicationContext (DefaultConfig .class );
4058 appT = ApplicationFactory .create (context );
4159 appT .startup ();
@@ -53,6 +71,49 @@ public void listNodesTest() {
5371 .getNodesList ().isEmpty ());
5472 }
5573
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+
56117 @ After
57118 public void destroy () {
58119 Args .clearParam ();
0 commit comments