@onekeyfe/hd-transport-electron 1.2.8-alpha.132 → 1.2.8-alpha.133
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/hd-transport-electron",
|
|
3
|
-
"version": "1.2.8-alpha.
|
|
3
|
+
"version": "1.2.8-alpha.133",
|
|
4
4
|
"author": "OneKey",
|
|
5
5
|
"homepage": "https://github.com/OneKeyHQ/hardware-js-sdk#readme",
|
|
6
6
|
"license": "MIT",
|
|
@@ -25,9 +25,9 @@
|
|
|
25
25
|
"electron-log": ">=4.0.0"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@onekeyfe/hd-core": "1.2.8-alpha.
|
|
29
|
-
"@onekeyfe/hd-shared": "1.2.8-alpha.
|
|
30
|
-
"@onekeyfe/hd-transport": "1.2.8-alpha.
|
|
28
|
+
"@onekeyfe/hd-core": "1.2.8-alpha.133",
|
|
29
|
+
"@onekeyfe/hd-shared": "1.2.8-alpha.133",
|
|
30
|
+
"@onekeyfe/hd-transport": "1.2.8-alpha.133",
|
|
31
31
|
"@stoprocent/noble": "2.3.16",
|
|
32
32
|
"p-retry": "^4.6.2"
|
|
33
33
|
},
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"electron": "^25.0.0",
|
|
37
37
|
"typescript": "^5.3.3"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "c859b88e03cf7a80e3168ab048fd1af6cb286af6"
|
|
40
40
|
}
|
|
@@ -1681,3 +1681,76 @@ describe('Electron Noble BLE advertisement color', () => {
|
|
|
1681
1681
|
]);
|
|
1682
1682
|
});
|
|
1683
1683
|
});
|
|
1684
|
+
|
|
1685
|
+
describe('Noble synchronous native connection failures', () => {
|
|
1686
|
+
test.each(['direct', 'peripheral'] as const)(
|
|
1687
|
+
'releases %s async connection listeners and permits a subsequent retry',
|
|
1688
|
+
async entry => {
|
|
1689
|
+
const Noble = jest.requireActual('@stoprocent/noble/lib/noble');
|
|
1690
|
+
const error = new Error('Peripheral could not be retrieved for connection');
|
|
1691
|
+
const bindings = { connect: jest.fn() };
|
|
1692
|
+
const noble = new Noble(bindings);
|
|
1693
|
+
noble.removeAllListeners('warning');
|
|
1694
|
+
noble.on('warning', jest.fn());
|
|
1695
|
+
const deviceId = 'aabbccddeeff';
|
|
1696
|
+
const peripheral =
|
|
1697
|
+
entry === 'peripheral'
|
|
1698
|
+
? noble._createPeripheral(deviceId, '', '', true, {}, 0, true)
|
|
1699
|
+
: undefined;
|
|
1700
|
+
bindings.connect.mockImplementationOnce(() => {
|
|
1701
|
+
throw error;
|
|
1702
|
+
});
|
|
1703
|
+
|
|
1704
|
+
await expect(
|
|
1705
|
+
entry === 'direct' ? noble.connectAsync(deviceId) : peripheral.connectAsync()
|
|
1706
|
+
).rejects.toBe(error);
|
|
1707
|
+
expect(noble.listenerCount(`connect:${deviceId}`)).toBe(0);
|
|
1708
|
+
expect(noble._exclusiveCallbacks?.size ?? 0).toBe(0);
|
|
1709
|
+
if (peripheral) {
|
|
1710
|
+
expect(peripheral.state).toBe('error');
|
|
1711
|
+
expect(peripheral.listenerCount('connect')).toBe(0);
|
|
1712
|
+
expect(peripheral._exclusiveCallbacks.size).toBe(0);
|
|
1713
|
+
}
|
|
1714
|
+
|
|
1715
|
+
const retryPeripheral =
|
|
1716
|
+
peripheral ?? noble._createPeripheral(deviceId, '', '', true, {}, 0, true);
|
|
1717
|
+
const retry =
|
|
1718
|
+
entry === 'direct' ? noble.connectAsync(deviceId) : retryPeripheral.connectAsync();
|
|
1719
|
+
noble._onConnect(deviceId);
|
|
1720
|
+
await retry;
|
|
1721
|
+
expect(retryPeripheral.state).toBe('connected');
|
|
1722
|
+
expect(bindings.connect).toHaveBeenCalledTimes(2);
|
|
1723
|
+
expect(noble.listenerCount(`connect:${deviceId}`)).toBe(0);
|
|
1724
|
+
expect(retryPeripheral.listenerCount('connect')).toBe(0);
|
|
1725
|
+
}
|
|
1726
|
+
);
|
|
1727
|
+
|
|
1728
|
+
test.each(['direct', 'peripheral'] as const)(
|
|
1729
|
+
'settles the %s callback once when the binding throws',
|
|
1730
|
+
entry => {
|
|
1731
|
+
const Noble = jest.requireActual('@stoprocent/noble/lib/noble');
|
|
1732
|
+
const error = new Error('Peripheral could not be retrieved for connection');
|
|
1733
|
+
const noble = new Noble({
|
|
1734
|
+
connect: () => {
|
|
1735
|
+
throw error;
|
|
1736
|
+
},
|
|
1737
|
+
});
|
|
1738
|
+
const deviceId = 'aabbccddeeff';
|
|
1739
|
+
const peripheral = noble._createPeripheral(deviceId, '', '', true, {}, 0, true);
|
|
1740
|
+
const callback = jest.fn();
|
|
1741
|
+
|
|
1742
|
+
expect(() =>
|
|
1743
|
+
entry === 'direct'
|
|
1744
|
+
? noble.connect(deviceId, undefined, callback)
|
|
1745
|
+
: peripheral.connect(undefined, callback)
|
|
1746
|
+
).not.toThrow();
|
|
1747
|
+
expect(callback).toHaveBeenCalledTimes(1);
|
|
1748
|
+
expect(callback.mock.calls[0][0]).toBe(error);
|
|
1749
|
+
expect(peripheral.state).toBe('error');
|
|
1750
|
+
expect(noble.listenerCount(`connect:${deviceId}`)).toBe(0);
|
|
1751
|
+
expect(peripheral.listenerCount('connect')).toBe(0);
|
|
1752
|
+
noble._onConnect(deviceId, error);
|
|
1753
|
+
expect(callback).toHaveBeenCalledTimes(1);
|
|
1754
|
+
}
|
|
1755
|
+
);
|
|
1756
|
+
});
|