Skip to content

Commit 65e7413

Browse files
committed
Fix unit tests
1 parent 1d0d523 commit 65e7413

File tree

8 files changed

+51
-26
lines changed

8 files changed

+51
-26
lines changed

.github/workflows/ci-master.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
run: yarn lint
3333

3434
- name: Run tests
35-
run: yarn run jest
35+
run: yarn test:unit
3636

3737
- name: Compile lib
3838
run: yarn compile

__tests__/api-tests/sdk.spec.ts

Lines changed: 0 additions & 9 deletions
This file was deleted.

__tests__/unit-tests/core/.gitkeep

Whitespace-only changes.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import { SDK } from 'src/core/sdk/sdk';
2+
import { freeRpc } from '__tests__/utils/constants/free-rpc';
3+
import { Configuration } from 'src/core/sdk/models/configuration';
4+
5+
describe('Common SDK tests', () => {
6+
const minimalConfig: Configuration = { rpcProviders: freeRpc };
7+
8+
test('Should create sdk instance', async () => {
9+
const sdk = await SDK.createSDK(minimalConfig);
10+
expect(typeof sdk).toBe('object');
11+
});
12+
});

__tests__/utils/constants/free-rpc.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import {
2+
BLOCKCHAIN_NAME,
3+
EvmBlockchainName,
4+
TronBlockchainName
5+
} from 'src/core/blockchain/models/blockchain-name';
6+
import { TronWebProvider } from 'src/core/blockchain/web3-public-service/web3-public/tron-web3-public/models/tron-web-provider';
7+
import { RpcProvider } from 'src/core/sdk/models/rpc-provider';
8+
9+
export const freeRpc: Partial<
10+
Record<EvmBlockchainName, RpcProvider<string>> &
11+
Record<TronBlockchainName, RpcProvider<TronWebProvider>>
12+
> = {
13+
[BLOCKCHAIN_NAME.ETHEREUM]: {
14+
rpcList: ['https://rpc.ankr.com/eth']
15+
},
16+
[BLOCKCHAIN_NAME.BINANCE_SMART_CHAIN]: {
17+
rpcList: ['https://bsc-dataseed.binance.org']
18+
},
19+
[BLOCKCHAIN_NAME.POLYGON]: {
20+
rpcList: ['https://polygon-rpc.com']
21+
},
22+
[BLOCKCHAIN_NAME.TRON]: {
23+
rpcList: [
24+
{
25+
fullHost: 'https://rpc.ankr.com/http/tron'
26+
}
27+
]
28+
}
29+
};

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
"create-index": "cti entrypoint ./src --withoutbackup && renamer -f \"/^entrypoint/\" -r \"index\" \"./src/*\" --force",
5858
"delete-index": "npx rimraf ./src/index.ts",
5959
"test": "cd ./scripts && bash test-runner.sh",
60+
"test:unit": "yarn jest ./__tests__/unit-tests",
6061
"build:publish": "yarn compile && yarn build && npm publish --access public",
6162
"analyze": "webpack --profile --json > stats.json && webpack-bundle-analyzer stats.json",
6263
"docs": "yarn create-index && typedoc && yarn delete-index",
@@ -116,9 +117,8 @@
116117
"ts-loader": "^9.3.0",
117118
"tsconfig-paths-webpack-plugin": "^3.5.2",
118119
"tscpaths": "^0.0.9",
119-
"ttypescript": "^1.5.13",
120120
"typedoc": "^0.23.21",
121-
"typescript": "~4.8.3",
121+
"typescript": "^4.9.4",
122122
"typescript-transform-paths": "^3.3.1",
123123
"url": "^0.11.0",
124124
"webpack": "^5.65.0",

tsconfig.test.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"experimentalDecorators": true,
1414
"esModuleInterop": true,
1515
"allowSyntheticDefaultImports": true,
16-
"target": "ESNext",
16+
"target": "es2020",
1717
"strict": true,
1818
"noImplicitAny": true,
1919
"strictNullChecks": true,

yarn.lock

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1995,7 +1995,7 @@ axios@^1.1.3:
19951995
follow-redirects "^1.15.0"
19961996
form-data "^4.0.0"
19971997
proxy-from-env "^1.1.0"
1998-
1998+
19991999
babel-jest@^29.3.1:
20002000
version "29.3.1"
20012001
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-29.3.1.tgz#05c83e0d128cd48c453eea851482a38782249f44"
@@ -6505,7 +6505,7 @@ resolve.exports@^1.1.0:
65056505
resolved "https://registry.yarnpkg.com/resolve.exports/-/resolve.exports-1.1.0.tgz#5ce842b94b05146c0e03076985d1d0e7e48c90c9"
65066506
integrity sha512-J1l+Zxxp4XK3LUDZ9m60LRJF/mAe4z6a4xyabPHk7pvK5t35dACV32iIjJDFeWZFfZlO29w6SZ67knR0tHzJtQ==
65076507

6508-
resolve@>=1.9.0, resolve@^1.20.0, resolve@^1.22.0, resolve@^1.9.0:
6508+
resolve@^1.20.0, resolve@^1.22.0, resolve@^1.9.0:
65096509
version "1.22.1"
65106510
resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.22.1.tgz#27cb2ebb53f91abb49470a928bba7558066ac177"
65116511
integrity sha512-nBpuuYuY5jFsli/JIs1oldw6fOQCBioohqWZg/2hiaOybXOft4lonv85uDOKXdf8rhyK159cxU5cDcK/NKk8zw==
@@ -7342,13 +7342,6 @@ tsutils@^3.21.0:
73427342
dependencies:
73437343
tslib "^1.8.1"
73447344

7345-
ttypescript@^1.5.13:
7346-
version "1.5.13"
7347-
resolved "https://registry.yarnpkg.com/ttypescript/-/ttypescript-1.5.13.tgz#c3bcb760599fe49157d30c5d5895a0023cbb7f30"
7348-
integrity sha512-KT/RBfGGlVJFqEI8cVvI3nMsmYcFvPSZh8bU0qX+pAwbi7/ABmYkzn7l/K8skw0xmYjVCoyaV6WLsBQxdadybQ==
7349-
dependencies:
7350-
resolve ">=1.9.0"
7351-
73527345
tunnel-agent@^0.6.0:
73537346
version "0.6.0"
73547347
resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd"
@@ -7425,10 +7418,10 @@ typescript-transform-paths@^3.3.1:
74257418
dependencies:
74267419
minimatch "^3.0.4"
74277420

7428-
typescript@~4.8.3:
7429-
version "4.8.4"
7430-
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.8.4.tgz#c464abca159669597be5f96b8943500b238e60e6"
7431-
integrity sha512-QCh+85mCy+h0IGff8r5XWzOVSbBO+KfeYrMQh7NJ58QujwcE22u+NUSmUxqF+un70P9GXKxa2HCNiTTMJknyjQ==
7421+
typescript@^4.9.4:
7422+
version "4.9.4"
7423+
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.4.tgz#a2a3d2756c079abda241d75f149df9d561091e78"
7424+
integrity sha512-Uz+dTXYzxXXbsFpM86Wh3dKCxrQqUcVMxwU54orwlJjOpO3ao8L7j5lH+dWfTwgCwIuM9GQ2kvVotzYJMXTBZg==
74327425

74337426
typical@^4.0.0:
74347427
version "4.0.0"

0 commit comments

Comments
 (0)