-
Notifications
You must be signed in to change notification settings - Fork 52
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add js libs * un-submodule js * fix pipeline branch * fix test * remove duplicate simulation * debug node location; * fix cache locations * fix simulation path * debug proving key and node paths * debug proving key and node paths * debug proving key and node paths * debug proving key and node paths * debug proving key and node paths * cleanup * cleanup * fix test runner * fix test runner * fix test runner * debug; try build without test * update gitignore * stop uselessly caching manta node * debug: change workflow names? * runner os -> matrix os * get node from S3 * get node from S3 * remove dists * remove junk
- Loading branch information
1 parent
3f3f8a1
commit 1c62b27
Showing
77 changed files
with
5,884 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
name: End-to-end test | ||
on: | ||
push: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- '**.md' | ||
pull_request: | ||
branches: | ||
- master | ||
paths-ignore: | ||
- '**.md' | ||
|
||
jobs: | ||
build_code: | ||
name: End to end test | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 120 | ||
strategy: | ||
matrix: | ||
node-version: [16.x] | ||
env: | ||
MANTA_SDK_BRANCH: "main" | ||
|
||
steps: | ||
- name: Cancel previous runs | ||
uses: styfle/cancel-workflow-action@0.9.1 | ||
with: | ||
access_token: ${{ github.token }} | ||
- uses: actions/checkout@v1 | ||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v1 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
- name: Build manta-signer test server | ||
run: cargo build --example test_server --release --features=unsafe-disable-cors | ||
- name: Build manta-js | ||
run: | | ||
cd js | ||
yarn install --immutable | grep -v 'YN0013' | ||
yarn build | ||
- name: Enable test scripts | ||
run: | | ||
chmod +x "${GITHUB_WORKSPACE}/.github/workflows/e2e/get_latest_sdk_version.sh" | ||
chmod +x "${GITHUB_WORKSPACE}/.github/workflows/e2e/move_proving_keys.sh" | ||
chmod +x "${GITHUB_WORKSPACE}/.github/workflows/e2e/get_node.sh" | ||
chmod +x "${GITHUB_WORKSPACE}/.github/workflows/e2e/run_test.sh" | ||
- name: Get latest Manta sdk version | ||
run: | | ||
LATEST_SDK_VERSION=`"${GITHUB_WORKSPACE}/.github/workflows/e2e/get_latest_sdk_version.sh" ${{ env.MANTA_SDK_BRANCH }}` | ||
echo $LATEST_SDK_VERSION | ||
echo "LATEST_SDK_VERSION=$LATEST_SDK_VERSION" >> $GITHUB_ENV | ||
- name: Load proving keys from cache | ||
id: load-cache-proving-keys | ||
uses: actions/cache@v2 | ||
env: | ||
cache-name: proving-keys | ||
with: | ||
path: ~/.local/share/manta-signer | ||
key: ${{ env.cache-name }}-${{ env.LATEST_SDK_VERSION }} | ||
- name: Get proving keys | ||
if: steps.load-cache-proving-keys.outputs.cache-hit != 'true' | ||
uses: actions/checkout@v2 | ||
with: | ||
repository: Manta-Network/sdk | ||
path: sdk | ||
fetch-depth: 1 | ||
lfs: true | ||
- name: Move proving keys | ||
if: steps.load-cache-proving-keys.outputs.cache-hit != 'true' | ||
run: "${GITHUB_WORKSPACE}/.github/workflows/e2e/move_proving_keys.sh" | ||
|
||
- name: Get Dolphin node | ||
run: "${GITHUB_WORKSPACE}/.github/workflows/e2e/get_node.sh" | ||
|
||
- name: Run test | ||
run: "${GITHUB_WORKSPACE}/.github/workflows/e2e/run_test.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#!/bin/bash | ||
BRANCH=$1 | ||
|
||
git ls-remote https://github.com/manta-network/sdk.git $BRANCH | awk '{ print $1}' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
cd ~ | ||
mkdir Manta | ||
cd Manta | ||
curl https://manta-ops.s3.amazonaws.com/Dolphin-v0.2.1-841eb2f-x86_64-linux-gnu/manta --output manta | ||
chmod +x manta |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
mkdir ~/.local | ||
mkdir ~/.local/share | ||
mkdir ~/.local/share/manta-signer | ||
cp ./sdk/zkp/reclaim_pk.bin ~/.local/share/manta-signer | ||
cp ./sdk/zkp/transfer_pk.bin ~/.local/share/manta-signer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
# Create 10-round simulation instructions and save output | ||
cd js/e2e/simulation | ||
cargo run 10 | tail -n +2 > out.json | ||
cat out.json | ||
|
||
# Run 3 headless copies of signer | ||
cd ../../.. | ||
cargo run --example test_server --release --features=unsafe-disable-cors -- http://127.0.0.1:29988 & | ||
cargo run --example test_server --release --features=unsafe-disable-cors -- http://127.0.0.1:29989 & | ||
cargo run --example test_server --release --features=unsafe-disable-cors -- http://127.0.0.1:29990 & | ||
|
||
# Run node | ||
~/Manta/manta --chain dev --ws-port 9944 --port 30333 --alice \ | ||
--tmp --rpc-cors all --unsafe-ws-external --unsafe-rpc-external \ | ||
--rpc-methods=Unsafe & | ||
|
||
# Run test | ||
cd js | ||
yarn test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
ESLINT_NO_DEV_ERRORS=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
env: | ||
commonjs: true | ||
es2021: true | ||
extends: | ||
- standard | ||
parser: '@typescript-eslint/parser' | ||
parserOptions: | ||
ecmaVersion: 12 | ||
plugins: | ||
- '@typescript-eslint' | ||
ignorePatterns: ['types.d.ts'] | ||
rules: | ||
{ | ||
'indent': ['error', 2], | ||
'linebreak-style': ['error', 'unix'], | ||
'quotes': ['error', 'single'], | ||
'semi': ['error', 'always'], | ||
'space-before-function-paren': ['error', 'never'], | ||
'comma-dangle': | ||
[ | ||
'error', | ||
{ | ||
'arrays': 'never', | ||
'objects': 'never', | ||
'imports': 'never', | ||
'exports': 'never', | ||
'functions': 'never' | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"tabWidth": 2, | ||
"semi": true, | ||
"singleQuote": true, | ||
"trailingComma": "none" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
nodeLinker: node-modules | ||
nmHoistingLimits: workspaces |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Signer JS Libraries | ||
|
||
This workspace includes the following packages: | ||
|
||
| name | path | description | status | | ||
|------------------|---------------------|-----------------------------------------|---------------| | ||
| dophin-api | `./dolphin-api` | api for dolphin nodes. | experimental | | ||
| workflows | `./workflows` | logical workflows with extrinsics. | experimental | | ||
| e2e | `./e2e` | end-to-end test suites. | experimental | | ||
| singer-interface | `/signer-interface` | typescript interface for manta-signer. | experimental | | ||
| coin-selection | `/coin-selection` | simple coin selection logic | experimental | | ||
|
||
|
||
## Build | ||
Tested environment: | ||
* node: `v16.x` | ||
* yarn: `1.22.x` | ||
|
||
```yarn install && yarn build``` | ||
|
||
## Test Setup | ||
|
||
1. Make sure you have a node running that you want to connect to. | ||
|
||
```bash | ||
git clone -b dolphin git@github.com:Manta-Network/Manta.git | ||
cd Manta | ||
cargo build --release | ||
./target/release/manta --dev --tmp --alice --unsafe-ws-external | ||
``` | ||
|
||
Which will be live at `ws://127.0.0.1:9944`. | ||
|
||
2. [Run manta-signer test server](https://github.com/Manta-Network/manta-signer/tree/master/examples) | ||
|
||
|
||
## Tests | ||
You can run the entire testsuite with | ||
|
||
```yarn run e2e test``` | ||
|
||
|
||
### Create a new test | ||
The test suite is set up using [mocha](https://mochajs.org/) as the test runner and [chai](https://www.chaijs.com/) for the assertion library. | ||
Both projects have good documentation on how to use them. | ||
|
||
Add a new test by adding a `describe()` call in `e2e/test/test.ts`. | ||
|
||
|
||
## Workflows | ||
To create a new workflow to be uses in `dev-cli` or `e2e` tests, | ||
start by choosing a name for your workflow. Then create a copy of | ||
`/manta-workflows/src/workflows/init_asset_workflow.ts` with the new name, and | ||
replace all instances of `initAssetWorkflow` in the file with the new name. | ||
|
||
Both repositories already have `manta-workflows` as a dependency, so to use a | ||
workflow recompile the project: | ||
|
||
```yarn run workflows build``` | ||
|
||
And then import your workflow like | ||
|
||
``` import { initAssetWorkflow } from 'manta-workflows';``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Manta Coin Selection | ||
|
||
Coin selection logic for Manta / Calamari Network, for now extremely basic |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "coin-selection", | ||
"version": "0.1.1", | ||
"main": "dist/index.js", | ||
"description": "Coin selection logic for Manta and Calamari Netowrk", | ||
"license": "GPL-3.0-only", | ||
"scripts": { | ||
"build": "rm -rf coin-selection/dist ; tsc" | ||
}, | ||
"dependencies": { | ||
"bn.js": "^5.2.0" | ||
}, | ||
"devDependencies": { | ||
"typescript": "^4.4.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// @ts-nocheck | ||
export class CoinSelection { | ||
constructor(coins, totalValueAtomicUnits, targetValueAtomicUnits, assetId) { | ||
this.coins = coins; | ||
this.totalValueAtomicUnits = totalValueAtomicUnits; | ||
this.targetValueAtomicUnits = targetValueAtomicUnits; | ||
this.assetId = assetId; | ||
this.changeValueAtomicUnits = totalValueAtomicUnits.sub( | ||
targetValueAtomicUnits | ||
); | ||
} | ||
|
||
numberOfZeroCoinsRequired() { | ||
return Math.max(0, 2 - this.coins.length); | ||
} | ||
|
||
last() { | ||
const last = this.coins[this.coins.length - 1]; | ||
if (!last) { | ||
throw new Error('Coin selection does not contain any coins'); | ||
} | ||
return last; | ||
} | ||
|
||
secondLast() { | ||
const secondLast = this.coins[this.coins.length - 2]; | ||
if (!secondLast) { | ||
throw new Error('Coin selection contains fewer than two coins'); | ||
} | ||
return secondLast; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import { CoinSelection } from './coinSelection.js'; | ||
import { selectCoins } from './selectCoins.js'; | ||
|
||
export { CoinSelection, selectCoins }; |
Oops, something went wrong.