Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions .github/workflows/package_for_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,81 @@ jobs:
comment-id: ${{ github.event.comment.id }}
body: Packageing failed in [${{ github.run_id }}](https://github.com/${{github.repository}}/actions/runs/${{github.run_id}}). @${{ github.event.comment.user.login }}
edit-mode: append

sync-test:
needs: [packaging]
strategy:
matrix:
node:
- 18.12.0
os:
- macos-latest
- ubuntu-20.04
- windows-2019

runs-on: ${{ matrix.os }}

name: ${{ matrix.os }}(Node.js ${{ matrix.node }})

steps:
- name: Checkout
uses: actions/checkout@v3


- name: Install libudev
if: matrix.os == 'ubuntu-20.04'
run: |
sudo apt-get update
sudo apt-get install -y libudev-dev
- name: Download Neuron App Zip(arm64)
if: matrix.os == 'macos-latest'
uses: actions/download-artifact@v3
with:
name: Neuron-Mac-arm64
path: packages/sync-test

- name: Upload Neuron Win
if: matrix.os == 'windows-2019'
uses: actions/download-artifact@v3
with:
name: Neuron-Win
path: packages/sync-test

- name: Upload Neuron Linux
if: matrix.os == 'ubuntu-20.04'
uses: actions/download-artifact@v3
with:
name: Neuron-Linux
path: packages/sync-test

- name: macos run
if: matrix.os == 'macos-latest'
run: |
cd packages/sync-test
yarn
bash scripts/prepare_neuron_macos.sh
yarn sync-test
- name: Windows run
if: matrix.os == 'windows-2019'
run: |
cd packages\sync-test
yarn
.\scripts\prepare_neuron_windows.bat
yarn sync-test
- name: ubuntu run
if: matrix.os == 'ubuntu-20.04'
run: |
cd packages/sync-test
yarn
bash scripts/prepare_neuron_linux.sh
xvfb-run --auto-servernum yarn sync-test
- name: tar result
if: always()
run: |
tar -zcvf tmp.${{ matrix.os }}.tar.gz packages/sync-test/tmp
- name: Publish reports
if: failed()
uses: actions/upload-artifact@v3
with:
name: jfoa-build-reports-${{ runner.os }}
path: tmp.${{ matrix.os }}.tar.gz
1 change: 1 addition & 0 deletions packages/sync-test/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
jest.config.js
59 changes: 59 additions & 0 deletions packages/sync-test/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module.exports = {
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'],
settings: {
'import/resolver': {
node: {
paths: ['src'],
extensions: ['.js', '.ts'],
},
},
},
env: {
es6: true,
node: true,
browser: true,
jest: true,
},
globals: {
BigInt: 'readonly',
},
rules: {
// TODO: Some temporarily disabled rules will be re-enabled later, considering that many files are affected and will be addressed in the future.
'@typescript-eslint/no-explicit-any': 'off',
'@typescript-eslint/no-non-null-assertion': 'off',
'prefer-const': 'off',

// This is the configuration that was set when using eslint-plugin-prettier
// https://github.com/prettier/eslint-plugin-prettier#arrow-body-style-and-prefer-arrow-callback-issue
'arrow-body-style': 'off',
'prefer-arrow-callback': 'off',

// TypeScript support
'@typescript-eslint/no-unused-vars': [
'error',
{
argsIgnorePattern: '^_',
},
],

// Unnecessary rules
'no-plusplus': 'off',
'max-classes-per-file': 'off',
'@typescript-eslint/no-inferrable-types': 'off',
'@typescript-eslint/no-empty-function': 'off',
'@typescript-eslint/ban-ts-comment': 'warn',
'no-console': 'off',
// Adjusted rules
'lines-between-class-members': ['error', 'always', { exceptAfterSingleLine: true }],
},
overrides: [
{
files: ['*.test.ts', '*.test.tsx'],
rules: {
'@typescript-eslint/ban-ts-comment': 'off',
'@typescript-eslint/no-var-requires': 'off',
'no-console': 'off',
},
},
],
}
11 changes: 11 additions & 0 deletions packages/sync-test/.prettierrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module.exports = {
tabWidth: 2,
useTabs: false,
printWidth: 120,
trailingComma: 'es5',
semi: false,
singleQuote: true,
// TODO: This is the previous legacy configuration, should use the default settings, considering that more files are affected, and will be dealt with later.
// https://prettier.io/blog/2020/03/21/2.0.0.html#change-default-value-for-arrowparens-to-always-7430httpsgithubcomprettierprettierpull7430-by-kachkaevhttpsgithubcomkachkaev
arrowParens: 'avoid',
}
9 changes: 9 additions & 0 deletions packages/sync-test/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# sync-test

notice: will remove your neuron config data

```shell
./scripts/prepare_neuron_macos.sh
yarn
yarn test
```
21 changes: 21 additions & 0 deletions packages/sync-test/jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
process.env = Object.assign(process.env, { NODE_ENV: undefined })

module.exports = {
displayName: 'Unit Tests',
preset: 'ts-jest',
testEnvironment: 'node',
testRegex: '(/tests/.*.(test|spec))\\.(ts?|js?)$',
transform: {
'^.+\\.ts?$': 'ts-jest',
},
roots: ['<rootDir>/src/'],
moduleDirectories: ['node_modules', 'src'],
moduleFileExtensions: ['ts', 'js', 'json', 'node'],
// setupFiles: ['<rootDir>/tests/setup.ts'],
moduleNameMapper: {
// FIXME: module mapper causes typeorm errors
// "electron": "<rootDir>/tests/mock/electron.ts",
// "logger": "<rootDir>/tests/mock/logger",
},
testTimeout: 1800000,
}
23 changes: 23 additions & 0 deletions packages/sync-test/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{
"name": "sync-test",
"productName": "Neuron",
"description": "CKB Neuron Wallet",
"homepage": "https://www.nervos.org/",
"version": "0.112.0",
"private": true,
"author": {
"name": "Nervos Core Dev",
"email": "dev@nervos.org",
"url": "https://github.com/nervosnetwork/neuron"
},
"repository": {
"type": "git",
"url": "https://github.com/nervosnetwork/neuron"
},
"scripts": {
"sync-test": "jest demo.test.ts"
},
"dependencies": {
"@types/tar": "6.1.10"
}
}
7 changes: 7 additions & 0 deletions packages/sync-test/scripts/prepare_neuron_linux.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#wget http://github-test-logs.ckbapp.dev/neuron/sync/Neuron-v0.111.1-x86_64.AppImage
cp Neuron-*.AppImage Neuron.AppImage
chmod 777 Neuron.AppImage
./Neuron.AppImage --appimage-extract
mkdir neuron
mv squashfs-root neuron
cp -r neuron/squashfs-root/bin source/
6 changes: 6 additions & 0 deletions packages/sync-test/scripts/prepare_neuron_macos.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#wget http://github-test-logs.ckbapp.dev/neuron/sync/Neuron-v0.111.1-mac-x64.zip
cp Neuron*.zip Neuron.zip
unzip Neuron.zip
mv Neuron.app neuron
chmod 777 neuron/Contents
cp -r neuron/Contents/bin source/
19 changes: 19 additions & 0 deletions packages/sync-test/scripts/prepare_neuron_windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
@REM curl -O -L http://github-test-logs.ckbapp.dev/neuron/sync/Neuron-v0.111.1-setup.exe
copy .\Neuron-*.exe Neuron-setup.exe
@echo off
REM 执行安装程序
.\Neuron-setup.exe /S /D=D:\a\neuron\neuron\packages\sync-test\neuron

REM 等待进程执行结束
:CHECK_LOOP
tasklist | find "Neuron-setup.exe" > nul
if errorlevel 1 (
echo Neuron install succ
mkdir ".\source\bin"
copy ".\neuron\bin\ckb.exe" ".\source\bin\ckb.exe"
copy ".\neuron\bin\ckb-light-client.exe" ".\source\bin\ckb-light-client.exe"
exit /b 0
) else (
timeout /t 5 /nobreak > nul
goto :CHECK_LOOP
)
Binary file added packages/sync-test/source/ckb-data/db.2000.tar.gz
Binary file not shown.
47 changes: 47 additions & 0 deletions packages/sync-test/source/ckb-light-client/config.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# chain = "mainnet"
# chain = "testnet"
# chain = "your_path_to/dev.toml"
chain = "../ckb/specs/dev.toml"

[store]
path = "data/store"

[network]
path = "data/network"

listen_addresses = ["/ip4/0.0.0.0/tcp/8118"]
### Specify the public and routable network addresses
# public_addresses = []

# Node connects to nodes listed here to discovery other peers when there's no local stored peers.
# When chain.spec is changed, this usually should also be changed to the bootnodes in the new chain.
bootnodes = ["/ip4/127.0.0.1/tcp/8115/p2p/QmShJCAx1RzpEDFwBuQ6noqViNgNuYrYv2KCRhxmNQCe5J"]

### Whitelist-only mode
# whitelist_only = false
### Whitelist peers connecting from the given IP addresses
# whitelist_peers = []

### Enable `SO_REUSEPORT` feature to reuse port on Linux, not supported on other OS yet
# reuse_port_on_linux = true

max_peers = 125
max_outbound_peers = 2
# 2 minutes
ping_interval_secs = 120
# 20 minutes
ping_timeout_secs = 1200
connect_outbound_interval_secs = 15
# If set to true, try to register upnp
upnp = false
# If set to true, network service will add discovered local address to peer store, it's helpful for private net development
discovery_local_address = false
# If set to true, random cleanup when there are too many inbound nodes
# Ensure that itself can continue to serve as a bootnode node
bootnode_mode = false

[rpc]
# Light client rpc is designed for self hosting, exposing to public network is not recommended and may cause security issues.
# By default RPC only binds to localhost, thus it only allows accessing from the same machine.
listen_address = "127.0.0.1:9000"

29 changes: 29 additions & 0 deletions packages/sync-test/source/ckb/ckb-miner.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@

data_dir = 'data'

[chain]

spec = { file = 'specs/dev.toml' }

[logger]

filter = 'info'
color = true
log_to_file = true
log_to_stdout = true

[sentry]

dsn = ''

[miner.client]

rpc_url = 'http://127.0.0.1:8114'
block_on_submit = true
poll_interval = 500

[[miner.workers]]

worker_type = 'Dummy'
delay_type = 'Constant'
value = 500
Loading