@@ -37,7 +37,8 @@ import {
37
37
Profile ,
38
38
InMemoryMerkleTreeStorage ,
39
39
W3CCredential ,
40
- Sec256k1Provider
40
+ Sec256k1Provider ,
41
+ StateInfo
41
42
} from '../../src' ;
42
43
import { Token } from '@iden3/js-jwz' ;
43
44
import { Blockchain , DID , DidMethod , NetworkId } from '@iden3/js-iden3-core' ;
@@ -565,8 +566,26 @@ describe('auth', () => {
565
566
from : didIssuer . string ( )
566
567
} ;
567
568
569
+ // Ethereum identities should have a previous state in state storage. We mock it here.
570
+ const previousGetLatestStateById = MOCK_STATE_STORAGE . getLatestStateById ;
571
+ MOCK_STATE_STORAGE . getLatestStateById = async ( id : bigint ) : Promise < StateInfo > => {
572
+ return {
573
+ id,
574
+ state : res . oldTreeState . state . bigInt ( ) ,
575
+ replacedByState : 0n ,
576
+ createdAtTimestamp : 1712062738n ,
577
+ replacedAtTimestamp : 0n ,
578
+ createdAtBlock : 5384981n ,
579
+ replacedAtBlock : 0n
580
+ } ;
581
+ } ;
582
+
568
583
const msgBytes = byteEncoder . encode ( JSON . stringify ( authReq ) ) ;
569
584
const authRes = await authHandler . handleAuthorizationRequest ( userDID , msgBytes ) ;
585
+
586
+ // Restore the mock state storage
587
+ MOCK_STATE_STORAGE . getLatestStateById = previousGetLatestStateById ;
588
+
570
589
// console.log(JSON.stringify(authRes.authResponse));
571
590
const tokenStr = authRes . token ;
572
591
// console.log(tokenStr);
@@ -580,7 +599,7 @@ describe('auth', () => {
580
599
const stateEthConfig = defaultEthConnectionConfig ;
581
600
stateEthConfig . url = RPC_URL ;
582
601
stateEthConfig . contractAddress = STATE_CONTRACT ;
583
- stateEthConfig . chainId = 80001 ;
602
+ stateEthConfig . chainId = 80002 ; // Amoy
584
603
585
604
const memoryKeyStore = new InMemoryPrivateKeyStore ( ) ;
586
605
const bjjProvider = new BjjProvider ( KmsKeyType . BabyJubJub , memoryKeyStore ) ;
@@ -625,7 +644,7 @@ describe('auth', () => {
625
644
const { did : didUser , credential : userAuthCredential } = await idWallet . createIdentity ( {
626
645
method : DidMethod . PolygonId ,
627
646
blockchain : Blockchain . Polygon ,
628
- networkId : NetworkId . Mumbai ,
647
+ networkId : NetworkId . Amoy ,
629
648
seed : SEED_USER ,
630
649
revocationOpts : {
631
650
type : CredentialStatusType . Iden3ReverseSparseMerkleTreeProof ,
@@ -643,15 +662,15 @@ describe('auth', () => {
643
662
const { did : didIssuer , credential : issuerAuthCredential } = await idWallet . createIdentity ( {
644
663
method : DidMethod . PolygonId ,
645
664
blockchain : Blockchain . Polygon ,
646
- networkId : NetworkId . Mumbai ,
665
+ networkId : NetworkId . Amoy ,
647
666
seed : Buffer . from ( WALLET_KEY , 'hex' ) ,
648
667
revocationOpts : {
649
668
type : CredentialStatusType . Iden3ReverseSparseMerkleTreeProof ,
650
669
id : RHS_URL
651
670
} ,
652
671
keyType : KmsKeyType . Secp256k1 ,
653
672
ethSigner,
654
- proofService : proofService
673
+ proofService
655
674
} ) ;
656
675
expect ( issuerAuthCredential ) . not . to . be . undefined ;
657
676
0 commit comments