UNPKG

balanceofsatoshis

Version:
33 lines (27 loc) 1.05 kB
const {equal} = require('node:assert').strict; const test = require('node:test'); const {derAsPem} = require('./../../encryption'); const tests = [ { args: {cert: Buffer.from('6b3V+MpX+++++++ENDCERTIFICATE+++++++', 'base64').toString('hex')}, description: 'A DER is mapped to a PEM string', expected: {pem: '-----BEGIN CERTIFICATE-----\n6b3V+MpX\n-----END CERTIFICATE-----'}, }, { args: {cert: Buffer.from('6b3V+MpX', 'base64').toString('hex')}, description: 'A DER is mapped to a PEM string', expected: {pem: '-----BEGIN CERTIFICATE-----\n6b3V+MpX\n-----END CERTIFICATE-----'}, }, { args: {key: Buffer.from('6b3V+MpX', 'base64').toString('hex')}, description: 'A DER is mapped to a PEM string', expected: {pem: '-----BEGIN PUBLIC KEY-----\n6b3V+MpX\n-----END PUBLIC KEY-----'}, }, ]; tests.forEach(({args, description, error, expected}) => { return test(description, (t, end) => { const {pem} = derAsPem(args); equal(pem, expected.pem, 'Got expected pem'); return end(); }); });