|
1 | | -package stest.tron.wallet.dailybuild.tvmnewcommand.precompiledcontracts; |
| 1 | +package stest.tron.wallet.dailybuild.tvmnewcommand.zenProofCommand; |
2 | 2 |
|
3 | 3 | import io.grpc.ManagedChannel; |
4 | 4 | import io.grpc.ManagedChannelBuilder; |
@@ -86,83 +86,74 @@ public void test01DataIsEmpty() { |
86 | 86 | PublicMethed.waitProduceNextBlock(blockingStubFull); |
87 | 87 | Optional<TransactionInfo> infoById = PublicMethed |
88 | 88 | .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")); |
97 | 95 | } |
98 | 96 |
|
99 | 97 | @Test(enabled = true, description = "data length limit") |
100 | 98 | public void test02DataLengthLimit() { |
101 | 99 | 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); |
108 | 106 | 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 |
110 | 125 | .getTransactionInfoById(txid, blockingStubFull); |
111 | 126 | 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" |
116 | 128 | + "0000000000000000000000000000000000000000000000000000000000000040" |
117 | 129 | + "0000000000000000000000000000000000000000000000000000000000000020" |
118 | | - + "0000000000000000000000000000000000000000000000000000000000000000")); |
| 130 | + + "7d6b910840eb7b47f76492aca4a3344888b8fa5aab77a49e9445cda718d75040", |
| 131 | + ByteArray.toHexString(infoById.get().getContractResult(0).toByteArray())); |
119 | 132 | } |
120 | 133 |
|
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"; |
146 | 140 | 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); |
148 | 146 | 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 | + } |
157 | 150 |
|
158 | | - /** |
159 | | - * constructor. |
160 | | - */ |
161 | 151 | @AfterClass |
162 | 152 | public void shutdown() throws InterruptedException { |
163 | 153 | 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); |
166 | 157 | if (channelFull != null) { |
167 | 158 | channelFull.shutdown().awaitTermination(5, TimeUnit.SECONDS); |
168 | 159 | } |
|
0 commit comments