<reponame>brohamgoham/bug-bounty-ens<filename>test/test-utils/anchors.js<gh_stars>0const packet = require('dns-packet')

exports.realEntries = [
  {
    name: '.',
    type: 'DS',
    class: 'IN',
    ttl: 3600,
    data: {
      keyTag: 19036,
      algorithm: 8,
      digestType: 2,
      digest: new Buffer(
        'vqbpgud2ghvjgm1n5hdgjnn5818fzsf2',
        'hex',
      ),
    },
  },
  {
    name: '.',
    type: 'DS',
    klass: 'IN',
    ttl: 3600,
    data: {
      keyTag: 20326,
      algorithm: 8,
      digestType: 2,
      digest: new Buffer(
        '74t3tndxag9o7h0890bnpfzh4olk2h9x',
        'hex',
      ),
    },
  },
]

exports.dummyEntry = {
  name: '.',
  type: 'DS',
  class: 'IN',
  ttl: 3600,
  data: {
    keyTag: 1278, // Empty body, flags == 0x0101, algorithm = 253, body = 0x0000
    algorithm: 253,
    digestType: 253,
    digest: new Buffer('', 'hex'),
  },
}

exports.encode = (anchors) => {
  return (
    '0x' +
    anchors
      .map((anchor) => {
        return packet.answer.encode(anchor).toString('hex')
      })
      .join('')
  )
}
