Skip to content

Commit 2c681de

Browse files
author
wangqqqqq
committed
Add 3.6.6 test case
1 parent fbc6fe6 commit 2c681de

16 files changed

Lines changed: 2597 additions & 10 deletions

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

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3547,6 +3547,7 @@ public static HttpResponse updateBrokerage(String httpNode, byte[] ownerAddress,
35473547
JsonObject userBaseObj2 = new JsonObject();
35483548
userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress));
35493549
userBaseObj2.addProperty("brokerage", brokerage);
3550+
logger.info("userBaseObj2:" + userBaseObj2);
35503551
response = createConnect(requestUrl, userBaseObj2);
35513552
transactionString = EntityUtils.toString(response.getEntity());
35523553
transactionSignString = gettransactionsign(httpNode, transactionString, fromKey);
@@ -3559,6 +3560,35 @@ public static HttpResponse updateBrokerage(String httpNode, byte[] ownerAddress,
35593560
return response;
35603561
}
35613562

3563+
/**
3564+
* constructor.
3565+
*/
3566+
public static HttpResponse updateBrokerageOnVisible(String httpNode, byte[] ownerAddress,
3567+
Long brokerage,
3568+
String fromKey, String visible) {
3569+
try {
3570+
final String requestUrl = "http://" + httpNode + "/wallet/updateBrokerage";
3571+
JsonObject userBaseObj2 = new JsonObject();
3572+
userBaseObj2.addProperty("brokerage", brokerage);
3573+
if (visible.equals("true")) {
3574+
userBaseObj2.addProperty("owner_address", Base58.encode58Check(ownerAddress));
3575+
} else if (visible.equals("false")) {
3576+
userBaseObj2.addProperty("owner_address", ByteArray.toHexString(ownerAddress));
3577+
}
3578+
userBaseObj2.addProperty("visible", visible);
3579+
response = createConnect(requestUrl, userBaseObj2);
3580+
logger.info("userBaseObj2:" + userBaseObj2);
3581+
transactionString = EntityUtils.toString(response.getEntity());
3582+
transactionSignString = gettransactionsign(httpNode, transactionString, fromKey);
3583+
response = broadcastTransaction(httpNode, transactionSignString);
3584+
} catch (Exception e) {
3585+
e.printStackTrace();
3586+
httppost.releaseConnection();
3587+
return null;
3588+
}
3589+
return response;
3590+
}
3591+
35623592
/**
35633593
* constructor.
35643594
*/
@@ -3567,6 +3597,7 @@ public static HttpResponse getReward(String httpNode, byte[] address) {
35673597
String requestUrl = "http://" + httpNode + "/wallet/getReward";
35683598
JsonObject userBaseObj2 = new JsonObject();
35693599
userBaseObj2.addProperty("address", ByteArray.toHexString(address));
3600+
logger.info("userBaseObj2:" + userBaseObj2);
35703601
response = createConnect(requestUrl, userBaseObj2);
35713602
} catch (Exception e) {
35723603
e.printStackTrace();
@@ -3584,6 +3615,7 @@ public static HttpResponse getRewardFromSolidity(String httpSolidityNode, byte[]
35843615
String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getReward";
35853616
JsonObject userBaseObj2 = new JsonObject();
35863617
userBaseObj2.addProperty("address", ByteArray.toHexString(address));
3618+
logger.info("userBaseObj2:" + userBaseObj2);
35873619
response = createConnect(requestUrl, userBaseObj2);
35883620
} catch (Exception e) {
35893621
e.printStackTrace();
@@ -3601,6 +3633,7 @@ public static HttpResponse getBrokerage(String httpNode, byte[] address) {
36013633
String requestUrl = "http://" + httpNode + "/wallet/getBrokerage";
36023634
JsonObject userBaseObj2 = new JsonObject();
36033635
userBaseObj2.addProperty("address", ByteArray.toHexString(address));
3636+
logger.info("userBaseObj2:" + userBaseObj2);
36043637
response = createConnect(requestUrl, userBaseObj2);
36053638
} catch (Exception e) {
36063639
e.printStackTrace();
@@ -3618,6 +3651,102 @@ public static HttpResponse getBrokerageFromSolidity(String httpSolidityNode, byt
36183651
String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getBrokerage";
36193652
JsonObject userBaseObj2 = new JsonObject();
36203653
userBaseObj2.addProperty("address", ByteArray.toHexString(address));
3654+
logger.info("userBaseObj2:" + userBaseObj2);
3655+
response = createConnect(requestUrl, userBaseObj2);
3656+
} catch (Exception e) {
3657+
e.printStackTrace();
3658+
httppost.releaseConnection();
3659+
return null;
3660+
}
3661+
return response;
3662+
}
3663+
3664+
/**
3665+
* constructor.
3666+
*/
3667+
public static HttpResponse getRewardOnVisible(String httpNode, byte[] address, String visible) {
3668+
try {
3669+
String requestUrl = "http://" + httpNode + "/wallet/getReward";
3670+
JsonObject userBaseObj2 = new JsonObject();
3671+
if (visible.equals("true")) {
3672+
userBaseObj2.addProperty("address", Base58.encode58Check(address));
3673+
} else if (visible.equals("false")) {
3674+
userBaseObj2.addProperty("address", ByteArray.toHexString(address));
3675+
}
3676+
userBaseObj2.addProperty("visible", visible);
3677+
logger.info("userBaseObj2:" + userBaseObj2);
3678+
response = createConnect(requestUrl, userBaseObj2);
3679+
} catch (Exception e) {
3680+
e.printStackTrace();
3681+
httppost.releaseConnection();
3682+
return null;
3683+
}
3684+
return response;
3685+
}
3686+
3687+
/**
3688+
* constructor.
3689+
*/
3690+
public static HttpResponse getRewardFromSolidityOnVisible(String httpSolidityNode, byte[] address,
3691+
String visible) {
3692+
try {
3693+
String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getReward";
3694+
JsonObject userBaseObj2 = new JsonObject();
3695+
if (visible.equals("true")) {
3696+
userBaseObj2.addProperty("address", Base58.encode58Check(address));
3697+
} else if (visible.equals("false")) {
3698+
userBaseObj2.addProperty("address", ByteArray.toHexString(address));
3699+
}
3700+
userBaseObj2.addProperty("visible", visible);
3701+
logger.info("userBaseObj2:" + userBaseObj2);
3702+
response = createConnect(requestUrl, userBaseObj2);
3703+
} catch (Exception e) {
3704+
e.printStackTrace();
3705+
httppost.releaseConnection();
3706+
return null;
3707+
}
3708+
return response;
3709+
}
3710+
3711+
/**
3712+
* constructor.
3713+
*/
3714+
public static HttpResponse getBrokerageOnVisible(String httpNode, byte[] address,
3715+
String visible) {
3716+
try {
3717+
String requestUrl = "http://" + httpNode + "/wallet/getBrokerage";
3718+
JsonObject userBaseObj2 = new JsonObject();
3719+
if (visible.equals("true")) {
3720+
userBaseObj2.addProperty("address", Base58.encode58Check(address));
3721+
} else if (visible.equals("false")) {
3722+
userBaseObj2.addProperty("address", ByteArray.toHexString(address));
3723+
}
3724+
userBaseObj2.addProperty("visible", visible);
3725+
logger.info("userBaseObj2:" + userBaseObj2);
3726+
response = createConnect(requestUrl, userBaseObj2);
3727+
} catch (Exception e) {
3728+
e.printStackTrace();
3729+
httppost.releaseConnection();
3730+
return null;
3731+
}
3732+
return response;
3733+
}
3734+
3735+
/**
3736+
* constructor.
3737+
*/
3738+
public static HttpResponse getBrokerageFromSolidityOnVisible(String httpSolidityNode,
3739+
byte[] address, String visible) {
3740+
try {
3741+
String requestUrl = "http://" + httpSolidityNode + "/walletsolidity/getBrokerage";
3742+
JsonObject userBaseObj2 = new JsonObject();
3743+
if (visible.equals("true")) {
3744+
userBaseObj2.addProperty("address", Base58.encode58Check(address));
3745+
} else if (visible.equals("false")) {
3746+
userBaseObj2.addProperty("address", ByteArray.toHexString(address));
3747+
}
3748+
userBaseObj2.addProperty("visible", visible);
3749+
logger.info("userBaseObj2:" + userBaseObj2);
36213750
response = createConnect(requestUrl, userBaseObj2);
36223751
} catch (Exception e) {
36233752
e.printStackTrace();

framework/src/test/java/stest/tron/wallet/dailybuild/http/HttpTestMortgageMechanism01.java

Lines changed: 86 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
import org.junit.Assert;
88
import org.testng.annotations.AfterClass;
99
import org.testng.annotations.Test;
10+
import org.tron.common.crypto.ECKey;
11+
import org.tron.common.utils.ByteArray;
12+
import org.tron.common.utils.Utils;
1013
import stest.tron.wallet.common.client.Configuration;
1114
import stest.tron.wallet.common.client.utils.HttpMethed;
1215
import stest.tron.wallet.common.client.utils.PublicMethed;
@@ -21,6 +24,9 @@ public class HttpTestMortgageMechanism01 {
2124
private final String witnessKey = Configuration.getByPath("testng.conf")
2225
.getString("witness.key1");
2326
private final byte[] witnessAddress = PublicMethed.getFinalAddress(witnessKey);
27+
private final String witnessKey2 = Configuration.getByPath("testng.conf")
28+
.getString("witness.key2");
29+
private final byte[] witnessAddress2 = PublicMethed.getFinalAddress(witnessKey2);
2430
Long amount = 2048000000L;
2531
String description = Configuration.getByPath("testng.conf")
2632
.getString("defaultParameter.assetDescription");
@@ -32,6 +38,9 @@ public class HttpTestMortgageMechanism01 {
3238
.get(1);
3339
private String httpSoliditynode = Configuration.getByPath("testng.conf")
3440
.getStringList("httpnode.ip.list").get(2);
41+
private ECKey ecKey1 = new ECKey(Utils.getRandom());
42+
private byte[] dev001Address = ecKey1.getAddress();
43+
private String dev001Key = ByteArray.toHexString(ecKey1.getPrivKeyBytes());
3544

3645
/**
3746
* constructor.
@@ -42,18 +51,39 @@ public void test01GetBrokerage() {
4251
responseContent = HttpMethed.parseResponseContent(response);
4352
HttpMethed.printJsonContent(responseContent);
4453
Assert.assertEquals("20", responseContent.getString("brokerage"));
54+
55+
response = HttpMethed.getBrokerageOnVisible(httpnode, witnessAddress2, "true");
56+
responseContent = HttpMethed.parseResponseContent(response);
57+
HttpMethed.printJsonContent(responseContent);
58+
Assert.assertEquals("20", responseContent.getString("brokerage"));
59+
60+
response = HttpMethed.getBrokerageOnVisible(httpnode, fromAddress, "false");
61+
responseContent = HttpMethed.parseResponseContent(response);
62+
HttpMethed.printJsonContent(responseContent);
63+
Assert.assertEquals("20", responseContent.getString("brokerage"));
4564
}
4665

47-
/**
48-
* constructor.
49-
*/
5066
@Test(enabled = true, description = "GetBrokerage from solidity by http")
5167
public void test02GetBrokerageFromSolidity() {
5268
HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode);
5369
response = HttpMethed.getBrokerageFromSolidity(httpSoliditynode, witnessAddress);
5470
responseContent = HttpMethed.parseResponseContent(response);
5571
HttpMethed.printJsonContent(responseContent);
5672
Assert.assertEquals("20", responseContent.getString("brokerage"));
73+
74+
HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode);
75+
response = HttpMethed
76+
.getBrokerageFromSolidityOnVisible(httpSoliditynode, witnessAddress2, "true");
77+
responseContent = HttpMethed.parseResponseContent(response);
78+
HttpMethed.printJsonContent(responseContent);
79+
Assert.assertEquals("20", responseContent.getString("brokerage"));
80+
81+
HttpMethed.waitToProduceOneBlockFromSolidity(httpnode, httpSoliditynode);
82+
response = HttpMethed
83+
.getBrokerageFromSolidityOnVisible(httpSoliditynode, fromAddress, "false");
84+
responseContent = HttpMethed.parseResponseContent(response);
85+
HttpMethed.printJsonContent(responseContent);
86+
Assert.assertEquals("20", responseContent.getString("brokerage"));
5787
}
5888

5989
/**
@@ -66,9 +96,35 @@ public void test03UpdateBrokerage() {
6696
HttpMethed.waitToProduceOneBlock(httpnode);
6797

6898
//update brokerage
69-
response = HttpMethed.updateBrokerage(httpnode, witnessAddress, 30L, witnessKey);
99+
response = HttpMethed.updateBrokerage(httpnode, witnessAddress, 11L, witnessKey);
100+
Assert.assertTrue(HttpMethed.verificationResult(response));
101+
HttpMethed.waitToProduceOneBlock(httpnode);
102+
103+
response = HttpMethed.sendCoin(httpnode, fromAddress, witnessAddress2, amount, testKey002);
70104
Assert.assertTrue(HttpMethed.verificationResult(response));
71105
HttpMethed.waitToProduceOneBlock(httpnode);
106+
107+
//update brokerage onvisible true
108+
response = HttpMethed
109+
.updateBrokerageOnVisible(httpnode, witnessAddress2, 24L, witnessKey2, "true");
110+
Assert.assertTrue(HttpMethed.verificationResult(response));
111+
HttpMethed.waitToProduceOneBlock(httpnode);
112+
113+
//update brokerage onvisible false
114+
response = HttpMethed
115+
.updateBrokerageOnVisible(httpnode, witnessAddress, 88L, witnessKey, "false");
116+
Assert.assertTrue(HttpMethed.verificationResult(response));
117+
HttpMethed.waitToProduceOneBlock(httpnode);
118+
119+
//update brokerage onvisible false for notwitness
120+
response = HttpMethed.sendCoin(httpnode, fromAddress, dev001Address, amount, testKey002);
121+
Assert.assertTrue(HttpMethed.verificationResult(response));
122+
HttpMethed.waitToProduceOneBlock(httpnode);
123+
124+
response = HttpMethed
125+
.updateBrokerageOnVisible(httpnode, dev001Address, 78L, dev001Key, "true");
126+
Assert.assertFalse(HttpMethed.verificationResult(response));
127+
HttpMethed.waitToProduceOneBlock(httpnode);
72128
}
73129

74130
/**
@@ -79,9 +135,19 @@ public void test04GetReward() {
79135
response = HttpMethed.getReward(httpnode, witnessAddress);
80136
responseContent = HttpMethed.parseResponseContent(response);
81137
HttpMethed.printJsonContent(responseContent);
82-
Assert.assertTrue((
83-
new BigInteger(responseContent.getString("reward")).compareTo(new BigInteger("0")) == 0)
84-
|| (new BigInteger(responseContent.getString("reward"))
138+
Assert.assertTrue((new BigInteger(responseContent.getString("reward"))
139+
.compareTo(new BigInteger("0"))) == 1);
140+
141+
response = HttpMethed.getRewardOnVisible(httpnode, witnessAddress2, "true");
142+
responseContent = HttpMethed.parseResponseContent(response);
143+
HttpMethed.printJsonContent(responseContent);
144+
Assert.assertTrue((new BigInteger(responseContent.getString("reward"))
145+
.compareTo(new BigInteger("0"))) == 1);
146+
147+
response = HttpMethed.getRewardOnVisible(httpnode, witnessAddress, "false");
148+
responseContent = HttpMethed.parseResponseContent(response);
149+
HttpMethed.printJsonContent(responseContent);
150+
Assert.assertTrue((new BigInteger(responseContent.getString("reward"))
85151
.compareTo(new BigInteger("0"))) == 1);
86152
}
87153

@@ -93,9 +159,19 @@ public void test05GetRewardFromSolidity() {
93159
response = HttpMethed.getRewardFromSolidity(httpSoliditynode, witnessAddress);
94160
responseContent = HttpMethed.parseResponseContent(response);
95161
HttpMethed.printJsonContent(responseContent);
96-
Assert.assertTrue((
97-
new BigInteger(responseContent.getString("reward")).compareTo(new BigInteger("0")) == 0)
98-
|| (new BigInteger(responseContent.getString("reward"))
162+
Assert.assertTrue((new BigInteger(responseContent.getString("reward"))
163+
.compareTo(new BigInteger("0"))) == 1);
164+
165+
response = HttpMethed.getRewardFromSolidityOnVisible(httpSoliditynode, witnessAddress, "true");
166+
responseContent = HttpMethed.parseResponseContent(response);
167+
HttpMethed.printJsonContent(responseContent);
168+
Assert.assertTrue((new BigInteger(responseContent.getString("reward"))
169+
.compareTo(new BigInteger("0"))) == 1);
170+
171+
response = HttpMethed.getRewardFromSolidityOnVisible(httpSoliditynode, witnessAddress, "false");
172+
responseContent = HttpMethed.parseResponseContent(response);
173+
HttpMethed.printJsonContent(responseContent);
174+
Assert.assertTrue((new BigInteger(responseContent.getString("reward"))
99175
.compareTo(new BigInteger("0"))) == 1);
100176
}
101177

0 commit comments

Comments
 (0)