Skip to content

Latest commit

 

History

History
161 lines (137 loc) · 7.24 KB

DEVELOPMENT.md

File metadata and controls

161 lines (137 loc) · 7.24 KB

Development Guide

Architecture

Setup

All:

  • npm install -g node-gyp
  • git clone https://github.com/Scoop-Tech/scpx-wallet.git
  • cd scpx-wallet

MacOS:

Windows:

  • npm install -g --production windows-build-tools@4.0.0 - see also here
  • npm config set msvs_version 2015

All:

  • yarn install PREFERRED
  • npm install - Windows: see also here re. node-gyp rebuild failures

Running Core Wallet CLI - through NPM

  • npm run dev - runs with dev flags (saves CLI history to file, caches MPK in memory, activates test assets)
  • npm start - runs with prod flags

Running Core Wallet CLI - directly with Node, e.g:

  • node --experimental-worker ./sw-cli.js --help to view CLI options
  • export NODE_OPTIONS=development &&node --experimental-worker ./sw-cli.js --saveHistory=true --mpk=... --loadServer=... e.g. to load a server-wallet, e.g. one created from www.scoop.tech

Running Tests

  • See: .env.example to run the entire integration test suite (you'll need to make a server test account, and fund it with test assets)
  • npm run test to run the the CI test suite; if no .env value(s) found, it will skip some tests
  • npm run test -- -t "BTC_TEST" - to run individual tests, filtered by it() description

The full test suite executes full integration tests that transact on testnets - these incur testnet network fees. The Travis integration suite uses a server account for this. If you can help keep it topped up, the testnet addresses are:

Core wallet functions are demonstrated as integration tests, many of which interact over HTTPS with 3rd Party Blockchain Providers (3PBPs) and/or the Scoop Data Storage Contract. Pull requests are welcome, as are contributions for more fine-grained unit tests.

Contributing

Please see the Contribution Guide for more info.

Debugging

Visual Studio Code is recommended. A template ./vscode/launch.json with some common launch actions:

{
    "version": "0.2.0",
    "configurations": [
        // LOAD SERVER WALLET
        {
            "type": "node",
            "request": "launch",
            "env": {
                "NODE_OPTIONS": "--experimental-worker",
                "NODE_ENV": "development"
            },
            "stopOnEntry": false,
            "runtimeVersion": "14.21.3",
            "name": "wallet-dev",
            "program": "${workspaceFolder}/ext/wallet/sw-cli.js",
            "args": ["--rpc=true",
                     "--rpcPort=4000",
                     "--rpcRemoteHosts=::ffff:127.0.0.1",
                     "--rpcUsername=scp",
                     "--rpcPassword=123",
                     //"--mpk=...", 
                     //"--loadServer=...",
                     "--saveHistory=true"
                    ],
            "console": "externalTerminal",
            "runtimeExecutable": "node",
            "runtimeArgs": ["--nolazy"],
            "autoAttachChildProcesses": true
        },

        // NEW LOCAL EMPTY WALLET, OR LOAD FILE WALLET
        {
            "name": "local: new",
            "type": "node",
            "request": "launch",
            "env": {
                "NODE_OPTIONS": "--experimental-worker",
                "NODE_ENV": "development"
            },
            "stopOnEntry": false,
            "runtimeVersion": "14.21.3",
            "program": "${workspaceFolder}/ext/wallet/sw-cli.js",
            "args": [//"--mpk=...", 
                     //"--loadFile=...",
                     "--rpc=true",
                     "--rpcPort=4000",
                     "--rpcRemoteHosts=::ffff:127.0.0.1",
                     "--rpcUsername=scp",
                     "--rpcPassword=.....",
                     "--saveHistory=true"
                    ],
                    
            "console": "externalTerminal",
            "runtimeExecutable": "node",
            "runtimeArgs": ["--nolazy"],
            "autoAttachChildProcesses": true
        },

        // RUN TESTS
        {
            "name": "tests: integration",
            "type": "node",
            "request": "launch",    
            "env": {
                "NODE_OPTIONS": "--experimental-worker",
                "NODE_ENV": "test"
            },
            "stopOnEntry": false,
            "runtimeVersion": "14.21.3",
            "program": "${workspaceFolder}/ext/wallet/node_modules/.bin/jest",
            "args": ["--runInBand", "--verbose", "--forceExit", "--env=node", "--coverage", 
                   //"-t=DSIG"
                    ], 
            "autoAttachChildProcesses": true,
            "console": "externalTerminal",
            "internalConsoleOptions": "neverOpen",
            "windows": {
              "program": "${workspaceFolder}/node_modules/jest/bin/jest",
            }        
        }
    ]
}