-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add optional param k1 for lnurl (#61)
* feat: add optional param k1 for lnurl * Added unit tests for Server.generateNewUrl Remove async/await syntax --------- Co-authored-by: Charles Hill <[email protected]>
- Loading branch information
1 parent
0d1e6cc
commit 966f5bd
Showing
2 changed files
with
59 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const assert = require('assert'); | ||
const querystring = require('querystring'); | ||
const url = require('url'); | ||
const { validParams } = require('../../../fixtures'); | ||
|
||
describe('generateNewUrl(tag, params[, options])', function() { | ||
|
||
let server; | ||
before(function() { | ||
server = this.helpers.createServer({ | ||
listen: false, | ||
lightning: null, | ||
}); | ||
return server.onReady(); | ||
}); | ||
|
||
after(function() { | ||
if (server) return server.close(); | ||
}); | ||
|
||
it('withdrawRequest', function() { | ||
const tag = 'withdrawRequest'; | ||
const params = Object.assign({}, validParams['create'][tag]); | ||
return server.generateNewUrl(tag, params).then(result => { | ||
assert.ok(result && typeof result === 'object'); | ||
assert.ok(result.encoded); | ||
assert.ok(result.secret); | ||
assert.ok(result.url); | ||
const parsed = url.parse(result.url); | ||
const query = querystring.parse(parsed.query); | ||
assert.strictEqual(query.q, result.secret); | ||
return server.generateNewUrl(tag, params).then(result2 => { | ||
assert.notStrictEqual(result2.secret, result.secret); | ||
}); | ||
}); | ||
}); | ||
|
||
it('pre-defined secret (k1)', function() { | ||
const tag = 'withdrawRequest'; | ||
const params = Object.assign({}, validParams['create'][tag], { | ||
k1: 'pre-defined 12345', | ||
}); | ||
return server.generateNewUrl(tag, params).then(result => { | ||
assert.ok(result && typeof result === 'object'); | ||
assert.ok(result.encoded); | ||
assert.ok(result.secret); | ||
assert.ok(result.url); | ||
const parsed = url.parse(result.url); | ||
const query = querystring.parse(parsed.query); | ||
assert.strictEqual(query.q, result.secret); | ||
assert.strictEqual(result.secret, params.k1); | ||
}); | ||
}); | ||
}); |