|
11 | 11 | import org.testng.Assert; |
12 | 12 | import org.tron.common.runtime.TVMTestResult; |
13 | 13 | import org.tron.common.runtime.TvmTestUtils; |
| 14 | +import org.tron.common.utils.ByteArray; |
14 | 15 | import org.tron.common.utils.WalletUtil; |
| 16 | +import org.tron.core.Wallet; |
15 | 17 | import org.tron.core.exception.ContractExeException; |
16 | 18 | import org.tron.core.exception.ContractValidateException; |
| 19 | +import org.tron.core.exception.JsonRpcInvalidParamsException; |
17 | 20 | import org.tron.core.exception.ReceiptCheckErrException; |
18 | 21 | import org.tron.core.exception.VMIllegalException; |
| 22 | +import org.tron.core.services.NodeInfoService; |
| 23 | +import org.tron.core.services.jsonrpc.TronJsonRpcImpl; |
19 | 24 | import org.tron.protos.Protocol.Transaction; |
20 | 25 | import stest.tron.wallet.common.client.utils.AbiUtil; |
21 | 26 | import stest.tron.wallet.common.client.utils.DataWord; |
@@ -171,14 +176,31 @@ public void testCreate2() |
171 | 176 |
|
172 | 177 | // trigger deployed contract |
173 | 178 | String methodToTrigger = "plusOne()"; |
174 | | - for (int i = 1; i < 3; i++) { |
| 179 | + long loop = 2; |
| 180 | + for (int i = 1; i <= loop; i++) { |
175 | 181 | hexInput = AbiUtil.parseMethod(methodToTrigger, Collections.emptyList()); |
176 | 182 | result = TvmTestUtils |
177 | 183 | .triggerContractAndReturnTvmTestResult(Hex.decode(OWNER_ADDRESS), |
178 | 184 | actualContract, Hex.decode(hexInput), 0, fee, manager, null); |
179 | 185 | Assert.assertNull(result.getRuntime().getRuntimeError()); |
180 | 186 | Assert.assertEquals(result.getRuntime().getResult().getHReturn(), new DataWord(i).getData()); |
181 | 187 | } |
| 188 | + testJsonRpc(actualContract, loop); |
| 189 | + } |
| 190 | + |
| 191 | + private void testJsonRpc(byte[] actualContract, long loop) { |
| 192 | + TronJsonRpcImpl tronJsonRpc; |
| 193 | + NodeInfoService nodeInfoService; |
| 194 | + nodeInfoService = context.getBean(NodeInfoService.class); |
| 195 | + Wallet wallet = context.getBean(Wallet.class); |
| 196 | + tronJsonRpc = new TronJsonRpcImpl(nodeInfoService, wallet, manager); |
| 197 | + try { |
| 198 | + String res = |
| 199 | + tronJsonRpc.getStorageAt(ByteArray.toHexString(actualContract), "0", "latest"); |
| 200 | + Assert.assertEquals(loop, ByteArray.jsonHexToLong(res)); |
| 201 | + } catch (JsonRpcInvalidParamsException e) { |
| 202 | + Assert.fail(); |
| 203 | + } |
182 | 204 | } |
183 | 205 |
|
184 | 206 | /* |
|
0 commit comments