@@ -2,9 +2,9 @@ import { encode } from 'bs58';
2
2
import { generatePeerId , peerIdToSeed , seedToPeerId } from '../../internal/peerIdUtils' ;
3
3
import { FluenceClientImpl } from '../../internal/FluenceClientImpl' ;
4
4
import log from 'loglevel' ;
5
- import { createClient } from '../../api' ;
5
+ import { createClient , subscribeForErrors } from '../../api' ;
6
6
import Multiaddr from 'multiaddr' ;
7
- import { createConnectedClient , nodes } from '../connection' ;
7
+ import { createConnectedClient , createLocalClient , nodes } from '../connection' ;
8
8
9
9
describe ( 'Typescript usage suite' , ( ) => {
10
10
it ( 'should create private key from seed and back' , async function ( ) {
@@ -219,4 +219,46 @@ describe('Typescript usage suite', () => {
219
219
let res = await resMakingPromise ;
220
220
expect ( res ) . toEqual ( [ 'some a' , 'some b' , 'some c' , 'some d' ] ) ;
221
221
} ) ;
222
+
223
+ it ( 'xor handling should work with connected client' , async function ( ) {
224
+ // arrange
225
+ const client = await createConnectedClient ( nodes [ 0 ] . multiaddr ) ;
226
+ log . setLevel ( 'info' ) ;
227
+
228
+ // act
229
+ let script = `
230
+ (seq
231
+ (call relay ("op" "identity") [])
232
+ (call relay ("incorrect" "service") ["incorrect_arg"])
233
+ )
234
+ ` ;
235
+ const data = new Map ( ) ;
236
+ data . set ( 'relay' , client . relayPeerId ) ;
237
+
238
+ const promise = subscribeForErrors ( client , 7000 ) ;
239
+ await client . sendScript ( script , data ) ;
240
+
241
+ // assert
242
+ await expect ( promise ) . rejects . toMatchObject ( {
243
+ error : expect . stringContaining ( "Service with id 'incorrect' not found" ) ,
244
+ instruction : expect . stringContaining ( 'incorrect' ) ,
245
+ } ) ;
246
+ } ) ;
247
+
248
+ it ( 'xor handling should work with local client' , async function ( ) {
249
+ // arrange
250
+ const client = await createLocalClient ( ) ;
251
+
252
+ // act
253
+ let script = `(call %init_peer_id% ("incorrect" "service") ["incorrect_arg"])` ;
254
+
255
+ const promise = subscribeForErrors ( client , 7000 ) ;
256
+ await client . sendScript ( script ) ;
257
+
258
+ // assert
259
+ await expect ( promise ) . rejects . toMatchObject ( {
260
+ error : expect . stringContaining ( 'There is no service: incorrect' ) ,
261
+ instruction : expect . stringContaining ( 'incorrect' ) ,
262
+ } ) ;
263
+ } ) ;
222
264
} ) ;
0 commit comments