@@ -61,6 +61,7 @@ describe("Zeto based fungible token with anonymity using nullifiers and encrypti
61
61
let erc20 : any ;
62
62
let zeto : any ;
63
63
let utxo100 : UTXO ;
64
+ let utxo0 : UTXO ;
64
65
let utxo1 : UTXO ;
65
66
let utxo2 : UTXO ;
66
67
let utxo3 : UTXO ;
@@ -336,17 +337,20 @@ describe("Zeto based fungible token with anonymity using nullifiers and encrypti
336
337
await tx1 . wait ( ) ;
337
338
338
339
utxo100 = newUTXO ( 100 , Alice ) ;
340
+ utxo0 = newUTXO ( 0 , Alice ) ;
339
341
const { outputCommitments, encodedProof } = await prepareDepositProof (
340
342
Alice ,
341
- utxo100 ,
343
+ [ utxo100 , utxo0 ] ,
342
344
) ;
343
345
const tx2 = await zeto
344
346
. connect ( Alice . signer )
345
- . deposit ( 100 , outputCommitments [ 0 ] , encodedProof , "0x" ) ;
347
+ . deposit ( 100 , outputCommitments , encodedProof , "0x" ) ;
346
348
await tx2 . wait ( ) ;
347
349
348
350
await smtAlice . add ( utxo100 . hash , utxo100 . hash ) ;
351
+ await smtAlice . add ( utxo0 . hash , utxo0 . hash ) ;
349
352
await smtBob . add ( utxo100 . hash , utxo100 . hash ) ;
353
+ await smtBob . add ( utxo0 . hash , utxo0 . hash ) ;
350
354
} ) ;
351
355
352
356
it ( "mint to Alice and transfer UTXOs honestly to Bob should succeed" , async function ( ) {
@@ -576,6 +580,7 @@ describe("Zeto based fungible token with anonymity using nullifiers and encrypti
576
580
577
581
describe ( "unregistered user cases" , function ( ) {
578
582
let unregisteredUtxo100 : UTXO ;
583
+ let unregisteredUtxo0 : UTXO ;
579
584
580
585
it ( "deposit by an unregistered user should succeed" , async function ( ) {
581
586
const tx = await erc20
@@ -588,24 +593,28 @@ describe("Zeto based fungible token with anonymity using nullifiers and encrypti
588
593
await tx1 . wait ( ) ;
589
594
590
595
unregisteredUtxo100 = newUTXO ( 100 , unregistered ) ;
596
+ unregisteredUtxo0 = newUTXO ( 0 , unregistered ) ;
591
597
const { outputCommitments, encodedProof } = await prepareDepositProof (
592
598
unregistered ,
593
- unregisteredUtxo100 ,
599
+ [ unregisteredUtxo100 , unregisteredUtxo0 ] ,
594
600
) ;
595
601
const tx2 = await zeto
596
602
. connect ( unregistered . signer )
597
- . deposit ( 100 , outputCommitments [ 0 ] , encodedProof , "0x" ) ;
603
+ . deposit ( 100 , outputCommitments , encodedProof , "0x" ) ;
598
604
await tx2 . wait ( ) ;
599
605
600
606
// Alice tracks the UTXO inside the SMT
601
607
await smtAlice . add ( unregisteredUtxo100 . hash , unregisteredUtxo100 . hash ) ;
608
+ await smtAlice . add ( unregisteredUtxo0 . hash , unregisteredUtxo0 . hash ) ;
602
609
// Bob also locally tracks the UTXOs inside the SMT
603
610
await smtBob . add ( unregisteredUtxo100 . hash , unregisteredUtxo100 . hash ) ;
611
+ await smtBob . add ( unregisteredUtxo0 . hash , unregisteredUtxo0 . hash ) ;
604
612
} ) ;
605
613
606
614
it ( "transfer from an unregistered user should fail" , async function ( ) {
607
615
// catch up the local SMT for the unregistered user
608
616
await smtUnregistered . add ( utxo100 . hash , utxo100 . hash ) ;
617
+ await smtUnregistered . add ( utxo0 . hash , utxo0 . hash ) ;
609
618
await smtUnregistered . add ( utxo1 . hash , utxo1 . hash ) ;
610
619
await smtUnregistered . add ( utxo2 . hash , utxo2 . hash ) ;
611
620
await smtUnregistered . add ( _utxo3 . hash , _utxo3 . hash ) ;
@@ -620,6 +629,7 @@ describe("Zeto based fungible token with anonymity using nullifiers and encrypti
620
629
unregisteredUtxo100 . hash ,
621
630
unregisteredUtxo100 . hash ,
622
631
) ;
632
+ await smtUnregistered . add ( unregisteredUtxo0 . hash , unregisteredUtxo0 . hash ) ;
623
633
const utxosRoot = await smtUnregistered . root ( ) ;
624
634
625
635
const nullifier = newNullifier ( unregisteredUtxo100 , unregistered ) ;
0 commit comments