Skip to content

Commit 3792da4

Browse files
author
wangzihe
committed
Add permission_id in stest http case
1 parent 43dc00b commit 3792da4

2 files changed

Lines changed: 44 additions & 4 deletions

File tree

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,14 @@ public static HttpResponse sendCoin(String httpNode, byte[] fromAddress, byte[]
240240
* constructor.
241241
*/
242242
public static HttpResponse sendCoin(String httpNode, byte[] fromAddress, byte[] toAddress,
243-
Long amount, String[] managerKeys) {
243+
Long amount, Integer permissionId,String[] managerKeys) {
244244
try {
245245
final String requestUrl = "http://" + httpNode + "/wallet/createtransaction";
246246
JsonObject userBaseObj2 = new JsonObject();
247247
userBaseObj2.addProperty("to_address", ByteArray.toHexString(toAddress));
248248
userBaseObj2.addProperty("owner_address", ByteArray.toHexString(fromAddress));
249249
userBaseObj2.addProperty("amount", amount);
250+
userBaseObj2.addProperty("Permission_id",permissionId);
250251
response = createConnect(requestUrl, userBaseObj2);
251252
transactionSignString = EntityUtils.toString(response.getEntity());
252253
HttpResponse getSignWeightResponse;

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

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,11 @@ public class HttpTestMutiSign001 {
3131
String ownerKey = ByteArray.toHexString(ecKey1.getPrivKeyBytes());
3232
Long amount = 1000000000L;
3333
JsonArray keys = new JsonArray();
34+
JsonArray activeKeys = new JsonArray();
3435
JsonObject manager1Wight = new JsonObject();
3536
JsonObject manager2Wight = new JsonObject();
37+
JsonObject manager3Wight = new JsonObject();
38+
JsonObject manager4Wight = new JsonObject();
3639
JsonObject ownerObject = new JsonObject();
3740
JsonObject witnessObject = new JsonObject();
3841
JsonObject activeObject = new JsonObject();
@@ -45,6 +48,14 @@ public class HttpTestMutiSign001 {
4548
.getString("foundationAccount.key2");
4649
private final byte[] manager2Address = PublicMethed.getFinalAddress(manager2Key);
4750

51+
private final String manager3Key = Configuration.getByPath("testng.conf")
52+
.getString("witness.key1");
53+
private final byte[] manager3Address = PublicMethed.getFinalAddress(manager3Key);
54+
55+
private final String manager4Key = Configuration.getByPath("testng.conf")
56+
.getString("witness.key2");
57+
private final byte[] manager4Address = PublicMethed.getFinalAddress(manager4Key);
58+
4859
/**
4960
* constructor.
5061
*/
@@ -71,12 +82,27 @@ public void test1AccountPermissionUpDate() {
7182
ownerObject.addProperty("threshold", 2);
7283
ownerObject.add("keys", keys);
7384

85+
86+
manager3Wight.addProperty("address", ByteArray.toHexString(manager3Address));
87+
manager3Wight.addProperty("weight", 1);
88+
89+
logger.info(manager3Wight.toString());
90+
manager4Wight.addProperty("address", ByteArray.toHexString(manager4Address));
91+
manager4Wight.addProperty("weight", 1);
92+
93+
logger.info(manager4Wight.toString());
94+
95+
activeKeys.add(manager3Wight);
96+
activeKeys.add(manager4Wight);
97+
98+
99+
74100
activeObject.addProperty("type", 2);
75101
activeObject.addProperty("permission_name", "active0");
76102
activeObject.addProperty("threshold", 2);
77103
activeObject.addProperty("operations",
78104
"7fff1fc0037e0000000000000000000000000000000000000000000000000000");
79-
activeObject.add("keys", keys);
105+
activeObject.add("keys", activeKeys);
80106

81107
response = HttpMethed.accountPermissionUpdate(httpnode, ownerAddress, ownerObject,
82108
witnessObject, activeObject, ownerKey);
@@ -86,17 +112,30 @@ public void test1AccountPermissionUpDate() {
86112
/**
87113
* constructor.
88114
*/
89-
@Test(enabled = true, description = "Add transaction sign by http")
115+
@Test(enabled = true, description = "Add transaction sign by http with permission id")
90116
public void test2AddTransactionSign() {
91117

92118
HttpMethed.waitToProduceOneBlock(httpnode);
93119
String[] permissionKeyString = new String[2];
94120
permissionKeyString[0] = manager1Key;
95121
permissionKeyString[1] = manager2Key;
96122

97-
response = HttpMethed.sendCoin(httpnode, ownerAddress, fromAddress, 10L, permissionKeyString);
123+
String[] permissionKeyActive = new String[2];
124+
permissionKeyActive[0] = manager3Key;
125+
permissionKeyActive[1] = manager4Key;
126+
127+
response = HttpMethed.sendCoin(httpnode, ownerAddress, fromAddress, 10L, 0,permissionKeyString);
98128
Assert.assertTrue(HttpMethed.verificationResult(response));
99129

130+
response = HttpMethed.sendCoin(httpnode, ownerAddress, fromAddress, 12L, 2,permissionKeyActive);
131+
Assert.assertTrue(HttpMethed.verificationResult(response));
132+
133+
response = HttpMethed.sendCoin(httpnode, ownerAddress, fromAddress, 11L, 1,permissionKeyActive);
134+
Assert.assertFalse(HttpMethed.verificationResult(response));
135+
136+
response = HttpMethed.sendCoin(httpnode, ownerAddress, fromAddress, 11L, 3,permissionKeyString);
137+
Assert.assertFalse(HttpMethed.verificationResult(response));
138+
100139

101140
}
102141

0 commit comments

Comments
 (0)