Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// not locally stored record
expect(err.code).to.equal('ERR_NOT_FOUND')
})
await waitForPeerToSubscribe(subsTopic, peerIdB, pubsubA)
// subscribe in order to understand when the message arrive to the node
await pubsubB.subscribe(subsTopic, messageHandler)
await dsPubsubA.put(key, serializedRecord)
// wait until message arrives
await waitFor(() => receivedMessage === true)
// get from datastore
const result = await dsPubsubB.get(keyNew)
const receivedRecord = Record.deserialize(result)
expect(receivedRecord.value.toString()).to.equal(value)
})
validate: (data) => {
const receivedRecord = Record.deserialize(data)
expect(receivedRecord.value.toString()).to.equal(value) // validator should deserialize correctly
return receivedRecord.value.toString() === value
},
select: () => {
let routingKey
try {
routingKey = this._routingKey(key)
} catch (err) {
log.error(err)
throw errcode(new Error('Not possible to generate the routing key'), 'ERR_GENERATING_ROUTING_KEY')
}
const res = await this._repo.datastore.get(routingKey)
// Unmarshal libp2p record as the DHT does
let record
try {
record = Record.deserialize(res)
} catch (err) {
log.error(err)
throw (err)
}
return record.value
}