-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
30 lines (26 loc) · 866 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
const createHirezSignature = require('./index.js');
const TESTS = [
{
devId: '1004',
methodName: 'getPlayer',
authKey: '23DF3C7E9BD14D84BF892AD206B6755C',
timestamp: '20120927183145',
signature: 'e4b75aac6c70059578adeb7fa2bbf504'
},
{
devId: '1004',
methodName: 'getPlayer',
authKey: '23DF3C7E9BD14D84BF892AD206B6755C',
timestamp: '20200619161618',
signature: 'ea665b5a12673d05896524511fe201fd'
}
];
async function test() {
for (let t of TESTS) {
const { signature, timestamp } = await createHirezSignature(t.devId, t.methodName, t.authKey, t.timestamp);
if (signature !== t.signature) throw new Error(`Signature for ${t.methodName}[${t.devId}] is wrong ${signature}!=${t.signature}`);
}
console.log('All tests passed');
}
if (!require.parent) test().then(null,console.error);
module.exports = test;