Skip to content

Commit ebf5d0b

Browse files
committed
Add Stest http solidityNode interface case
1 parent b122e65 commit ebf5d0b

9 files changed

Lines changed: 291 additions & 25 deletions

File tree

‎src/test/java/stest/tron/wallet/common/client/utils/HttpMethed.java‎

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,8 @@ public static HttpResponse getTransactionInfoByIdFromSolidity(String httpSolidit
12751275
/**
12761276
* constructor.
12771277
*/
1278-
public static HttpResponse getTransactionCountByBlocknumFromSolidity(String httpSolidityNode, long blocknum) {
1278+
public static HttpResponse getTransactionCountByBlocknumFromSolidity(String httpSolidityNode,
1279+
long blocknum) {
12791280
try {
12801281
String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/gettransactioncountbyblocknum";
12811282
JsonObject userBaseObj2 = new JsonObject();
@@ -1482,12 +1483,11 @@ public static void waitToProduceOneBlock(String httpNode) {
14821483
}
14831484
}
14841485

1485-
14861486
/**
14871487
* constructor.
14881488
*/
1489-
public static void waitToProduceOneBlockFromSolidity(String httpSolidityNode) {
1490-
response = HttpMethed.getNowBlockFromSolidity(httpSolidityNode);
1489+
public static void waitToProduceOneBlockFromSolidity(String httpNode, String httpSolidityNode) {
1490+
response = HttpMethed.getNowBlock(httpNode);
14911491
responseContent = HttpMethed.parseResponseContent(response);
14921492
responseContent = HttpMethed.parseStringContent(responseContent.get("block_header").toString());
14931493
responseContent = HttpMethed.parseStringContent(responseContent.get("raw_data").toString());
@@ -1721,15 +1721,15 @@ public static HttpResponse getAssetissueList(String httpNode) {
17211721
* constructor.
17221722
*/
17231723
public static HttpResponse getAssetIssueListFromSolidity(String httpSolidityNode) {
1724-
try {
1725-
String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getassetissuelist";
1726-
response = createConnect(requestUrl);
1727-
} catch (Exception e) {
1728-
e.printStackTrace();
1729-
httppost.releaseConnection();
1730-
return null;
1731-
}
1732-
return response;
1724+
try {
1725+
String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getassetissuelist";
1726+
response = createConnect(requestUrl);
1727+
} catch (Exception e) {
1728+
e.printStackTrace();
1729+
httppost.releaseConnection();
1730+
return null;
1731+
}
1732+
return response;
17331733
}
17341734

17351735
/**

‎src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount001.java‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ public class HttpTestAccount001 {
2020
private HttpResponse response;
2121
private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list")
2222
.get(0);
23+
private String httpSoliditynode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list")
24+
.get(2);
2325

2426
/**
2527
* constructor.
@@ -34,6 +36,19 @@ public void getAccount() {
3436
Assert.assertTrue(responseContent.size() > 3);
3537
}
3638

39+
/**
40+
* constructor.
41+
*/
42+
@Test(enabled = true, description = "Get account from solidity by http")
43+
public void getAccountFromSolidity() {
44+
response = HttpMethed.getAccountFromSolidity(httpSoliditynode, fromAddress);
45+
logger.info("code is " + response.getStatusLine().getStatusCode());
46+
Assert.assertEquals(response.getStatusLine().getStatusCode(), 200);
47+
responseContent = HttpMethed.parseResponseContent(response);
48+
HttpMethed.printJsonContent(responseContent);
49+
Assert.assertTrue(responseContent.size() > 3);
50+
}
51+
3752
/**
3853
* constructor.
3954
*/

‎src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount002.java‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class HttpTestAccount002 {
2424
private HttpResponse response;
2525
private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list")
2626
.get(1);
27+
private String httpSoliditynode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list").get(2);
2728

2829
ECKey ecKey1 = new ECKey(Utils.getRandom());
2930
byte[] freezeBalanceAddress = ecKey1.getAddress();
@@ -145,6 +146,25 @@ public void test6GetDelegatedResource() {
145146
frozenBalance);
146147
}
147148

149+
/**
150+
* constructor.
151+
*/
152+
@Test(enabled = true, description = "Get Delegated Resource from solidity by http")
153+
public void test6GetDelegatedResourceFromSolidity() {
154+
response = HttpMethed.getDelegatedResourceFromSolidity(
155+
httpSoliditynode,freezeBalanceAddress,receiverResourceAddress);
156+
responseContent = HttpMethed.parseResponseContent(response);
157+
HttpMethed.printJsonContent(responseContent);
158+
JSONArray jsonArray = JSONArray.parseArray(responseContent.get("delegatedResource").toString());
159+
Assert.assertTrue(jsonArray.size() >= 1);
160+
Assert.assertEquals(jsonArray.getJSONObject(0).getString("from"),
161+
ByteArray.toHexString(freezeBalanceAddress));
162+
Assert.assertEquals(jsonArray.getJSONObject(0).getString("to"),
163+
ByteArray.toHexString(receiverResourceAddress));
164+
Assert.assertEquals(jsonArray.getJSONObject(0).getLong("frozen_balance_for_bandwidth"),
165+
frozenBalance);
166+
}
167+
148168
/**
149169
* constructor.
150170
*/
@@ -158,6 +178,19 @@ public void test7GetDelegatedResourceAccountIndex() {
158178
Assert.assertEquals(toAddress,ByteArray.toHexString(receiverResourceAddress));
159179
}
160180

181+
/**
182+
* constructor.
183+
*/
184+
@Test(enabled = true, description = "Get Delegated Resource Account Index from solidity by http")
185+
public void test7GetDelegatedResourceAccountIndexFromSolidity() {
186+
response = HttpMethed.getDelegatedResourceAccountIndexFromSolidity(httpSoliditynode,freezeBalanceAddress);
187+
responseContent = HttpMethed.parseResponseContent(response);
188+
HttpMethed.printJsonContent(responseContent);
189+
Assert.assertFalse(responseContent.get("toAccounts").toString().isEmpty());
190+
String toAddress = responseContent.getJSONArray("toAccounts").get(0).toString();
191+
Assert.assertEquals(toAddress,ByteArray.toHexString(receiverResourceAddress));
192+
}
193+
161194
/**
162195
* constructor.
163196
*/

‎src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAccount003.java‎

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ public class HttpTestAccount003 {
2626
private HttpResponse response;
2727
private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list")
2828
.get(0);
29+
private String httpSoliditynode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list").get(2);
2930
private final String witnessKey001 = Configuration.getByPath("testng.conf")
3031
.getString("witness.key1");
3132
private final byte[] witness1Address = PublicMethed.getFinalAddress(witnessKey001);
@@ -118,6 +119,18 @@ public void test3ListWitness() {
118119
Assert.assertTrue(jsonArray.size() >= 2);
119120
}
120121

122+
/**
123+
* constructor.
124+
*/
125+
@Test(enabled = true, description = "List witnesses from solidity by http")
126+
public void test3ListWitnessFromSolidity() {
127+
response = HttpMethed.listwitnessesFromSolidity(httpSoliditynode);
128+
responseContent = HttpMethed.parseResponseContent(response);
129+
HttpMethed.printJsonContent(responseContent);
130+
JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("witnesses"));
131+
Assert.assertTrue(jsonArray.size() >= 2);
132+
}
133+
121134
/**
122135
* constructor.
123136
*/

‎src/test/java/stest/tron/wallet/dailybuild/http/HttpTestAsset001.java‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ public class HttpTestAsset001 {
2626
private HttpResponse response;
2727
private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list")
2828
.get(1);
29+
private String httpSoliditynode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list").get(2);
30+
2931

3032
ECKey ecKey1 = new ECKey(Utils.getRandom());
3133
byte[] assetAddress = ecKey1.getAddress();
@@ -87,6 +89,18 @@ public void test2GetAssetIssueById() {
8789
Assert.assertTrue(totalSupply == getAssetIssueByIdContent.getLong("total_supply"));
8890
}
8991

92+
/**
93+
* constructor.
94+
*/
95+
@Test(enabled = true, description = "GetAssetIssueById from solidity by http")
96+
public void test2GetAssetIssueByIdFromSolidity() {
97+
HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode);
98+
response = HttpMethed.getAssetIssueByIdFromSolidity(httpSoliditynode, assetIssueId);
99+
getAssetIssueByIdContent = HttpMethed.parseResponseContent(response);
100+
HttpMethed.printJsonContent(getAssetIssueByIdContent);
101+
Assert.assertTrue(totalSupply == getAssetIssueByIdContent.getLong("total_supply"));
102+
}
103+
90104
/**
91105
* constructor.
92106
*/
@@ -97,6 +111,16 @@ public void test3GetAssetIssueByName() {
97111
HttpMethed.printJsonContent(getAssetIssueByNameContent);
98112
}
99113

114+
/**
115+
* constructor.
116+
*/
117+
@Test(enabled = true, description = "GetAssetIssueByName from solidity by http")
118+
public void test3GetAssetIssueByNameFromSolidity() {
119+
response = HttpMethed.getAssetIssueByNameFromSolidity(httpSoliditynode, name);
120+
getAssetIssueByNameContent = HttpMethed.parseResponseContent(response);
121+
HttpMethed.printJsonContent(getAssetIssueByNameContent);
122+
}
123+
100124
/**
101125
* constructor.
102126
*/
@@ -168,6 +192,22 @@ public void test7GetAssetissueList() {
168192
}
169193

170194

195+
/**
196+
* * constructor. *
197+
*/
198+
@Test(enabled = true, description = "Get asset issue list from solidity by http")
199+
public void test7GetAssetissueListFromSolidity() {
200+
201+
response = HttpMethed.getAssetIssueListFromSolidity(httpSoliditynode);
202+
responseContent = HttpMethed.parseResponseContent(response);
203+
HttpMethed.printJsonContent(responseContent);
204+
Assert.assertEquals(response.getStatusLine().getStatusCode(), 200);
205+
206+
JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("assetIssue"));
207+
Assert.assertTrue(jsonArray.size() >= 1);
208+
}
209+
210+
171211
/**
172212
* * constructor. *
173213
*/
@@ -183,6 +223,21 @@ public void test8GetPaginatedAssetissueList() {
183223
}
184224

185225

226+
/**
227+
* * constructor. *
228+
*/
229+
@Test(enabled = true, description = "Get paginated asset issue list from solidity by http")
230+
public void test8GetPaginatedAssetissueListFromSolidity() {
231+
response = HttpMethed.getPaginatedAssetissueListFromSolidity(httpSoliditynode, 0, 1);
232+
responseContent = HttpMethed.parseResponseContent(response);
233+
HttpMethed.printJsonContent(responseContent);
234+
Assert.assertEquals(response.getStatusLine().getStatusCode(), 200);
235+
236+
JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("assetIssue"));
237+
Assert.assertTrue(jsonArray.size() == 1);
238+
}
239+
240+
186241
/**
187242
* constructor.
188243
*/

‎src/test/java/stest/tron/wallet/dailybuild/http/HttpTestBlock001.java‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ public class HttpTestBlock001 {
1717
private HttpResponse response;
1818
private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list")
1919
.get(0);
20+
private String httpSoliditynode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list").get(2);
2021
private Integer currentBlockNum;
2122
private JSONObject blockContent;
2223
private String blockId;
@@ -46,6 +47,31 @@ public void get1NowBlock() {
4647
Assert.assertFalse(responseContent.get("witness_address").toString().isEmpty());
4748
}
4849

50+
/**
51+
* constructor.
52+
*/
53+
@Test(enabled = true, description = "Get now block from solidity by http")
54+
public void get1NowBlockFromSolidity() {
55+
response = HttpMethed.getNowBlockFromSolidity(httpSoliditynode);
56+
logger.info("code is " + response.getStatusLine().getStatusCode());
57+
Assert.assertEquals(response.getStatusLine().getStatusCode(), 200);
58+
responseContent = HttpMethed.parseResponseContent(response);
59+
blockContent = responseContent;
60+
blockId = responseContent.get("blockID").toString();
61+
HttpMethed.printJsonContent(responseContent);
62+
Assert.assertTrue(responseContent.size() >= 2);
63+
responseContent = HttpMethed.parseStringContent(responseContent.get("block_header").toString());
64+
Assert.assertTrue(responseContent.size() >= 2);
65+
Assert.assertFalse(responseContent.get("witness_signature").toString().isEmpty());
66+
HttpMethed.printJsonContent(responseContent);
67+
responseContent = HttpMethed.parseStringContent(responseContent.get("raw_data").toString());
68+
HttpMethed.printJsonContent(responseContent);
69+
Assert.assertTrue(Integer.parseInt(responseContent.get("number").toString()) > 0);
70+
currentBlockNum = Integer.parseInt(responseContent.get("number").toString());
71+
Assert.assertTrue(Long.parseLong(responseContent.get("timestamp").toString()) > 1550724114000L);
72+
Assert.assertFalse(responseContent.get("witness_address").toString().isEmpty());
73+
}
74+
4975
/**
5076
* constructor.
5177
*/
@@ -58,6 +84,18 @@ public void get2BlockByNum() {
5884

5985
}
6086

87+
/**
88+
* constructor.
89+
*/
90+
@Test(enabled = true, description = "Get block by num from solidity by http")
91+
public void get2BlockByNumFromSolidity() {
92+
response = HttpMethed.getBlockByNumFromSolidity(httpSoliditynode, currentBlockNum);
93+
Assert.assertEquals(response.getStatusLine().getStatusCode(), 200);
94+
responseContent = HttpMethed.parseResponseContent(response);
95+
Assert.assertEquals(responseContent, blockContent);
96+
97+
}
98+
6199
/**
62100
* constructor.
63101
*/
@@ -154,6 +192,19 @@ public void get9NodeInfo() {
154192
Assert.assertTrue(responseContent.getString("configNodeInfo").contains("\"dbVersion\":2"));
155193
}
156194

195+
/**
196+
* constructor.
197+
*/
198+
@Test(enabled = true, description = "Get transaction count by blocknum from solidity by http")
199+
public void getTransactionCountByBlocknumFromSolidity() {
200+
response = HttpMethed.getTransactionCountByBlocknumFromSolidity(httpSoliditynode, currentBlockNum);
201+
Assert.assertEquals(response.getStatusLine().getStatusCode(), 200);
202+
responseContent = HttpMethed.parseResponseContent(response);
203+
HttpMethed.printJsonContent(responseContent);
204+
Assert.assertTrue(responseContent.size() == 1);
205+
Assert.assertTrue(Integer.parseInt(responseContent.get("count").toString()) >= 0);
206+
}
207+
157208
/**
158209
* constructor.
159210
*/

‎src/test/java/stest/tron/wallet/dailybuild/http/HttpTestExchange001.java‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ public class HttpTestExchange001 {
2424
private HttpResponse response;
2525
private String httpnode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list")
2626
.get(1);
27+
private String httpSoliditynode = Configuration.getByPath("testng.conf").getStringList("httpnode.ip.list").get(2);
2728

2829
ECKey ecKey1 = new ECKey(Utils.getRandom());
2930
byte[] exchangeOwnerAddress = ecKey1.getAddress();
@@ -114,6 +115,19 @@ public void test2ListExchange() {
114115
exchangeId = jsonArray.size();
115116
}
116117

118+
/**
119+
* constructor.
120+
*/
121+
@Test(enabled = true, description = "List exchanges from solidity by http")
122+
public void test2ListExchangeFromSolidity() {
123+
response = HttpMethed.listExchangesFromSolidity(httpSoliditynode);
124+
responseContent = HttpMethed.parseResponseContent(response);
125+
HttpMethed.printJsonContent(responseContent);
126+
JSONArray jsonArray = JSONArray.parseArray(responseContent.getString("exchanges"));
127+
Assert.assertTrue(jsonArray.size() >= 1);
128+
exchangeId = jsonArray.size();
129+
}
130+
117131
/**
118132
* constructor.
119133
*/
@@ -130,6 +144,22 @@ public void test3GetExchangeById() {
130144
logger.info("beforeInjectBalance" + beforeInjectBalance);
131145
}
132146

147+
/**
148+
* constructor.
149+
*/
150+
@Test(enabled = true, description = "GetExchangeById from solidity by http")
151+
public void test3GetExchangeByIdFromSolidity() {
152+
response = HttpMethed.getExchangeByIdFromSolidity(httpSoliditynode, exchangeId);
153+
responseContent = HttpMethed.parseResponseContent(response);
154+
HttpMethed.printJsonContent(responseContent);
155+
Assert.assertTrue(responseContent.getInteger("exchange_id") == exchangeId);
156+
Assert.assertEquals(responseContent.getString("creator_address"),
157+
ByteArray.toHexString(exchangeOwnerAddress));
158+
beforeInjectBalance = responseContent.getLong("first_token_balance");
159+
160+
logger.info("beforeInjectBalance" + beforeInjectBalance);
161+
}
162+
133163
/**
134164
* constructor.
135165
*/
@@ -204,6 +234,18 @@ public void test7GetAssetIssueListByName() {
204234
Assert.assertTrue(jsonArray.size() >= 2);
205235
}
206236

237+
/**
238+
* constructor.
239+
*/
240+
@Test(enabled = true, description = "Get asset issue list by name from solidity by http")
241+
public void test7GetAssetIssueListByNameFromSolidity() {
242+
response = HttpMethed.getAssetIssueListByNameFromSolidity(httpSoliditynode, name);
243+
responseContent = HttpMethed.parseResponseContent(response);
244+
HttpMethed.printJsonContent(responseContent);
245+
JSONArray jsonArray = JSONArray.parseArray(responseContent.get("assetIssue").toString());
246+
Assert.assertTrue(jsonArray.size() >= 2);
247+
}
248+
207249
/**
208250
* * constructor. *
209251
*/

0 commit comments

Comments
 (0)