Browse Source

moved to network-tests directory, bumped joystream types

Gleb Urvanov 4 years ago
parent
commit
094d374f8f

+ 1 - 1
package.json

@@ -6,6 +6,6 @@
 		"test": "yarn && yarn workspaces run test"
 	},
 	"workspaces": [
-		"tests"
+		"tests/network-tests"
 	]
 }

+ 0 - 0
tests/.env → tests/network-tests/.env


+ 0 - 0
tests/.prettierrc → tests/network-tests/.prettierrc


+ 0 - 0
tests/LICENSE → tests/network-tests/LICENSE


+ 1 - 1
tests/package.json → tests/network-tests/package.json

@@ -9,7 +9,7 @@
     "prettier": "prettier --write ./src"
   },
   "dependencies": {
-    "@joystream/types": "^0.6.0",
+    "@joystream/types": "^0.7.0",
     "@polkadot/api": "^0.96.1",
     "@polkadot/keyring": "^1.7.0-beta.5",
     "@types/bn.js": "^4.11.5",

+ 0 - 0
tests/src/tests/electingCouncilTest.ts → tests/network-tests/src/tests/electingCouncilTest.ts


+ 0 - 0
tests/src/tests/membershipCreationTest.ts → tests/network-tests/src/tests/membershipCreationTest.ts


+ 0 - 0
tests/src/utils/apiWrapper.ts → tests/network-tests/src/utils/apiWrapper.ts


+ 0 - 0
tests/src/utils/config.ts → tests/network-tests/src/utils/config.ts


+ 65 - 65
tests/src/utils/sender.ts → tests/network-tests/src/utils/sender.ts

@@ -1,65 +1,65 @@
-import BN = require('bn.js');
-import { ApiPromise } from '@polkadot/api';
-import { Index } from '@polkadot/types/interfaces';
-import { SubmittableExtrinsic } from '@polkadot/api/types';
-import { KeyringPair } from '@polkadot/keyring/types';
-
-export class Sender {
-  private readonly api: ApiPromise;
-  private static nonceMap: Map<string, BN> = new Map();
-
-  constructor(api: ApiPromise) {
-    this.api = api;
-  }
-
-  private async getNonce(address: string): Promise<BN> {
-    let oncahinNonce: BN = new BN(0);
-    if (!Sender.nonceMap.get(address)) {
-      oncahinNonce = await this.api.query.system.accountNonce<Index>(address);
-    }
-    let nonce: BN | undefined = Sender.nonceMap.get(address);
-    if (!nonce) {
-      nonce = oncahinNonce;
-    }
-    const nextNonce: BN = nonce.addn(1);
-    Sender.nonceMap.set(address, nextNonce);
-    return nonce;
-  }
-
-  private clearNonce(address: string): void {
-    Sender.nonceMap.delete(address);
-  }
-
-  public async signAndSend(
-    tx: SubmittableExtrinsic<'promise'>,
-    account: KeyringPair,
-    expectFailure = false
-  ): Promise<void> {
-    return new Promise(async (resolve, reject) => {
-      const nonce: BN = await this.getNonce(account.address);
-      const signedTx = tx.sign(account, { nonce });
-      await signedTx
-        .send(async result => {
-          if (result.status.isFinalized === true && result.events !== undefined) {
-            result.events.forEach(event => {
-              if (event.event.method === 'ExtrinsicFailed') {
-                if (expectFailure) {
-                  resolve();
-                } else {
-                  reject(new Error('Extrinsic failed unexpectedly'));
-                }
-              }
-            });
-            resolve();
-          }
-          if (result.status.isFuture) {
-            this.clearNonce(account.address);
-            reject(new Error('Extrinsic nonce is in future'));
-          }
-        })
-        .catch(error => {
-          reject(error);
-        });
-    });
-  }
-}
+import BN = require('bn.js');
+import { ApiPromise } from '@polkadot/api';
+import { Index } from '@polkadot/types/interfaces';
+import { SubmittableExtrinsic } from '@polkadot/api/types';
+import { KeyringPair } from '@polkadot/keyring/types';
+
+export class Sender {
+  private readonly api: ApiPromise;
+  private static nonceMap: Map<string, BN> = new Map();
+
+  constructor(api: ApiPromise) {
+    this.api = api;
+  }
+
+  private async getNonce(address: string): Promise<BN> {
+    let oncahinNonce: BN = new BN(0);
+    if (!Sender.nonceMap.get(address)) {
+      oncahinNonce = await this.api.query.system.accountNonce<Index>(address);
+    }
+    let nonce: BN | undefined = Sender.nonceMap.get(address);
+    if (!nonce) {
+      nonce = oncahinNonce;
+    }
+    const nextNonce: BN = nonce.addn(1);
+    Sender.nonceMap.set(address, nextNonce);
+    return nonce;
+  }
+
+  private clearNonce(address: string): void {
+    Sender.nonceMap.delete(address);
+  }
+
+  public async signAndSend(
+    tx: SubmittableExtrinsic<'promise'>,
+    account: KeyringPair,
+    expectFailure = false
+  ): Promise<void> {
+    return new Promise(async (resolve, reject) => {
+      const nonce: BN = await this.getNonce(account.address);
+      const signedTx = tx.sign(account, { nonce });
+      await signedTx
+        .send(async result => {
+          if (result.status.isFinalized === true && result.events !== undefined) {
+            result.events.forEach(event => {
+              if (event.event.method === 'ExtrinsicFailed') {
+                if (expectFailure) {
+                  resolve();
+                } else {
+                  reject(new Error('Extrinsic failed unexpectedly'));
+                }
+              }
+            });
+            resolve();
+          }
+          if (result.status.isFuture) {
+            this.clearNonce(account.address);
+            reject(new Error('Extrinsic nonce is in future'));
+          }
+        })
+        .catch(error => {
+          reject(error);
+        });
+    });
+  }
+}

+ 0 - 0
tests/src/utils/utils.ts → tests/network-tests/src/utils/utils.ts


+ 0 - 0
tests/tsconfig.json → tests/network-tests/tsconfig.json


+ 0 - 0
tests/tslint.json → tests/network-tests/tslint.json