File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed
packages/portalnetwork/test/wire Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change 1+ import { assert , describe , expect , it } from 'vitest'
2+ import { decodeClientInfo , encodeClientInfo } from '../../src/index.js'
3+ import { bytesToHex , hexToBytes , toAscii } from '@ethereumjs/util'
4+ describe ( 'Client Info' , ( ) => {
5+ const testVectors = {
6+ object : {
7+ clientName : 'trin' ,
8+ clientVersionAndShortCommit : '0.1.1-2b00d730' ,
9+ operatingSystemAndCpuArchitecture : 'linux-x86_64' ,
10+ programmingLanguageAndVersion : 'rustc1.81.0' ,
11+ } ,
12+ string : 'trin/0.1.1-2b00d730/linux-x86_64/rustc1.81.0' ,
13+ hex : '0x7472696E2F302E312E312D32623030643733302F6C696E75782D7838365F36342F7275737463312E38312E30' ,
14+ }
15+
16+ it ( 'should encode client info hex' , ( ) => {
17+ const encoded = encodeClientInfo ( testVectors . object )
18+ expect ( bytesToHex ( encoded ) . toLowerCase ( ) ) . toEqual ( testVectors . hex . toLowerCase ( ) )
19+ } )
20+
21+ it ( 'should decode client info hex' , ( ) => {
22+ const decoded = decodeClientInfo ( hexToBytes ( testVectors . hex ) )
23+ assert . deepEqual ( decoded , testVectors . object )
24+ } )
25+
26+ it ( 'should equal client info string' , ( ) => {
27+ assert . equal ( toAscii ( testVectors . hex ) , testVectors . string )
28+ } )
29+ } )
You can’t perform that action at this time.
0 commit comments