git.delta.rocks / unique-network / refs/commits / 297a2ab34b66

difftreelog

Connection test.

sotmorskiy2020-09-09parent: #3e483e7.patch.diff
in: master

11 files changed

added.editorconfigdiffbeforeafterboth
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,13 @@
+root = true
+
+[*]
+indent_style = space
+indent_size = 4
+
+[*.ts]
+indent_style = space
+indent_size = 2
+
+[*.yaml]
+indent_style = space
+indent_size = 2
modified.gitignorediffbeforeafterboth
--- a/.gitignore
+++ b/.gitignore
@@ -8,4 +8,6 @@
 chain-data*/
 
 einstein_key_file
-*store_key*.json
\ No newline at end of file
+*store_key*.json
+
+/.idea/
\ No newline at end of file
addedtests/.gitignorediffbeforeafterboth
--- /dev/null
+++ b/tests/.gitignore
@@ -0,0 +1 @@
+/node_modules/
addedtests/.vscode/launch.jsondiffbeforeafterboth
--- /dev/null
+++ b/tests/.vscode/launch.json
@@ -0,0 +1,23 @@
+{
+    // Use IntelliSense to learn about possible attributes.
+    // Hover to view descriptions of existing attributes.
+    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+    "version": "0.2.0",
+    "configurations": [
+        {
+            "type": "node",
+            "request": "launch",
+            "name": "Mocha Current File",
+            "program": "${workspaceFolder}/node_modules/mocha/bin/_mocha",
+            "args": [
+                "--timeout", "999999",
+                "--colors",
+                "--recursive",
+                "--require", "ts-node/register",
+                "./**/*.test.ts"
+            ],
+            "console": "integratedTerminal",
+            "internalConsoleOptions": "neverOpen"
+      }
+    ]
+}
\ No newline at end of file
addedtests/package-lock.jsondiffbeforeafterboth

no changes

addedtests/package.jsondiffbeforeafterboth
--- /dev/null
+++ b/tests/package.json
@@ -0,0 +1,41 @@
+{
+  "name": "NftTests",
+  "version": "1.0.0",
+  "description": "Substrate Nft tests",
+  "main": "",
+  "devDependencies": {
+    "@polkadot/dev": "^0.52.11",
+    "@polkadot/ts": "^0.3.41",
+    "@types/bn.js": "^4.11.6",
+    "@types/chai": "^4.2.12",
+    "@types/mocha": "^8.0.3",
+    "chai": "^4.2.0",
+    "mocha": "^8.1.1",
+    "ts-node": "^9.0.0",
+    "tslint": "^5.20.1",
+    "typescript": "^3.9.7"
+  },
+  "scripts": {
+    "test": "mocha -r ts-node/register ./**/*.test.ts"
+  },
+  "author": "",
+  "license": "Apache 2.0",
+  "homepage": "",
+  "dependencies": {
+    "@polkadot/api": "^1.31.2",
+    "@polkadot/types": "^1.31.2",
+    "@polkadot/util": "^2.18.1",
+    "@types/bn.js": "^4.11.6"
+  },
+  "standard": {
+    "globals": [
+      "it",
+      "assert",
+      "beforeEach",
+      "afterEach",
+      "describe",
+      "contract",
+      "artifacts"
+    ]
+  }
+}
addedtests/src/config.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/config.ts
@@ -0,0 +1,7 @@
+import process from 'process';
+
+const config = {
+  substrateUrl: process.env.substrateUrl || 'ws://127.0.0.1:9944'
+}
+
+export default config;
\ No newline at end of file
addedtests/src/connection.test.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/connection.test.ts
@@ -0,0 +1,10 @@
+import createSubstrateApi from "./substrate-api";
+import {expect} from 'chai';
+
+describe('Connection', () => {
+  it('Connection can be established', async () => {
+    const api = await createSubstrateApi();
+    const health = await api.rpc.system.health();
+    expect(health).to.be.not.empty;
+  });
+});
\ No newline at end of file
addedtests/src/substrate-api.tsdiffbeforeafterboth
--- /dev/null
+++ b/tests/src/substrate-api.ts
@@ -0,0 +1,10 @@
+import { WsProvider, ApiPromise } from "@polkadot/api";
+import config from "./config";
+
+const wsProvider = new WsProvider(config.substrateUrl);
+const settings = { provider: wsProvider };
+
+
+export default function createSubstrateApi(): Promise<ApiPromise> {
+  return new ApiPromise(settings).isReady;
+}
\ No newline at end of file
addedtests/tsconfig.jsondiffbeforeafterboth
--- /dev/null
+++ b/tests/tsconfig.json
@@ -0,0 +1,22 @@
+{
+  "exclude": [
+    "node_modules",
+    "node_modules/**/*",
+    "**/node_modules/**/*"
+  ],
+  "compilerOptions": {
+    "target": "es6",
+    "moduleResolution": "node",
+    "esModuleInterop": true,
+    "resolveJsonModule": true,
+    "module": "commonjs",
+    "sourceMap": true,
+    "outDir": "dist",
+    "rootDir": "src",
+    "strict": true
+  },
+  "include": [
+    "src/**/*"
+  ],
+  "lib": ["es2015"]
+}
addedtests/tslint.jsondiffbeforeafterboth
--- /dev/null
+++ b/tests/tslint.json
@@ -0,0 +1,11 @@
+{
+  "defaultSeverity": "error",
+  "extends": ["tslint:recommended"],
+  "jsRules": {},
+  "rules": {
+    "indent": [false, "spaces"],
+    "no-console": false,
+    "quotemark": [true, "single", "avoid-escape", "avoid-template"]
+  },
+  "rulesDirectory": []
+}