|
19 | 19 | import org.tron.core.capsule.TransactionCapsule; |
20 | 20 | import org.tron.core.config.args.Args; |
21 | 21 | import org.tron.core.exception.ContractExeException; |
| 22 | +import org.tron.core.exception.ContractValidateException; |
22 | 23 | import org.tron.core.services.http.JsonFormat; |
23 | 24 | import org.tron.core.services.http.JsonFormat.ParseException; |
24 | 25 |
|
@@ -337,6 +338,48 @@ public void testCreateShieldedContractParameters() throws ContractExeException { |
337 | 338 | } |
338 | 339 | } |
339 | 340 |
|
| 341 | + @Test |
| 342 | + public void testCreateShieldedContractParameters2() throws ContractExeException { |
| 343 | + librustzcashInitZksnarkParams(); |
| 344 | + Args.getInstance().setFullNodeAllowShieldedTransactionArgs(true); |
| 345 | + Wallet wallet1 = spy(new Wallet()); |
| 346 | + |
| 347 | + doReturn(BigInteger.valueOf(1).toByteArray()) |
| 348 | + .when(wallet1).getShieldedContractScalingFactor( |
| 349 | + ByteArray.fromHexString("4144007979359ECAC395BBD3CEF8060D3DF2DC3F01")); |
| 350 | + String parameter = new String(ByteArray.fromHexString( |
| 351 | + "7b0a202020202261736b223a2263323531336539653330383439343933326264383265306365353336" |
| 352 | + + "363264313734323164393062373261383437316130613132623835353261333336653032222c0a202" |
| 353 | + + "02020226e736b223a2234633662663364643461303634336432306236323866376534353938306335" |
| 354 | + + "653138376630376135316436663365383661616631616239313663303765623064222c0a202020202" |
| 355 | + + "26f766b223a2231376135386439613530353864613665343263613132636432383964306136616131" |
| 356 | + + "363962393236633138653139626361353138623864366638363734653433222c0a202020202266726" |
| 357 | + + "f6d5f616d6f756e74223a22313030222c0a2020202022736869656c6465645f726563656976657322" |
| 358 | + + "3a5b0a20202020202020207b0a202020202020202020202020226e6f7465223a7b0a2020202020202" |
| 359 | + + "02020202020202020202276616c7565223a3130302c0a202020202020202020202020202020202270" |
| 360 | + + "61796d656e745f61646472657373223a22222c0a202020202020202020202020202020202272636d2" |
| 361 | + + "23a223136623666356534303434346162376565616231316165363631336332376633353131373937" |
| 362 | + + "3165666138376237313536306235383133383239633933393064220a2020202020202020202020207" |
| 363 | + + "d0a20202020202020207d0a202020205d2c0a2020202022736869656c6465645f54524332305f636f" |
| 364 | + + "6e74726163745f61646472657373223a2234313434303037393739333539454341433339354242443" |
| 365 | + + "3434546383036304433444632444333463031220a7d")); |
| 366 | + PrivateShieldedTRC20Parameters.Builder builder = PrivateShieldedTRC20Parameters.newBuilder(); |
| 367 | + try { |
| 368 | + JsonFormat.merge(parameter, builder, false); |
| 369 | + } catch (ParseException e) { |
| 370 | + Assert.fail(); |
| 371 | + } |
| 372 | + |
| 373 | + try { |
| 374 | + wallet1.createShieldedContractParameters(builder.build()); |
| 375 | + Assert.fail(); |
| 376 | + } catch (Exception e) { |
| 377 | + Assert.assertTrue(e instanceof ContractValidateException); |
| 378 | + Assert.assertEquals("Payment Address in ReceiveNote should not be empty", |
| 379 | + e.getMessage()); |
| 380 | + } |
| 381 | + } |
| 382 | + |
340 | 383 | @Test |
341 | 384 | public void testCreateShieldedContractParametersWithoutAsk() throws ContractExeException { |
342 | 385 | librustzcashInitZksnarkParams(); |
|
0 commit comments