1+ // SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11
2+
13import { jest } from '@jest/globals' ;
2- import { useProvingStore } from '../../../src/utils/proving/provingMachine' ;
4+
35import { useProtocolStore } from '../../../src/stores/protocolStore' ;
46import { useSelfAppStore } from '../../../src/stores/selfAppStore' ;
7+ import { useProvingStore } from '../../../src/utils/proving/provingMachine' ;
58
69jest . mock ( 'xstate' , ( ) => {
710 const actual = jest . requireActual ( 'xstate' ) ;
811 const { actorMock } = require ( './actorMock' ) ;
912 return { ...actual , createActor : jest . fn ( ( ) => actorMock ) } ;
1013} ) ;
1114
12- jest . mock ( '../../../src/utils/analytics' , ( ) => ( ) => ( { trackEvent : jest . fn ( ) } ) ) ;
15+ jest . mock ( '../../../src/utils/analytics' , ( ) => ( ) => ( {
16+ trackEvent : jest . fn ( ) ,
17+ } ) ) ;
1318
1419jest . mock ( '@selfxyz/common' , ( ) => {
1520 const actual = jest . requireActual ( '@selfxyz/common' ) ;
16- return { ...actual , getSolidityPackedUserContextData : jest . fn ( ( ) => '0x1234' ) } ;
21+ return {
22+ ...actual ,
23+ getSolidityPackedUserContextData : jest . fn ( ( ) => '0x1234' ) ,
24+ } ;
1725} ) ;
1826
1927jest . mock ( '../../../src/utils/proving/provingInputs' , ( ) => ( {
@@ -42,12 +50,23 @@ jest.mock('../../../src/utils/proving/provingUtils', () => {
4250 return {
4351 ...actual ,
4452 getPayload : jest . fn ( ( ) => ( { mocked : true } ) ) ,
45- encryptAES256GCM : jest . fn ( ( ) => ( { nonce : [ 0 ] , cipher_text : [ 1 ] , auth_tag : [ 2 ] } ) ) ,
53+ encryptAES256GCM : jest . fn ( ( ) => ( {
54+ nonce : [ 0 ] ,
55+ cipher_text : [ 1 ] ,
56+ auth_tag : [ 2 ] ,
57+ } ) ) ,
4658 } ;
4759} ) ;
4860
49- const { getPayload, encryptAES256GCM } = require ( '../../../src/utils/proving/provingUtils' ) ;
50- const { generateTEEInputsRegister, generateTEEInputsDSC, generateTEEInputsDisclose } = require ( '../../../src/utils/proving/provingInputs' ) ;
61+ const {
62+ getPayload,
63+ encryptAES256GCM,
64+ } = require ( '../../../src/utils/proving/provingUtils' ) ;
65+ const {
66+ generateTEEInputsRegister,
67+ generateTEEInputsDSC,
68+ generateTEEInputsDisclose,
69+ } = require ( '../../../src/utils/proving/provingInputs' ) ;
5170
5271describe ( '_generatePayload' , ( ) => {
5372 beforeEach ( ( ) => {
@@ -60,8 +79,42 @@ describe('_generatePayload', () => {
6079 sharedKey : Buffer . alloc ( 32 , 1 ) ,
6180 env : 'prod' ,
6281 } ) ;
63- useSelfAppStore . setState ( { selfApp : { chainID : 1 , userId : 'u' , userDefinedData : '0x0' , endpointType : 'https' , endpoint : 'https://e' , scope : 's' , sessionId : '' , appName : '' , logoBase64 : '' , header : '' , userIdType : 'uuid' , devMode : false , disclosures : { } , version : 1 } } ) ;
64- useProtocolStore . setState ( { passport : { dsc_tree : 'tree' , csca_tree : [ [ 'a' ] ] , commitment_tree : null , deployed_circuits : null , circuits_dns_mapping : null , alternative_csca : { } } , id_card : { commitment_tree : null , dsc_tree : null , csca_tree : null , deployed_circuits : null , circuits_dns_mapping : null , alternative_csca : { } } } ) ;
82+ useSelfAppStore . setState ( {
83+ selfApp : {
84+ chainID : 1 ,
85+ userId : 'u' ,
86+ userDefinedData : '0x0' ,
87+ endpointType : 'https' ,
88+ endpoint : 'https://e' ,
89+ scope : 's' ,
90+ sessionId : '' ,
91+ appName : '' ,
92+ logoBase64 : '' ,
93+ header : '' ,
94+ userIdType : 'uuid' ,
95+ devMode : false ,
96+ disclosures : { } ,
97+ version : 1 ,
98+ } ,
99+ } ) ;
100+ useProtocolStore . setState ( {
101+ passport : {
102+ dsc_tree : 'tree' ,
103+ csca_tree : [ [ 'a' ] ] ,
104+ commitment_tree : null ,
105+ deployed_circuits : null ,
106+ circuits_dns_mapping : null ,
107+ alternative_csca : { } ,
108+ } ,
109+ id_card : {
110+ commitment_tree : null ,
111+ dsc_tree : null ,
112+ csca_tree : null ,
113+ deployed_circuits : null ,
114+ circuits_dns_mapping : null ,
115+ alternative_csca : { } ,
116+ } ,
117+ } ) ;
65118 } ) ;
66119
67120 it ( 'register circuit' , async ( ) => {
@@ -71,7 +124,12 @@ describe('_generatePayload', () => {
71124 expect ( getPayload ) . toHaveBeenCalled ( ) ;
72125 expect ( encryptAES256GCM ) . toHaveBeenCalled ( ) ;
73126 expect ( useProvingStore . getState ( ) . endpointType ) . toBe ( 'celo' ) ;
74- expect ( payload . params ) . toEqual ( { uuid : '123' , nonce : [ 0 ] , cipher_text : [ 1 ] , auth_tag : [ 2 ] } ) ;
127+ expect ( payload . params ) . toEqual ( {
128+ uuid : '123' ,
129+ nonce : [ 0 ] ,
130+ cipher_text : [ 1 ] ,
131+ auth_tag : [ 2 ] ,
132+ } ) ;
75133 } ) ;
76134
77135 it ( 'dsc circuit' , async ( ) => {
0 commit comments