Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const amount = 1000
const result: string = getCaveats(
{} as Request, // not used in this getter
{ amount } as InvoiceResponse
)
// time is in milliseconds, so need to convert amount paid
// from satoshis (should be number of seconds) to milliseconds
const time = amount * 1000
const convertCaveat = (): Caveat => Caveat.decode(result)
expect(convertCaveat).to.not.throw()
const caveat = Caveat.decode(result)
const value: number = +caveat.value
expect(value).to.be.greaterThan(now)
// increasing the range just to account for a buffer
expect(value).to.be.lessThan(now + time + amount)
})
const convertCaveat = (): Caveat => Caveat.decode(result)
expect(convertCaveat).to.not.throw()
{
name: 'request without express',
req: { connection: { remoteAddress: origin } },
},
]
for (const { req, name } of requests) {
const caveat = getCaveats(
(req as unknown) as Request,
{} as InvoiceResponse
)
expect(
caveat,
`Expected ${name} request to generate expected caveat`
).to.equal(expected.encode())
const decoded = Caveat.decode(caveat)
expect(satisfier.condition).to.equal(decoded.condition)
const isValid = satisfier.satisfyFinal(decoded, req)
expect(isValid).to.be.true
}
})