-
Notifications
You must be signed in to change notification settings - Fork 1
/
addon.js
60 lines (52 loc) · 1.34 KB
/
addon.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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
'use strict'
const { Session } = require('bindings')('addon')
const usb_connection = "yhusb://"
const connector_connection = "http://127.0.0.1:12345"
const { performance } = require('perf_hooks')
async function main() {
const config = {
url: usb_connection,
password: "password",
// authkey: 39106,
authkey: 1,
}
const ecdh_key_id = 22096
const session = new Session(config)
await session.open()
try {
// const keys = await session.getKeys()
const a = performance.now()
// const keys = await session.ecdh(ecdh_key_id, "EOS6UqHJB1A58qPS4yUbV1ZNkhETFo6F7bAuhrDXvpEq95Jq94LdC")
const keys = await session.getKeys()
const b = performance.now()
console.log("Keys: ", keys)
console.log(`ECDH took ${b-a} milliseconds`)
} catch(e) {
console.log("Error: ", e.message)
}
// session.close()
}
main()
async function test() {
const config = {
url: usb_connection,
password: "password",
authkey: 1,
}
const session = new Session(config)
const response = await session.test("ohai")
console.log("Response: ", response)
}
// test()
/*
* Test if destructor is getting called
*/
function forceGC() {
if (global.gc) {
global.gc();
} else {
console.warn('No GC hook! Start your program as `node --expose-gc ./addon.js`.');
}
}
// forceGC();
// setTimeout(forceGC, 1000);