Skip to content

Commit de0c79c

Browse files
authored
Merge pull request tronprotocol#2181 from tronprotocol/stest_add_deferred_transaction_cases
Stest add deferred transaction cases
2 parents 51df34b + 292f628 commit de0c79c

23 files changed

Lines changed: 3910 additions & 24 deletions

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

Lines changed: 199 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,34 @@ public static HttpResponse updateAccount(String httpNode, byte[] updateAccountAd
7070
return response;
7171
}
7272

73+
/**
74+
* constructor.
75+
*/
76+
public static HttpResponse setAccountId(String httpNode, byte[] setAccountIdAddress,
77+
String accountId, Boolean visable, String fromKey) {
78+
try {
79+
final String requestUrl = "http://" + httpNode + "/wallet/setaccountid";
80+
JsonObject userBaseObj2 = new JsonObject();
81+
userBaseObj2.addProperty("account_id", accountId);
82+
userBaseObj2.addProperty("owner_address",
83+
Base58.encode58Check(PublicMethed.getFinalAddress(fromKey)));
84+
userBaseObj2.addProperty("visible",visable);
85+
response = createConnect(requestUrl, userBaseObj2);
86+
transactionString = EntityUtils.toString(response.getEntity());
87+
transactionSignString = gettransactionsign(httpNode, transactionString, fromKey);
88+
logger.info(transactionString);
89+
logger.info(transactionSignString);
90+
response = broadcastTransaction(httpNode, transactionSignString);
91+
} catch (Exception e) {
92+
e.printStackTrace();
93+
httppost.releaseConnection();
94+
return null;
95+
}
96+
return response;
97+
}
98+
99+
100+
73101
/**
74102
* constructor.
75103
*/
@@ -213,13 +241,14 @@ public static HttpResponse sendCoin(String httpNode, byte[] fromAddress, byte[]
213241
* constructor.
214242
*/
215243
public static HttpResponse sendCoin(String httpNode, byte[] fromAddress, byte[] toAddress,
216-
Long amount, String[] managerKeys) {
244+
Long amount, Integer permissionId,String[] managerKeys) {
217245
try {
218246
final String requestUrl = "http://" + httpNode + "/wallet/createtransaction";
219247
JsonObject userBaseObj2 = new JsonObject();
220248
userBaseObj2.addProperty("to_address", ByteArray.toHexString(toAddress));
221249
userBaseObj2.addProperty("owner_address", ByteArray.toHexString(fromAddress));
222250
userBaseObj2.addProperty("amount", amount);
251+
userBaseObj2.addProperty("Permission_id",permissionId);
223252
response = createConnect(requestUrl, userBaseObj2);
224253
transactionSignString = EntityUtils.toString(response.getEntity());
225254
HttpResponse getSignWeightResponse;
@@ -601,6 +630,8 @@ public static String deployContractGetTxid(String httpNode, String name, String
601630
userBaseObj2.addProperty("token_id", tokenId);
602631
userBaseObj2.addProperty("call_token_value", tokenValue);
603632
userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress));
633+
634+
604635
logger.info(userBaseObj2.toString());
605636
response = createConnect(requestUrl, userBaseObj2);
606637
transactionString = EntityUtils.toString(response.getEntity());
@@ -617,6 +648,46 @@ public static String deployContractGetTxid(String httpNode, String name, String
617648
return responseContent.getString("txID");
618649
}
619650

651+
/**
652+
* constructor.
653+
*/
654+
public static HttpResponse deployContractGetTxidWithTooBigLong(String httpNode, String name,
655+
String abi, String bytecode, Long bandwidthLimit, Long feeLimit,
656+
Integer consumeUserResourcePercent, Long originEnergyLimit, Long callValue, Integer tokenId,
657+
Long tokenValue, byte[] ownerAddress, String fromKey) {
658+
try {
659+
final String requestUrl = "http://" + httpNode + "/wallet/deploycontract";
660+
661+
String text = "{\"call_token_value\": 10000000e100000000}";
662+
JSONObject jsonObject = JSONObject.parseObject(text);
663+
logger.info("jsonObject: " + jsonObject.toString());
664+
jsonObject.put("name", name);
665+
jsonObject.put("abi", abi);
666+
jsonObject.put("bytecode", bytecode);
667+
jsonObject.put("bandwidth_limit", bandwidthLimit);
668+
jsonObject.put("fee_limit", feeLimit);
669+
jsonObject.put("consume_user_resource_percent", consumeUserResourcePercent);
670+
jsonObject.put("origin_energy_limit", originEnergyLimit);
671+
jsonObject.put("call_value", callValue);
672+
jsonObject.put("token_id", tokenId);
673+
jsonObject.put("owner_address", ByteArray.toHexString(ownerAddress));
674+
675+
logger.info(jsonObject.toString());
676+
response = createConnect1(requestUrl,jsonObject);
677+
/* transactionString = EntityUtils.toString(response.getEntity());
678+
logger.info(transactionString);
679+
transactionSignString = gettransactionsign(httpNode, transactionString, fromKey);
680+
logger.info(transactionSignString);
681+
response = broadcastTransaction(httpNode, transactionSignString);*/
682+
} catch (Exception e) {
683+
e.printStackTrace();
684+
httppost.releaseConnection();
685+
return null;
686+
}
687+
return response;
688+
}
689+
690+
620691

621692
/**
622693
* constructor.
@@ -869,6 +940,44 @@ public static HttpResponse broadcastTransaction(String httpNode, String transact
869940
return response;
870941
}
871942

943+
/**
944+
* constructor.
945+
*/
946+
public static HttpResponse getAccountById(String httpNode, String accountId, Boolean visable) {
947+
try {
948+
String requestUrl = "http://" + httpNode + "/wallet/getaccountbyid";
949+
JsonObject userBaseObj2 = new JsonObject();
950+
userBaseObj2.addProperty("account_id", accountId);
951+
userBaseObj2.addProperty("visible",visable);
952+
response = createConnect(requestUrl, userBaseObj2);
953+
} catch (Exception e) {
954+
e.printStackTrace();
955+
httppost.releaseConnection();
956+
return null;
957+
}
958+
return response;
959+
}
960+
961+
/**
962+
* constructor.
963+
*/
964+
public static HttpResponse getAccountByIdFromSolidity(String httpSolidityNode, String accountId,
965+
Boolean visable) {
966+
try {
967+
String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getaccountbyid";
968+
JsonObject userBaseObj2 = new JsonObject();
969+
userBaseObj2.addProperty("account_id", accountId);
970+
userBaseObj2.addProperty("visible",visable);
971+
response = createConnect(requestUrl, userBaseObj2);
972+
} catch (Exception e) {
973+
e.printStackTrace();
974+
httppost.releaseConnection();
975+
return null;
976+
}
977+
return response;
978+
}
979+
980+
872981
/**
873982
* constructor.
874983
*/
@@ -1598,6 +1707,27 @@ public static HttpResponse getBlockByLimitNext(String httpNode, Integer startNum
15981707
return response;
15991708
}
16001709

1710+
/**
1711+
* constructor.
1712+
*/
1713+
public static HttpResponse getBlockByLimitNextFromSolidity(String httpNode, Integer startNum,
1714+
Integer endNum) {
1715+
try {
1716+
String requestUrl = "http://" + httpNode + "/walletsolidity/getblockbylimitnext";
1717+
JsonObject userBaseObj2 = new JsonObject();
1718+
userBaseObj2.addProperty("startNum", startNum);
1719+
userBaseObj2.addProperty("endNum", endNum);
1720+
response = createConnect(requestUrl, userBaseObj2);
1721+
} catch (Exception e) {
1722+
e.printStackTrace();
1723+
httppost.releaseConnection();
1724+
return null;
1725+
}
1726+
return response;
1727+
}
1728+
1729+
1730+
16011731
/**
16021732
* constructor.
16031733
*/
@@ -1615,6 +1745,25 @@ public static HttpResponse getBlockByLastNum(String httpNode, Integer num) {
16151745
return response;
16161746
}
16171747

1748+
/**
1749+
* constructor.
1750+
*/
1751+
public static HttpResponse getBlockByLastNumFromSolidity(String httpNode, Integer num) {
1752+
try {
1753+
String requestUrl = "http://" + httpNode + "/walletsolidity/getblockbylatestnum";
1754+
JsonObject userBaseObj2 = new JsonObject();
1755+
userBaseObj2.addProperty("num", num);
1756+
response = createConnect(requestUrl, userBaseObj2);
1757+
} catch (Exception e) {
1758+
e.printStackTrace();
1759+
httppost.releaseConnection();
1760+
return null;
1761+
}
1762+
return response;
1763+
}
1764+
1765+
1766+
16181767
/**
16191768
* constructor.
16201769
*/
@@ -1632,6 +1781,25 @@ public static HttpResponse getBlockById(String httpNode, String blockId) {
16321781
return response;
16331782
}
16341783

1784+
/**
1785+
* constructor.
1786+
*/
1787+
public static HttpResponse getBlockByIdFromSolidity(String httpNode, String blockId) {
1788+
try {
1789+
String requestUrl = "http://" + httpNode + "/walletsolidity/getblockbyid";
1790+
JsonObject userBaseObj2 = new JsonObject();
1791+
userBaseObj2.addProperty("value", blockId);
1792+
response = createConnect(requestUrl, userBaseObj2);
1793+
} catch (Exception e) {
1794+
e.printStackTrace();
1795+
httppost.releaseConnection();
1796+
return null;
1797+
}
1798+
return response;
1799+
}
1800+
1801+
1802+
16351803
/**
16361804
* constructor.
16371805
*/
@@ -1740,6 +1908,36 @@ public static HttpResponse createConnect(String url, JsonObject requestBody) {
17401908
return response;
17411909
}
17421910

1911+
/**
1912+
* constructor.
1913+
*/
1914+
public static HttpResponse createConnect1(String url, JSONObject requestBody) {
1915+
try {
1916+
httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
1917+
connectionTimeout);
1918+
httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, soTimeout);
1919+
httpClient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,
1920+
connectionTimeout * 10000);
1921+
httpClient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, soTimeout * 10000);
1922+
httppost = new HttpPost(url);
1923+
httppost.setHeader("Content-type", "application/json; charset=utf-8");
1924+
httppost.setHeader("Connection", "Close");
1925+
if (requestBody != null) {
1926+
StringEntity entity = new StringEntity(requestBody.toString(), Charset.forName("UTF-8"));
1927+
entity.setContentEncoding("UTF-8");
1928+
entity.setContentType("application/json");
1929+
httppost.setEntity(entity);
1930+
}
1931+
response = httpClient.execute(httppost);
1932+
} catch (Exception e) {
1933+
e.printStackTrace();
1934+
httppost.releaseConnection();
1935+
return null;
1936+
}
1937+
return response;
1938+
}
1939+
1940+
17431941

17441942
/**
17451943
* constructor.

0 commit comments

Comments
 (0)