Skip to content

Commit 74cc411

Browse files
gpBlockchainyanguoyu
authored andcommitted
wip: add sync test for dev node (#2997)
Co-authored-by: gpBlockchain
1 parent 432f0ec commit 74cc411

40 files changed

+1818
-0
lines changed

.github/workflows/package_for_test.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,81 @@ jobs:
238238
comment-id: ${{ github.event.comment.id }}
239239
body: Packageing failed in [${{ github.run_id }}](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}). @${{ github.event.comment.user.login }}
240240
edit-mode: append
241+
242+
sync-test:
243+
needs: [packaging]
244+
strategy:
245+
matrix:
246+
node:
247+
- 18.12.0
248+
os:
249+
- macos-latest
250+
- ubuntu-20.04
251+
- windows-2019
252+
253+
runs-on: ${{ matrix.os }}
254+
255+
name: ${{ matrix.os }}(Node.js ${{ matrix.node }})
256+
257+
steps:
258+
- name: Checkout
259+
uses: actions/checkout@v3
260+
261+
262+
- name: Install libudev
263+
if: matrix.os == 'ubuntu-20.04'
264+
run: |
265+
sudo apt-get update
266+
sudo apt-get install -y libudev-dev
267+
- name: Download Neuron App Zip(arm64)
268+
if: matrix.os == 'macos-latest'
269+
uses: actions/download-artifact@v4
270+
with:
271+
name: Neuron-Mac-arm64
272+
path: packages/sync-test
273+
274+
- name: Download Neuron Win
275+
if: matrix.os == 'windows-2019'
276+
uses: actions/download-artifact@v4
277+
with:
278+
name: Neuron-Win
279+
path: packages/sync-test
280+
281+
- name: Download Neuron Linux
282+
if: matrix.os == 'ubuntu-20.04'
283+
uses: actions/download-artifact@v4
284+
with:
285+
name: Neuron-Linux
286+
path: packages/sync-test
287+
288+
- name: macos run
289+
if: matrix.os == 'macos-latest'
290+
run: |
291+
cd packages/sync-test
292+
yarn
293+
bash scripts/prepare_neuron_macos.sh
294+
yarn sync-test
295+
- name: Windows run
296+
if: matrix.os == 'windows-2019'
297+
run: |
298+
cd packages\sync-test
299+
yarn
300+
.\scripts\prepare_neuron_windows.bat
301+
yarn sync-test
302+
- name: ubuntu run
303+
if: matrix.os == 'ubuntu-20.04'
304+
run: |
305+
cd packages/sync-test
306+
yarn
307+
bash scripts/prepare_neuron_linux.sh
308+
xvfb-run --auto-servernum yarn sync-test
309+
- name: tar result
310+
if: always()
311+
run: |
312+
tar -zcvf tmp.${{ matrix.os }}.tar.gz packages/sync-test/tmp
313+
- name: Publish reports
314+
if: failure()
315+
uses: actions/upload-artifact@v3
316+
with:
317+
name: jfoa-build-reports-${{ runner.os }}
318+
path: tmp.${{ matrix.os }}.tar.gz

packages/sync-test/.eslintignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
jest.config.js

packages/sync-test/.eslintrc.js

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
module.exports = {
2+
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
3+
settings: {
4+
'import/resolver': {
5+
node: {
6+
paths: ['src'],
7+
extensions: ['.js', '.ts'],
8+
},
9+
},
10+
},
11+
env: {
12+
es6: true,
13+
node: true,
14+
browser: true,
15+
jest: true,
16+
},
17+
globals: {
18+
BigInt: 'readonly',
19+
},
20+
rules: {
21+
// TODO: Some temporarily disabled rules will be re-enabled later, considering that many files are affected and will be addressed in the future.
22+
'@typescript-eslint/no-explicit-any': 'off',
23+
'@typescript-eslint/no-non-null-assertion': 'off',
24+
'prefer-const': 'off',
25+
26+
// This is the configuration that was set when using eslint-plugin-prettier
27+
// https://github.com/prettier/eslint-plugin-prettier#arrow-body-style-and-prefer-arrow-callback-issue
28+
'arrow-body-style': 'off',
29+
'prefer-arrow-callback': 'off',
30+
31+
// TypeScript support
32+
'@typescript-eslint/no-unused-vars': [
33+
'error',
34+
{
35+
argsIgnorePattern: '^_',
36+
},
37+
],
38+
39+
// Unnecessary rules
40+
'no-plusplus': 'off',
41+
'max-classes-per-file': 'off',
42+
'@typescript-eslint/no-inferrable-types': 'off',
43+
'@typescript-eslint/no-empty-function': 'off',
44+
'@typescript-eslint/ban-ts-comment': 'warn',
45+
'no-console': 'off',
46+
// Adjusted rules
47+
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
48+
},
49+
overrides: [
50+
{
51+
files: ['*.test.ts', '*.test.tsx'],
52+
rules: {
53+
'@typescript-eslint/ban-ts-comment': 'off',
54+
'@typescript-eslint/no-var-requires': 'off',
55+
'no-console': 'off',
56+
},
57+
},
58+
],
59+
}

packages/sync-test/.prettierrc.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module.exports = {
2+
tabWidth: 2,
3+
useTabs: false,
4+
printWidth: 120,
5+
trailingComma: 'es5',
6+
semi: false,
7+
singleQuote: true,
8+
// TODO: This is the previous legacy configuration, should use the default settings, considering that more files are affected, and will be dealt with later.
9+
// https://prettier.io/blog/2020/03/21/2.0.0.html#change-default-value-for-arrowparens-to-always-7430httpsgithubcomprettierprettierpull7430-by-kachkaevhttpsgithubcomkachkaev
10+
arrowParens: 'avoid',
11+
}

packages/sync-test/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# sync-test
2+
3+
notice: will remove your neuron config data
4+
5+
```shell
6+
./scripts/prepare_neuron_macos.sh
7+
yarn
8+
yarn test
9+
```

packages/sync-test/jest.config.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
process.env = Object.assign(process.env, { NODE_ENV: undefined })
2+
3+
module.exports = {
4+
displayName: 'Unit Tests',
5+
preset: 'ts-jest',
6+
testEnvironment: 'node',
7+
testRegex: '(/tests/.*.(test|spec))\\.(ts?|js?)$',
8+
transform: {
9+
'^.+\\.ts?$': 'ts-jest',
10+
},
11+
roots: ['<rootDir>/src/'],
12+
moduleDirectories: ['node_modules', 'src'],
13+
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
14+
// setupFiles: ['<rootDir>/tests/setup.ts'],
15+
moduleNameMapper: {
16+
// FIXME: module mapper causes typeorm errors
17+
// "electron": "<rootDir>/tests/mock/electron.ts",
18+
// "logger": "<rootDir>/tests/mock/logger",
19+
},
20+
testTimeout: 1800000,
21+
}

packages/sync-test/package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "sync-test",
3+
"productName": "Neuron",
4+
"description": "CKB Neuron Wallet",
5+
"homepage": "https://www.nervos.org/",
6+
"version": "0.112.0",
7+
"private": true,
8+
"author": {
9+
"name": "Nervos Core Dev",
10+
"email": "[email protected]",
11+
"url": "https://github.com/nervosnetwork/neuron"
12+
},
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/nervosnetwork/neuron"
16+
},
17+
"scripts": {
18+
"sync-test": "jest demo.test.ts"
19+
},
20+
"dependencies": {
21+
"@types/tar": "6.1.10"
22+
}
23+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#wget http://github-test-logs.ckbapp.dev/neuron/sync/Neuron-v0.111.1-x86_64.AppImage
2+
cp Neuron-*.AppImage Neuron.AppImage
3+
chmod 777 Neuron.AppImage
4+
./Neuron.AppImage --appimage-extract
5+
mkdir neuron
6+
mv squashfs-root neuron
7+
cp -r neuron/squashfs-root/bin source/
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#wget http://github-test-logs.ckbapp.dev/neuron/sync/Neuron-v0.111.1-mac-x64.zip
2+
cp Neuron*.zip Neuron.zip
3+
unzip Neuron.zip
4+
mv Neuron.app neuron
5+
chmod 777 neuron/Contents
6+
cp -r neuron/Contents/bin source/
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
@REM curl -O -L http://github-test-logs.ckbapp.dev/neuron/sync/Neuron-v0.111.1-setup.exe
2+
copy .\Neuron-*.exe Neuron-setup.exe
3+
@echo off
4+
REM 执行安装程序
5+
.\Neuron-setup.exe /S /D=D:\a\neuron\neuron\packages\sync-test\neuron
6+
7+
REM 等待进程执行结束
8+
:CHECK_LOOP
9+
tasklist | find "Neuron-setup.exe" > nul
10+
if errorlevel 1 (
11+
echo Neuron install succ
12+
mkdir ".\source\bin"
13+
copy ".\neuron\bin\ckb.exe" ".\source\bin\ckb.exe"
14+
copy ".\neuron\bin\ckb-light-client.exe" ".\source\bin\ckb-light-client.exe"
15+
exit /b 0
16+
) else (
17+
timeout /t 5 /nobreak > nul
18+
goto :CHECK_LOOP
19+
)

0 commit comments

Comments
 (0)