11import { expect , it , jest } from '@jest/globals' ;
22import { type SendTelegram } from '../../src/web3telegram/sendTelegram.js' ;
33import { getRandomAddress } from '../test-utils.js' ;
4- import { CHAIN_CONFIG , CHAIN_IDS } from '../../src/config/config.js' ;
4+ import {
5+ DEFAULT_CHAIN_ID ,
6+ getChainDefaultConfig ,
7+ } from '../../src/config/config.js' ;
58import { mockAllForSendTelegram } from '../utils/mockAllForSendTelegram.js' ;
69
710jest . unstable_mockModule ( '../../src/utils/subgraphQuery.js' , ( ) => ( {
811 checkProtectedDataValidity : jest . fn ( ) ,
912} ) ) ;
1013
1114jest . unstable_mockModule ( '../../src/utils/ipfs-service.js' , ( ) => ( {
12- add : jest . fn ( ( ) => Promise . resolve ( 'QmSBoN71925mWJ6acehqDLQrrxihxX55EXrqHxpYja4HCG' ) ) ,
15+ add : jest . fn ( ( ) =>
16+ Promise . resolve ( 'QmSBoN71925mWJ6acehqDLQrrxihxX55EXrqHxpYja4HCG' )
17+ ) ,
1318 get : jest . fn ( ( ) => Promise . resolve ( new ArrayBuffer ( 8 ) ) ) ,
1419} ) ) ;
1520
1621describe ( 'sendTelegram' , ( ) => {
1722 let testedModule : any ;
1823 let sendTelegram : SendTelegram ;
24+ const defaultConfig = getChainDefaultConfig ( DEFAULT_CHAIN_ID ) ;
1925
2026 beforeAll ( async ( ) => {
2127 // import tested module after all mocked modules
@@ -37,11 +43,11 @@ describe('sendTelegram', () => {
3743 sendTelegram ( {
3844 graphQLClient : { request : jest . fn ( ) } as any ,
3945 iexec : mockAllForSendTelegram ( ) as any ,
40- workerpoolAddressOrEns : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . prodWorkerpoolAddress ,
41- dappAddressOrENS : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . dappAddress ,
42- dappWhitelistAddress : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . whitelistSmartContract ,
43- ipfsNode : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsUploadUrl ,
44- ipfsGateway : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsGateway ,
46+ workerpoolAddressOrEns : defaultConfig . prodWorkerpoolAddress ,
47+ dappAddressOrENS : defaultConfig . dappAddress ,
48+ dappWhitelistAddress : defaultConfig . whitelistSmartContract ,
49+ ipfsNode : defaultConfig . ipfsUploadUrl ,
50+ ipfsGateway : defaultConfig . ipfsGateway ,
4551 senderName : 'AB' , // Trop court, déclenche l'erreur Yup
4652 ...sendTelegramParams ,
4753 } )
@@ -70,11 +76,11 @@ describe('sendTelegram', () => {
7076 sendTelegram ( {
7177 graphQLClient : { request : jest . fn ( ) } as any ,
7278 iexec : mockAllForSendTelegram ( ) as any ,
73- workerpoolAddressOrEns : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . prodWorkerpoolAddress ,
74- dappAddressOrENS : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . dappAddress ,
75- dappWhitelistAddress : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . whitelistSmartContract ,
76- ipfsNode : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsUploadUrl ,
77- ipfsGateway : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsGateway ,
79+ workerpoolAddressOrEns : defaultConfig . prodWorkerpoolAddress ,
80+ dappAddressOrENS : defaultConfig . dappAddress ,
81+ dappWhitelistAddress : defaultConfig . whitelistSmartContract ,
82+ ipfsNode : defaultConfig . ipfsUploadUrl ,
83+ ipfsGateway : defaultConfig . ipfsGateway ,
7884 senderName : 'AB' , // Trop court, déclenche l'erreur Yup
7985 ...sendTelegramParams ,
8086 } )
@@ -103,11 +109,11 @@ describe('sendTelegram', () => {
103109 sendTelegram ( {
104110 graphQLClient : { request : jest . fn ( ) } as any ,
105111 iexec : mockAllForSendTelegram ( ) as any ,
106- workerpoolAddressOrEns : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . prodWorkerpoolAddress ,
107- dappAddressOrENS : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . dappAddress ,
108- dappWhitelistAddress : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . whitelistSmartContract ,
109- ipfsNode : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsUploadUrl ,
110- ipfsGateway : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsGateway ,
112+ workerpoolAddressOrEns : defaultConfig . prodWorkerpoolAddress ,
113+ dappAddressOrENS : defaultConfig . dappAddress ,
114+ dappWhitelistAddress : defaultConfig . whitelistSmartContract ,
115+ ipfsNode : defaultConfig . ipfsUploadUrl ,
116+ ipfsGateway : defaultConfig . ipfsGateway ,
111117 ...sendTelegramParams ,
112118 } )
113119 ) . rejects . toMatchObject ( {
@@ -135,11 +141,11 @@ describe('sendTelegram', () => {
135141 sendTelegram ( {
136142 graphQLClient : { request : jest . fn ( ) } as any ,
137143 iexec : mockAllForSendTelegram ( ) as any ,
138- workerpoolAddressOrEns : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . prodWorkerpoolAddress ,
139- dappAddressOrENS : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . dappAddress ,
140- dappWhitelistAddress : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . whitelistSmartContract ,
141- ipfsNode : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsUploadUrl ,
142- ipfsGateway : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsGateway ,
144+ workerpoolAddressOrEns : defaultConfig . prodWorkerpoolAddress ,
145+ dappAddressOrENS : defaultConfig . dappAddress ,
146+ dappWhitelistAddress : defaultConfig . whitelistSmartContract ,
147+ ipfsNode : defaultConfig . ipfsUploadUrl ,
148+ ipfsGateway : defaultConfig . ipfsGateway ,
143149 ...sendTelegramParams ,
144150 } )
145151 ) . rejects . toMatchObject ( {
@@ -169,11 +175,11 @@ describe('sendTelegram', () => {
169175 sendTelegram ( {
170176 graphQLClient : { request : jest . fn ( ) } as any ,
171177 iexec : mockAllForSendTelegram ( ) as any ,
172- workerpoolAddressOrEns : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . prodWorkerpoolAddress ,
173- dappAddressOrENS : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . dappAddress ,
174- dappWhitelistAddress : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . whitelistSmartContract ,
175- ipfsNode : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsUploadUrl ,
176- ipfsGateway : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsGateway ,
178+ workerpoolAddressOrEns : defaultConfig . prodWorkerpoolAddress ,
179+ dappAddressOrENS : defaultConfig . dappAddress ,
180+ dappWhitelistAddress : defaultConfig . whitelistSmartContract ,
181+ ipfsNode : defaultConfig . ipfsUploadUrl ,
182+ ipfsGateway : defaultConfig . ipfsGateway ,
177183 ...sendTelegramParams ,
178184 } )
179185 ) . rejects . toMatchObject ( {
@@ -208,11 +214,11 @@ describe('sendTelegram', () => {
208214 await sendTelegram ( {
209215 graphQLClient : { request : jest . fn ( ) } as any ,
210216 iexec,
211- workerpoolAddressOrEns : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . prodWorkerpoolAddress ,
212- dappAddressOrENS : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . dappAddress ,
213- dappWhitelistAddress : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . whitelistSmartContract ,
214- ipfsNode : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsUploadUrl ,
215- ipfsGateway : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . ipfsGateway ,
217+ workerpoolAddressOrEns : defaultConfig . prodWorkerpoolAddress ,
218+ dappAddressOrENS : defaultConfig . dappAddress ,
219+ dappWhitelistAddress : defaultConfig . whitelistSmartContract ,
220+ ipfsNode : defaultConfig . ipfsUploadUrl ,
221+ ipfsGateway : defaultConfig . ipfsGateway ,
216222 telegramContent : 'e2e telegram content for test' ,
217223 protectedData,
218224 } ) ;
@@ -222,8 +228,8 @@ describe('sendTelegram', () => {
222228 expect ( iexec . orderbook . fetchWorkerpoolOrderbook ) . toHaveBeenNthCalledWith (
223229 1 ,
224230 {
225- workerpool : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . prodWorkerpoolAddress ,
226- app : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . dappAddress . toLowerCase ( ) ,
231+ workerpool : defaultConfig . prodWorkerpoolAddress ,
232+ app : defaultConfig . dappAddress . toLowerCase ( ) ,
227233 dataset : protectedData ,
228234 requester : userAddress ,
229235 isRequesterStrict : false ,
@@ -235,8 +241,8 @@ describe('sendTelegram', () => {
235241 expect ( iexec . orderbook . fetchWorkerpoolOrderbook ) . toHaveBeenNthCalledWith (
236242 2 ,
237243 {
238- workerpool : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . prodWorkerpoolAddress ,
239- app : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . whitelistSmartContract . toLowerCase ( ) ,
244+ workerpool : defaultConfig . prodWorkerpoolAddress ,
245+ app : defaultConfig . whitelistSmartContract . toLowerCase ( ) ,
240246 dataset : protectedData ,
241247 requester : userAddress ,
242248 isRequesterStrict : false ,
@@ -248,8 +254,8 @@ describe('sendTelegram', () => {
248254 expect ( iexec . orderbook . fetchWorkerpoolOrderbook ) . toHaveBeenNthCalledWith (
249255 2 ,
250256 {
251- workerpool : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . prodWorkerpoolAddress ,
252- app : CHAIN_CONFIG [ CHAIN_IDS . BELLECOUR ] . whitelistSmartContract . toLowerCase ( ) ,
257+ workerpool : defaultConfig . prodWorkerpoolAddress ,
258+ app : defaultConfig . whitelistSmartContract . toLowerCase ( ) ,
253259 dataset : protectedData ,
254260 requester : userAddress ,
255261 isRequesterStrict : false ,
0 commit comments