Skip to content
This repository has been archived by the owner on Dec 10, 2020. It is now read-only.

fix incorrect argument passed in neighbours.encode #36

Closed
wants to merge 1 commit into from

Conversation

uneco
Copy link

@uneco uneco commented Mar 18, 2018

test code:

let data = {
  peers: [
    {
      id: Buffer.from('1111'),
      endpoint: {
        address: '192.168.0.1',
        udpPort: 8080,
        tcpPort: 8080,
      },
    },
    {
      id: Buffer.from('1112'),
      endpoint: {
        address: '192.168.0.2',
        udpPort: 8080,
        tcpPort: 8080,
      },
    },
  ],
  timestamp: Math.floor(new Date().getTime() / 1000),
}

console.log(hex(neighbours.encode(data)))
console.log(neighbours.decode(neighbours.encode(data)))

before this change:

Error: Invalid address: undefined
    at Object.encode (/private/tmp/test/dpt/message.js:26:11)
    at Object.encode (/private/tmp/test/dpt/message.js:56:15)
    at obj.peers.map (/private/tmp/test/dpt/message.js:124:40)
    at Array.map (<anonymous>)
    at Object.encode (/private/tmp/test/dpt/message.js:124:17)
    at Object.<anonymous> (/private/tmp/test/dpt/message.js:168:28)
    at Module._compile (module.js:641:30)
    at Object.Module._extensions..js (module.js:652:10)
    at Module.load (module.js:560:32)
    at tryModuleLoad (module.js:503:12)

after this change:

[ [ [ 'c0a80001', '1f90', '1f90', '31313131' ],
    [ 'c0a80002', '1f90', '1f90', '31313132' ] ],
  '5aaeaa28' ]
{ peers:
   [ { endpoint: [Object], id: <Buffer 31 31 31 31> },
     { endpoint: [Object], id: <Buffer 31 31 31 32> } ],
  timestamp: 1521396264 }

@uneco
Copy link
Author

uneco commented Mar 19, 2018

sorry, I understood that the format of decode and encode are different.

@uneco uneco closed this Mar 19, 2018
@uneco uneco deleted the fix-neighbours-encode branch March 19, 2018 00:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant