Skip to content

Commit 395582f

Browse files
Merge pull request #3607 from tronprotocol/test/4.1.2_case
Test/4.1.2 case
2 parents 263892c + 024bbb3 commit 395582f

18 files changed

+378
-64
lines changed

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

+93
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
import org.tron.api.GrpcAPI.TransactionExtention;
3737
import org.tron.api.GrpcAPI.TransactionSignWeight;
3838
import org.tron.api.WalletGrpc;
39+
import org.tron.api.WalletGrpc.WalletBlockingStub;
3940
import org.tron.api.WalletSolidityGrpc;
4041
import org.tron.common.crypto.ECKey;
4142
import org.tron.common.crypto.ECKey.ECDSASignature;
@@ -74,6 +75,7 @@
7475
import org.tron.protos.contract.ExchangeContract.ExchangeInjectContract;
7576
import org.tron.protos.contract.ExchangeContract.ExchangeTransactionContract;
7677
import org.tron.protos.contract.ExchangeContract.ExchangeWithdrawContract;
78+
import org.tron.protos.contract.MarketContract;
7779
import org.tron.protos.contract.ProposalContract.ProposalApproveContract;
7880
import org.tron.protos.contract.ProposalContract.ProposalCreateContract;
7981
import org.tron.protos.contract.ProposalContract.ProposalDeleteContract;
@@ -5239,4 +5241,95 @@ public static boolean updateBrokerage(byte[] owner, int brokerage, String priKey
52395241

52405242
return broadcastTransaction(transaction, blockingStubFull);
52415243
}
5244+
5245+
/**
5246+
* constructor.
5247+
*/
5248+
public static boolean marketSellAsset(byte[] owner, byte[] sellTokenId,
5249+
long sellTokenQuantity, byte[] buyTokenId, long buyTokenQuantity,
5250+
int permissionId, String[] priKeys, WalletBlockingStub blockingStubFull) {
5251+
5252+
MarketContract.MarketSellAssetContract.Builder builder = MarketContract.MarketSellAssetContract
5253+
.newBuilder();
5254+
builder
5255+
.setOwnerAddress(ByteString.copyFrom(owner))
5256+
.setSellTokenId(ByteString.copyFrom(sellTokenId))
5257+
.setSellTokenQuantity(sellTokenQuantity)
5258+
.setBuyTokenId(ByteString.copyFrom(buyTokenId))
5259+
.setBuyTokenQuantity(buyTokenQuantity);
5260+
5261+
TransactionExtention transactionExtention = blockingStubFull.marketSellAsset(builder.build());
5262+
if (transactionExtention == null) {
5263+
return false;
5264+
}
5265+
Return ret = transactionExtention.getResult();
5266+
if (!ret.getResult()) {
5267+
System.out.println("Code = " + ret.getCode());
5268+
System.out.println("Message = " + ret.getMessage().toStringUtf8());
5269+
return false;
5270+
}
5271+
Transaction transaction = transactionExtention.getTransaction();
5272+
if (transaction == null || transaction.getRawData().getContractCount() == 0) {
5273+
System.out.println("Transaction is empty");
5274+
return false;
5275+
}
5276+
5277+
if (transaction.getRawData().getContract(0).getType()
5278+
!= ContractType.MarketSellAssetContract) {
5279+
return false;
5280+
}
5281+
5282+
try {
5283+
transaction = setPermissionId(transaction, permissionId);
5284+
transaction = signTransaction(transaction, blockingStubFull, priKeys);
5285+
} catch (CancelException e) {
5286+
e.printStackTrace();
5287+
}
5288+
return broadcastTransaction(transaction, blockingStubFull);
5289+
5290+
}
5291+
5292+
/**
5293+
* constructor.
5294+
*/
5295+
public static boolean marketCancelOrder(byte[] owner, byte[] orderId,
5296+
int permissionId, String[] priKeys,
5297+
WalletBlockingStub blockingStubFull) {
5298+
5299+
MarketContract.MarketCancelOrderContract.Builder builder = MarketContract
5300+
.MarketCancelOrderContract.newBuilder();
5301+
builder.setOwnerAddress(ByteString.copyFrom(owner)).setOrderId(ByteString.copyFrom(orderId));
5302+
5303+
TransactionExtention transactionExtention = blockingStubFull.marketCancelOrder(builder.build());
5304+
5305+
if (transactionExtention == null) {
5306+
return false;
5307+
}
5308+
Return ret = transactionExtention.getResult();
5309+
if (!ret.getResult()) {
5310+
System.out.println("Code = " + ret.getCode());
5311+
System.out.println("Message = " + ret.getMessage().toStringUtf8());
5312+
return false;
5313+
}
5314+
Transaction transaction = transactionExtention.getTransaction();
5315+
if (transaction == null || transaction.getRawData().getContractCount() == 0) {
5316+
System.out.println("Transaction is empty");
5317+
return false;
5318+
}
5319+
5320+
if (transaction.getRawData().getContract(0).getType()
5321+
!= ContractType.MarketCancelOrderContract) {
5322+
System.out.println("Wrong ContractType :"
5323+
+ transaction.getRawData().getContract(0).getType());
5324+
return false;
5325+
}
5326+
5327+
try {
5328+
transaction = setPermissionId(transaction, permissionId);
5329+
transaction = signTransaction(transaction,blockingStubFull,priKeys);
5330+
} catch (CancelException e) {
5331+
e.printStackTrace();
5332+
}
5333+
return broadcastTransaction(transaction, blockingStubFull);
5334+
}
52425335
}

framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign017.java framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/MutiSignAccountPermissionUpdateTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign;
2424

2525
@Slf4j
26-
public class WalletTestMutiSign017 {
26+
public class MutiSignAccountPermissionUpdateTest {
2727

2828
private static final long now = System.currentTimeMillis();
2929
private static final long totalSupply = now;
@@ -75,15 +75,15 @@ public void beforeSuite() {
7575
* constructor.
7676
*/
7777

78-
@BeforeClass(enabled = false)
78+
@BeforeClass(enabled = true)
7979
public void beforeClass() {
8080
channelFull = ManagedChannelBuilder.forTarget(fullnode)
8181
.usePlaintext(true)
8282
.build();
8383
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
8484
}
8585

86-
@Test(enabled = false)
86+
@Test(enabled = true)
8787
public void testMutiSign1UpdatePermission() {
8888
ecKey1 = new ECKey(Utils.getRandom());
8989
manager1Address = ecKey1.getAddress();
@@ -185,7 +185,7 @@ public void testMutiSign1UpdatePermission() {
185185
/**
186186
* constructor.
187187
*/
188-
@AfterClass(enabled = false)
188+
@AfterClass(enabled = true)
189189
public void shutdown() throws InterruptedException {
190190
if (channelFull != null) {
191191
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);

framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign011.java framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/MutiSignAccountPermissionUpdateTest002.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign;
2424

2525
@Slf4j
26-
public class WalletTestMutiSign011 {
26+
public class MutiSignAccountPermissionUpdateTest002 {
2727

2828
private static final long now = System.currentTimeMillis();
2929
private static final long totalSupply = now;
@@ -75,15 +75,15 @@ public void beforeSuite() {
7575
* constructor.
7676
*/
7777

78-
@BeforeClass(enabled = false)
78+
@BeforeClass(enabled = true)
7979
public void beforeClass() {
8080
channelFull = ManagedChannelBuilder.forTarget(fullnode)
8181
.usePlaintext(true)
8282
.build();
8383
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
8484
}
8585

86-
@Test(enabled = false)
86+
@Test(enabled = true)
8787
public void testMutiSign1UpdatePermission() {
8888
ecKey1 = new ECKey(Utils.getRandom());
8989
manager1Address = ecKey1.getAddress();
@@ -185,7 +185,7 @@ public void testMutiSign1UpdatePermission() {
185185
/**
186186
* constructor.
187187
*/
188-
@AfterClass(enabled = false)
188+
@AfterClass(enabled = true)
189189
public void shutdown() throws InterruptedException {
190190
if (channelFull != null) {
191191
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);

framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign013.java framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/MutiSignAccountTest.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign;
2727

2828
@Slf4j
29-
public class WalletTestMutiSign013 {
29+
public class MutiSignAccountTest {
3030

3131
private final String testKey002 = Configuration.getByPath("testng.conf")
3232
.getString("foundationAccount.key1");
@@ -83,15 +83,15 @@ public void beforeSuite() {
8383
* constructor.
8484
*/
8585

86-
@BeforeClass(enabled = false)
86+
@BeforeClass(enabled = true)
8787
public void beforeClass() {
8888
channelFull = ManagedChannelBuilder.forTarget(fullnode)
8989
.usePlaintext(true)
9090
.build();
9191
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
9292
}
9393

94-
@Test(enabled = false)
94+
@Test(enabled = true)
9595
public void testMutiSignForAccount() {
9696
ecKey1 = new ECKey(Utils.getRandom());
9797
manager1Address = ecKey1.getAddress();
@@ -210,7 +210,7 @@ public void testMutiSignForAccount() {
210210
/**
211211
* constructor.
212212
*/
213-
@AfterClass(enabled = false)
213+
@AfterClass(enabled = true)
214214
public void shutdown() throws InterruptedException {
215215
if (channelFull != null) {
216216
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);

framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign007.java framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/MutiSignAccountTest002.java

+4-4
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign;
2727

2828
@Slf4j
29-
public class WalletTestMutiSign007 {
29+
public class MutiSignAccountTest002 {
3030

3131
private final String testKey002 = Configuration.getByPath("testng.conf")
3232
.getString("foundationAccount.key1");
@@ -83,15 +83,15 @@ public void beforeSuite() {
8383
* constructor.
8484
*/
8585

86-
@BeforeClass(enabled = false)
86+
@BeforeClass(enabled = true)
8787
public void beforeClass() {
8888
channelFull = ManagedChannelBuilder.forTarget(fullnode)
8989
.usePlaintext(true)
9090
.build();
9191
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
9292
}
9393

94-
@Test(enabled = false)
94+
@Test(enabled = true)
9595
public void testMutiSignForAccount() {
9696
ecKey1 = new ECKey(Utils.getRandom());
9797
manager1Address = ecKey1.getAddress();
@@ -210,7 +210,7 @@ public void testMutiSignForAccount() {
210210
/**
211211
* constructor.
212212
*/
213-
@AfterClass(enabled = false)
213+
@AfterClass(enabled = true)
214214
public void shutdown() throws InterruptedException {
215215
if (channelFull != null) {
216216
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);

framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign012.java framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/MutiSignAssetTest.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign;
2525

2626
@Slf4j
27-
public class WalletTestMutiSign012 {
27+
public class MutiSignAssetTest {
2828

2929
private static final long now = System.currentTimeMillis();
3030
private static final long totalSupply = now;
@@ -76,15 +76,15 @@ public void beforeSuite() {
7676
* constructor.
7777
*/
7878

79-
@BeforeClass(enabled = false)
79+
@BeforeClass(enabled = true)
8080
public void beforeClass() {
8181
channelFull = ManagedChannelBuilder.forTarget(fullnode)
8282
.usePlaintext(true)
8383
.build();
8484
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
8585
}
8686

87-
@Test(enabled = false)
87+
@Test(enabled = true)
8888
public void testMutiSign1CreateAssetissue() {
8989
ecKey1 = new ECKey(Utils.getRandom());
9090
manager1Address = ecKey1.getAddress();
@@ -184,7 +184,7 @@ public void testMutiSign1CreateAssetissue() {
184184
* constructor.
185185
*/
186186

187-
@Test(enabled = false)
187+
@Test(enabled = true)
188188
public void testMutiSign2TransferAssetissue() {
189189
PublicMethed.waitProduceNextBlock(blockingStubFull);
190190
PublicMethed.printAddress(manager1Key);
@@ -222,7 +222,7 @@ public void testMutiSign2TransferAssetissue() {
222222
* constructor.
223223
*/
224224

225-
@Test(enabled = false)
225+
@Test(enabled = true)
226226
public void testMutiSign3ParticipateAssetissue() {
227227
ecKey4 = new ECKey(Utils.getRandom());
228228
participateAddress = ecKey4.getAddress();
@@ -305,7 +305,7 @@ public void testMutiSign3ParticipateAssetissue() {
305305
* constructor.
306306
*/
307307

308-
@Test(enabled = false)
308+
@Test(enabled = true)
309309
public void testMutiSign4updateAssetissue() {
310310
url = "MutiSign001_update_url" + Long.toString(now);
311311
ownerKeyString[0] = ownerKey;
@@ -341,7 +341,7 @@ public void testMutiSign4updateAssetissue() {
341341
/**
342342
* constructor.
343343
*/
344-
@AfterClass(enabled = false)
344+
@AfterClass(enabled = true)
345345
public void shutdown() throws InterruptedException {
346346
if (channelFull != null) {
347347
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);

framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/WalletTestMutiSign006.java framework/src/test/java/stest/tron/wallet/dailybuild/operationupdate/MutiSignAssetTest002.java

+7-7
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
import stest.tron.wallet.common.client.utils.PublicMethedForMutiSign;
2525

2626
@Slf4j
27-
public class WalletTestMutiSign006 {
27+
public class MutiSignAssetTest002 {
2828

2929
private static final long now = System.currentTimeMillis();
3030
private static final long totalSupply = now;
@@ -76,15 +76,15 @@ public void beforeSuite() {
7676
* constructor.
7777
*/
7878

79-
@BeforeClass(enabled = false)
79+
@BeforeClass(enabled = true)
8080
public void beforeClass() {
8181
channelFull = ManagedChannelBuilder.forTarget(fullnode)
8282
.usePlaintext(true)
8383
.build();
8484
blockingStubFull = WalletGrpc.newBlockingStub(channelFull);
8585
}
8686

87-
@Test(enabled = false)
87+
@Test(enabled = true)
8888
public void testMutiSign1CreateAssetissue() {
8989
ecKey1 = new ECKey(Utils.getRandom());
9090
manager1Address = ecKey1.getAddress();
@@ -184,7 +184,7 @@ public void testMutiSign1CreateAssetissue() {
184184
* constructor.
185185
*/
186186

187-
@Test(enabled = false)
187+
@Test(enabled = true)
188188
public void testMutiSign2TransferAssetissue() {
189189
PublicMethed.waitProduceNextBlock(blockingStubFull);
190190
PublicMethed.printAddress(manager1Key);
@@ -222,7 +222,7 @@ public void testMutiSign2TransferAssetissue() {
222222
* constructor.
223223
*/
224224

225-
@Test(enabled = false)
225+
@Test(enabled = true)
226226
public void testMutiSign3ParticipateAssetissue() {
227227
ecKey4 = new ECKey(Utils.getRandom());
228228
participateAddress = ecKey4.getAddress();
@@ -305,7 +305,7 @@ public void testMutiSign3ParticipateAssetissue() {
305305
* constructor.
306306
*/
307307

308-
@Test(enabled = false)
308+
@Test(enabled = true)
309309
public void testMutiSign4updateAssetissue() {
310310
url = "MutiSign001_update_url" + Long.toString(now);
311311
ownerKeyString[0] = ownerKey;
@@ -341,7 +341,7 @@ public void testMutiSign4updateAssetissue() {
341341
/**
342342
* constructor.
343343
*/
344-
@AfterClass(enabled = false)
344+
@AfterClass(enabled = true)
345345
public void shutdown() throws InterruptedException {
346346
if (channelFull != null) {
347347
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);

0 commit comments

Comments
 (0)