Skip to content

Commit 3c44ed1

Browse files
committed
Merge branch 'shielded_4.0_stest' of https://github.com/tronprotocol/java-tron into shielded_4.0_stest
2 parents fe43ebb + 1ef6fa9 commit 3c44ed1

7 files changed

Lines changed: 1395 additions & 1969 deletions

File tree

framework/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/precompiledcontracts/pedersenHash002.java

Lines changed: 0 additions & 1488 deletions
This file was deleted.

framework/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/precompiledcontracts/verifyTransferProof001.java

Lines changed: 0 additions & 407 deletions
This file was deleted.

framework/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/precompiledcontracts/pedersenHash001.java renamed to framework/src/test/java/stest/tron/wallet/dailybuild/tvmnewcommand/zenProofCommand/pedersenHash001.java

Lines changed: 51 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package stest.tron.wallet.dailybuild.tvmnewcommand.precompiledcontracts;
1+
package stest.tron.wallet.dailybuild.tvmnewcommand.zenProofCommand;
22

33
import io.grpc.ManagedChannel;
44
import io.grpc.ManagedChannelBuilder;
@@ -86,83 +86,74 @@ public void test01DataIsEmpty() {
8686
PublicMethed.waitProduceNextBlock(blockingStubFull);
8787
Optional<TransactionInfo> infoById = PublicMethed
8888
.getTransactionInfoById(txid, blockingStubFull);
89-
Assert.assertEquals(0, infoById.get().getResultValue());
90-
logger.info(
91-
"infoById:" + ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()));
92-
Assert.assertTrue(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())
93-
.equals("0000000000000000000000000000000000000000000000000000000000000001"
94-
+ "0000000000000000000000000000000000000000000000000000000000000040"
95-
+ "0000000000000000000000000000000000000000000000000000000000000020"
96-
+ "0000000000000000000000000000000000000000000000000000000000000000"));
89+
Assert.assertEquals(1, infoById.get().getResultValue());
90+
Assert.assertEquals("FAILED", infoById.get().getResult().toString());
91+
Assert.assertEquals("OUT_OF_ENERGY", infoById.get().getReceipt().getResult().toString());
92+
Assert.assertEquals(1000000000, infoById.get().getFee());
93+
Assert.assertTrue(infoById.get().getResMessage().toStringUtf8()
94+
.contains("Not enough energy for 'SWAP2' operation executing: curInvokeEnergyLimit"));
9795
}
9896

9997
@Test(enabled = true, description = "data length limit")
10098
public void test02DataLengthLimit() {
10199
String method = "test2(bytes)";
102-
txid = PublicMethed
103-
.triggerContract(contractAddress, method,
104-
"\"0000000000000000000000000000000000000000000000000000000000000001"
105-
+ "0000000000000000000000000000000000000000000000000000000000000002\"",
106-
false, 0, maxFeeLimit, contractExcAddress,
107-
contractExcKey, blockingStubFull);
100+
// length:64
101+
String argsStr1 = "\"0000000000000000000000000000000000000000000000000000000000000001"
102+
+ "0000000000000000000000000000000000000000000000000000000000000002\"";
103+
Optional<TransactionInfo> infoById = null;
104+
txid = PublicMethed.triggerContract(contractAddress, method, argsStr1, false, 0, maxFeeLimit,
105+
contractExcAddress, contractExcKey, blockingStubFull);
108106
PublicMethed.waitProduceNextBlock(blockingStubFull);
109-
Optional<TransactionInfo> infoById = PublicMethed
107+
infoById = PublicMethed
108+
.getTransactionInfoById(txid, blockingStubFull);
109+
Assert.assertEquals(1, infoById.get().getResultValue());
110+
Assert.assertEquals("FAILED", infoById.get().getResult().toString());
111+
Assert.assertEquals("OUT_OF_ENERGY", infoById.get().getReceipt().getResult().toString());
112+
Assert.assertEquals(1000000000, infoById.get().getFee());
113+
Assert.assertTrue(infoById.get().getResMessage().toStringUtf8()
114+
.contains("Not enough energy for 'SWAP2' operation executing: curInvokeEnergyLimit"));
115+
116+
// length:128
117+
String argsStr2 = "\"0000000000000000000000000000000000000000000000000000000000000001"
118+
+ "0000000000000000000000000000000000000000000000000000000000000001"
119+
+ "0000000000000000000000000000000000000000000000000000000000000002"
120+
+ "0000000000000000000000000000000000000000000000000000000000000002\"";
121+
txid = PublicMethed.triggerContract(contractAddress, method, argsStr2, false, 0, maxFeeLimit,
122+
contractExcAddress, contractExcKey, blockingStubFull);
123+
PublicMethed.waitProduceNextBlock(blockingStubFull);
124+
infoById = PublicMethed
110125
.getTransactionInfoById(txid, blockingStubFull);
111126
Assert.assertEquals(0, infoById.get().getResultValue());
112-
logger.info(
113-
"infoById:" + ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()));
114-
Assert.assertTrue(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())
115-
.equals("0000000000000000000000000000000000000000000000000000000000000001"
127+
Assert.assertEquals("0000000000000000000000000000000000000000000000000000000000000001"
116128
+ "0000000000000000000000000000000000000000000000000000000000000040"
117129
+ "0000000000000000000000000000000000000000000000000000000000000020"
118-
+ "0000000000000000000000000000000000000000000000000000000000000000"));
130+
+ "7d6b910840eb7b47f76492aca4a3344888b8fa5aab77a49e9445cda718d75040",
131+
ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()));
119132
}
120133

121-
/*
122-
@Test(enabled = true, description = "Trigger precompile multivalidatesign function with incor"
123-
+ "rect data")
124-
public void test02TriggerPrecompileMultivalisignWithIncorrectData() {
125-
List<Object> signatures = new ArrayList<>();
126-
List<Object> addresses = new ArrayList<>();
127-
byte[] hash = Hash.sha3(txid.getBytes());
128-
for (int i = 0; i < 16; i++) {
129-
ECKey key = new ECKey();
130-
byte[] sign = key.sign(hash).toByteArray();
131-
signatures.add(Hex.toHexString(sign));
132-
addresses.add(WalletUtil.encode58Check(key.getAddress()));
133-
}
134-
byte[] sign = new ECKey().sign(Hash.sha3("sdifhsdfihyw888w7".getBytes())).toByteArray();
135-
signatures.set(0, Hex.toHexString(sign));
136-
List<Object> parameters = Arrays.asList("0x" + Hex.toHexString(hash), signatures, addresses);
137-
String argsStr = PublicMethed.parametersString(parameters);
138-
139-
String input = AbiUtil.parseParameters("batchvalidatesign(bytes32,bytes[],address[])", argsStr);
140-
String method = "testArray2(bytes)";
141-
txid = PublicMethed.triggerContractBoth(contractAddress, method,
142-
AbiUtil.parseParameters(method, Arrays.asList(input)), true, 0, maxFeeLimit,
143-
contractExcAddress, contractExcKey, blockingStubFull, blockingStubFull1);
144-
PublicMethed.getTransactionById(txid, blockingStubFull);
145-
PublicMethed.waitProduceNextBlock(blockingStubFull);
134+
@Test(enabled = true, description = "normal")
135+
public void test02Normal() {
136+
String method = "test3(uint32,bytes32,bytes32)";
137+
String argsStr1 = "0000000000000000000000000000000000000000000000000000000000000001"
138+
+ "0000000000000000000000000000000000000000000000000000000000000001"
139+
+ "0000000000000000000000000000000000000000000000000000000000000002";
146140
Optional<TransactionInfo> infoById = null;
147-
infoById = PublicMethed.getTransactionInfoById(txid, blockingStubFull);
141+
txid = PublicMethed.triggerContract(contractAddress, method, argsStr1, true, 0, maxFeeLimit,
142+
contractExcAddress, contractExcKey, blockingStubFull);
143+
PublicMethed.waitProduceNextBlock(blockingStubFull);
144+
infoById = PublicMethed
145+
.getTransactionInfoById(txid, blockingStubFull);
148146
Assert.assertEquals(0, infoById.get().getResultValue());
149-
logger.info(
150-
"infoById:" + ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()));
151-
Assert.assertTrue(ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())
152-
.equals("0000000000000000000000000000000000000000000000000000000000000001"
153-
+ "0000000000000000000000000000000000000000000000000000000000000040"
154-
+ "0000000000000000000000000000000000000000000000000000000000000020"
155-
+ "0001010101010101010101010101010100000000000000000000000000000000"));
156-
}*/
147+
Assert.assertEquals("7d6b910840eb7b47f76492aca4a3344888b8fa5aab77a49e9445cda718d75040",
148+
ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray()));
149+
}
157150

158-
/**
159-
* constructor.
160-
*/
161151
@AfterClass
162152
public void shutdown() throws InterruptedException {
163153
long balance = PublicMethed.queryAccount(contractExcKey, blockingStubFull).getBalance();
164-
PublicMethed.sendcoin(testNetAccountAddress, balance, contractExcAddress, contractExcKey,
165-
blockingStubFull);
154+
PublicMethed
155+
.sendcoin(testNetAccountAddress, balance - 1000000, contractExcAddress, contractExcKey,
156+
blockingStubFull);
166157
if (channelFull != null) {
167158
channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS);
168159
}

0 commit comments

Comments
 (0)