11import { encode } from 'bs58' ;
2- import { certificateFromString , certificateToString , issue } from '../../internal/trust/certificate' ;
3- import { TrustGraph } from '../../internal/trust/trust_graph' ;
4- import { nodeRootCert } from '../../internal/trust/misc' ;
52import { generatePeerId , peerIdToSeed , seedToPeerId } from '../../internal/peerIdUtils' ;
63import { FluenceClientImpl } from '../../internal/FluenceClientImpl' ;
7- import { createConnectedClient , createLocalClient } from '../util' ;
4+ import { createConnectedClient } from '../util' ;
85import log from 'loglevel' ;
96import { createClient } from '../../api' ;
107import Multiaddr from 'multiaddr' ;
@@ -22,28 +19,6 @@ describe('Typescript usage suite', () => {
2219 expect ( peerIdToSeed ( pid ) ) . toEqual ( seedStr ) ;
2320 } ) ;
2421
25- it ( 'should serialize and deserialize certificate correctly' , async function ( ) {
26- let cert = `11
27- 1111
28- 5566Dn4ZXXbBK5LJdUsE7L3pG9qdAzdPY47adjzkhEx9
29- 3HNXpW2cLdqXzf4jz5EhsGEBFkWzuVdBCyxzJUZu2WPVU7kpzPjatcqvdJMjTtcycVAdaV5qh2fCGphSmw8UMBkr
30- 158981172690500
31- 1589974723504
32- 2EvoZAZaGjKWFVdr36F1jphQ5cW7eK3yM16mqEHwQyr7
33- 4UAJQWzB3nTchBtwARHAhsn7wjdYtqUHojps9xV6JkuLENV8KRiWM3BhQByx5KijumkaNjr7MhHjouLawmiN1A4d
34- 1590061123504
35- 1589974723504` ;
36-
37- let deser = await certificateFromString ( cert ) ;
38- let ser = certificateToString ( deser ) ;
39-
40- expect ( ser ) . toEqual ( cert ) ;
41- } ) ;
42-
43- it . skip ( 'should perform tests on certs' , async function ( ) {
44- await testCerts ( ) ;
45- } ) ;
46-
4722 describe ( 'should make connection to network' , function ( ) {
4823 const testProcedure = async ( client : FluenceClientImpl ) => {
4924 let resMakingPromise = new Promise ( ( resolve ) => {
@@ -290,42 +265,3 @@ describe('Typescript usage suite', () => {
290265 } ) ;
291266 } ) ;
292267} ) ;
293-
294- export async function testCerts ( ) {
295- const key1 = await generatePeerId ( ) ;
296- const key2 = await generatePeerId ( ) ;
297-
298- // connect to two different nodes
299- const cl1 = new FluenceClientImpl ( key1 ) ;
300- const cl2 = new FluenceClientImpl ( key2 ) ;
301-
302- await cl1 . connect ( '/dns4/134.209.186.43/tcp/9003/ws/p2p/12D3KooWBUJifCTgaxAUrcM9JysqCcS4CS8tiYH5hExbdWCAoNwb' ) ;
303- await cl2 . connect ( '/ip4/134.209.186.43/tcp/9002/ws/p2p/12D3KooWHk9BjDQBUqnavciRPhAYFvqKBe4ZiPPvde7vDaqgn5er' ) ;
304-
305- let trustGraph1 = new TrustGraph ( /* cl1 */ ) ;
306- let trustGraph2 = new TrustGraph ( /* cl2 */ ) ;
307-
308- let issuedAt = new Date ( ) ;
309- let expiresAt = new Date ( ) ;
310- // certificate expires after one day
311- expiresAt . setDate ( new Date ( ) . getDate ( ) + 1 ) ;
312-
313- // create root certificate for key1 and extend it with key2
314- let rootCert = await nodeRootCert ( key1 ) ;
315- let extended = await issue ( key1 , key2 , rootCert , expiresAt . getTime ( ) , issuedAt . getTime ( ) ) ;
316-
317- // publish certificates to Fluence network
318- await trustGraph1 . publishCertificates ( key2 . toB58String ( ) , [ extended ] ) ;
319-
320- // get certificates from network
321- let certs = await trustGraph2 . getCertificates ( key2 . toB58String ( ) ) ;
322-
323- // root certificate could be different because nodes save trusts with bigger `expiresAt` date and less `issuedAt` date
324- expect ( certs [ 0 ] . chain [ 1 ] . issuedFor . toB58String ( ) ) . toEqual ( extended . chain [ 1 ] . issuedFor . toB58String ( ) ) ;
325- expect ( certs [ 0 ] . chain [ 1 ] . signature ) . toEqual ( extended . chain [ 1 ] . signature ) ;
326- expect ( certs [ 0 ] . chain [ 1 ] . expiresAt ) . toEqual ( extended . chain [ 1 ] . expiresAt ) ;
327- expect ( certs [ 0 ] . chain [ 1 ] . issuedAt ) . toEqual ( extended . chain [ 1 ] . issuedAt ) ;
328-
329- await cl1 . disconnect ( ) ;
330- await cl2 . disconnect ( ) ;
331- }
0 commit comments