Skip to content

Commit b3e623a

Browse files
author
Wenhua Zhang
committed
test: add test case for generate note with default address
1 parent 0a2b7f5 commit b3e623a

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

‎src/test/java/org/tron/core/zksnark/LibrustzcashTest.java‎

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,6 @@ public void calBenchmarkVerifySpend() throws ZksnarkException {
225225

226226
@Test
227227
public void testGenerateNote() throws Exception {
228-
librustzcashInitZksnarkParams();
229228

230229
int total = 10;
231230
int success = 0;
@@ -267,4 +266,44 @@ public void testGenerateNote() throws Exception {
267266
System.out.println("fail is: " + fail);
268267
}
269268

269+
@Test
270+
public void testGenerateNoteWithDefault() throws Exception {
271+
272+
int total = 1000;
273+
int success = 0;
274+
int fail = 0;
275+
276+
for (int i=0; i < total; i++) {
277+
278+
SpendingKey spendingKey = SpendingKey
279+
.decode("044ce61616fc962c9fb3ac3a71ce8bfc6dfd42d414eb8b64c3f7306861a7db36");
280+
// SpendingKey spendingKey = SpendingKey.random();
281+
282+
try {
283+
PaymentAddress address = spendingKey.defaultAddress();
284+
System.out.println("d is: " + ByteArray.toHexString(address.getD().getData()));
285+
System.out.println("pkd is: " + ByteArray.toHexString(address.getPkD()));
286+
287+
Note note = new Note(address, 100);
288+
note.rcm = ByteArray
289+
.fromHexString("bf4b2042e3e8c4a0b390e407a79a0b46e36eff4f7bb54b2349dbb0046ee21e02");
290+
291+
byte[] cm = note.cm();
292+
if (cm != null) {
293+
success ++;
294+
} else {
295+
fail ++;
296+
}
297+
System.out.println("note is " + note.cm());
298+
} catch (ZksnarkException e) {
299+
System.out.println("failed: " + e.getMessage());
300+
fail ++;
301+
// continue;
302+
}
303+
}
304+
System.out.println("total is: " + total);
305+
System.out.println("success is: " + success);
306+
System.out.println("fail is: " + fail);
307+
}
308+
270309
}

0 commit comments

Comments
 (0)