Skip to content

Commit 463ec0a

Browse files
committed
fix_eth_unit_test
1 parent 52c5d51 commit 463ec0a

File tree

15 files changed

+8199
-3247
lines changed

15 files changed

+8199
-3247
lines changed

babel.config.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
1+
/** @type {import('@types/babel__core').TransformOptions} */
12
module.exports = {
23
presets: [
34
[
45
'@babel/preset-env',
56
{
67
targets: {
78
node: 'current',
8-
},
9+
}
910
},
1011
],
12+
'@babel/preset-typescript'
1113
],
1214
plugins: [
1315
['@babel/plugin-transform-runtime',

jest.config.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import type {Config} from '@jest/types';
2+
3+
// Sync object
4+
const config: Config.InitialOptions = {
5+
verbose: false,
6+
automock: false,
7+
};
8+
export default config;

package-lock.json

Lines changed: 2676 additions & 918 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,15 @@
22
"name": "root",
33
"private": true,
44
"devDependencies": {
5+
"@babel/core": "^7.16.0",
56
"@babel/plugin-transform-runtime": "^7.8.3",
6-
"@babel/preset-env": "^7.8.6",
7-
"@types/jest": "^25.1.3",
7+
"@babel/preset-env": "^7.16.4",
8+
"@babel/preset-typescript": "^7.16.0",
9+
"@types/babel__core": "^7.1.17",
10+
"@types/jest": "^27.0.3",
811
"@typescript-eslint/eslint-plugin": "^4.10.0",
912
"@typescript-eslint/parser": "^4.10.0",
10-
"babel-jest": "^25.1.0",
13+
"babel-jest": "^27.4.4",
1114
"eslint": "^6.1.0",
1215
"eslint-config-airbnb": "^18.0.1",
1316
"eslint-plugin-import": "^2.19.1",
@@ -31,7 +34,5 @@
3134
"test": "jest"
3235
},
3336
"license": "Apache-2.0",
34-
"dependencies": {
35-
"@coolwallet/core": "0.1.0-beta.25"
36-
}
37+
"dependencies": {}
3738
}

packages/coin-eth/__mocks__/@coolwallet/coin.js

Lines changed: 0 additions & 22 deletions
This file was deleted.
Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,38 @@
11
/* eslint-disable max-len */
2-
export const core = {
3-
util: {
4-
addressIndexToKeyId: jest.fn(() => '3C0000000000'),
2+
class ECDSA {
3+
constructor(transport, appPrivateKey, appId, coinType) {
4+
this.transport = transport;
5+
this.appPrivateKey = appPrivateKey;
6+
this.appId = appId;
7+
this.coinType = coinType;
8+
this.getPublicKey = this.getPublicKey.bind(this);
9+
}
10+
11+
async getPublicKey() {
12+
return '033a057e1f19ea73423bd75f4d391dd28145636081bf0c2674f89fd6d04738f293';
13+
}
14+
}
15+
16+
const core = {
17+
utils: {
18+
getPath: jest.fn(() => '328000002C8000003C800000000000000000000000')
519
},
6-
controller: {
7-
checkSupportScripts: jest.fn(() => false),
20+
coin:{
21+
ECDSACoin: ECDSA,
22+
Coin:{
23+
getAddress: jest.fn(() => Function),
24+
signTransaction: jest.fn(() => Function)
25+
}
826
},
9-
flow: {
10-
prepareSEData: jest.fn(() => Buffer.from('f700003c853c00000000ed82031b84b2d05e0082520c940644de2a0cf3f11ef6ad89c264585406ea346a96880de0b6b3a764000080018080')),
11-
sendDataToCoolWallet: jest.fn(() => ({
12-
r: 'ac1feeae6a0d9c0b6e23152432a270889495dcfc837db978f10000d38102be02',
13-
s: '1570ac1cea178b10c2bc4d1693ba6599c80679eac83c2548234a3ad8e4f117a4'
14-
})),
15-
sendScriptAndDataToCard: jest.fn((transport, appId, appPrivateKey, script) => {
16-
// console.debug(`calling with script ${script}`);
17-
switch (script) {
18-
case transferScript: {
19-
return {
20-
r: '7cce23b352f3c1f11ef4833e76b3b0cb14ca17bb0097d197b307690a551d19ee',
21-
s: '156703269448e84d2a82e07531375896fd6fc6e0478cdda876315611d4cad697',
22-
};
27+
tx:{
28+
flow: {
29+
getSingleSignatureFromCoolWallet: jest.fn(() => {
30+
return{
31+
r: '7cce23b352f3c1f11ef4833e76b3b0cb14ca17bb0097d197b307690a551d19ee',
32+
s: '156703269448e84d2a82e07531375896fd6fc6e0478cdda876315611d4cad697'
2333
}
24-
case erc20Script: {
25-
return {
26-
r: '841b0f25bad78c3544300eb43396c5420b0e7f2eefac97e7c3578790742aaaf3',
27-
s: '625f11b18f9a2e0a8ed786c2b714e6e2fe22bad2a57636905e5a966df98dff6a'
28-
};
29-
}
30-
default: {
31-
return {};
32-
}
33-
}
34-
})
34+
}),
35+
}
3536
}
36-
};
37-
38-
const transferScript = '03000601C707000000003CCC0710C0C2ACD70032FFF8C2ACD7001EFFF6C2ACD70028FFF6CC071094CAA02700C2A2D700FFF6CC071080C2ACD7003AFFFECC07C0028080C3709710D107C03CCC0FC0023078BAA02F6C0E01DDF09700DAA2D7C0FFF612D207CC05065052455353425554546f4e00304502201F5179C4FAAFA09B28C57FA9D7DFC1BB1D9C582A98ECEE0A474DC00B536BC72B0221008ADD665FF6BDFE10A8168CA5F37E054C6101184D0375F1E795D8CD671542AA0E';
39-
const erc20Script = '03000601C707000000003CCC07C002F800C2ACD70034FFF8C2A5D700FFF6C2ACD7002AFFF6CC071094CAAC270047CC07C01380B844a9059cbb000000000000000000000000CAA02700CC07200000000000000000000000000000000000000000CAA2C7000CC2ACD7003CFFFECC07C0028080C37097C00211ACC7CC3E1D045B1507C004CC0F104012AC17C03F0401071507C002FF00B5AC17003FCAA6BF00DEF09700250F00CC0FC0023078BAA02F6C0E01DDF0970012AC17C03E0400141507C002FF00B5AC17003EDAA2C7B00CD207CC05065052455353425554546f4efa0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000';
37+
}
38+
module.exports = core;

0 commit comments

Comments
 (0)