Browse Source

rome constantinople test finished, new proposals moved to separate branch

Gleb Urvanov 4 years ago
parent
commit
3f25c78f81

+ 2 - 2
tests/network-tests/package.json

@@ -4,8 +4,8 @@
   "license": "GPL-3.0-only",
   "scripts": {
     "build": "tsc --build tsconfig.json",
-    "test": "mocha -r ts-node/register src/tests/proposals/*",
-    "test-migration": "mocha -r ts-node/register src/tests/rome/* && mocha -r ts-node/register src/tests/proposals/*",
+    "test": "mocha -r ts-node/register src/tests/constantinople/*",
+    "test-migration": "mocha -r ts-node/register src/tests/rome/* && mocha -r ts-node/register src/tests/constantinople/*",
     "lint": "tslint --project tsconfig.json",
     "prettier": "prettier --write ./src"
   },

+ 4 - 4
tests/network-tests/src/tests/electingCouncilTest.ts → tests/network-tests/src/tests/constantinople/electingCouncilTest.ts

@@ -1,13 +1,13 @@
 import { membershipTest } from './membershipCreationTest';
 import { KeyringPair } from '@polkadot/keyring/types';
-import { ApiWrapper } from '../utils/apiWrapper';
+import { ApiWrapper } from '../../utils/apiWrapper';
 import { WsProvider, Keyring } from '@polkadot/api';
-import { initConfig } from '../utils/config';
+import { initConfig } from '../../utils/config';
 import BN = require('bn.js');
 import { registerJoystreamTypes, Seat } from '@joystream/types';
 import { assert } from 'chai';
 import { v4 as uuid } from 'uuid';
-import { Utils } from '../utils/utils';
+import { Utils } from '../../utils/utils';
 
 export function councilTest(m1KeyPairs: KeyringPair[], m2KeyPairs: KeyringPair[]) {
   initConfig();
@@ -118,7 +118,7 @@ export function councilTest(m1KeyPairs: KeyringPair[], m2KeyPairs: KeyringPair[]
   });
 }
 
-describe.skip('Council integration tests', () => {
+describe('Council integration tests', () => {
   const m1KeyPairs: KeyringPair[] = new Array();
   const m2KeyPairs: KeyringPair[] = new Array();
   membershipTest(m1KeyPairs);

+ 2 - 2
tests/network-tests/src/tests/membershipCreationTest.ts → tests/network-tests/src/tests/constantinople/membershipCreationTest.ts

@@ -4,8 +4,8 @@ import { Keyring } from '@polkadot/keyring';
 import { assert } from 'chai';
 import { KeyringPair } from '@polkadot/keyring/types';
 import BN = require('bn.js');
-import { ApiWrapper } from '../utils/apiWrapper';
-import { initConfig } from '../utils/config';
+import { ApiWrapper } from '../../utils/apiWrapper';
+import { initConfig } from '../../utils/config';
 import { v4 as uuid } from 'uuid';
 
 export function membershipTest(nKeyPairs: KeyringPair[]) {

+ 0 - 75
tests/network-tests/src/tests/proposals/spendingProposalTest.ts

@@ -1,75 +0,0 @@
-import { initConfig } from '../../utils/config';
-import { Keyring, WsProvider } from '@polkadot/api';
-import { KeyringPair } from '@polkadot/keyring/types';
-import { membershipTest } from '../membershipCreationTest';
-import { councilTest } from '../electingCouncilTest';
-import { registerJoystreamTypes } from '@joystream/types';
-import { ApiWrapper } from '../../utils/apiWrapper';
-import { v4 as uuid } from 'uuid';
-import BN = require('bn.js');
-
-describe.skip('Spending proposal network tests', () => {
-  initConfig();
-  const keyring = new Keyring({ type: 'sr25519' });
-  const nodeUrl: string = process.env.NODE_URL!;
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!;
-  const spendingBalance: BN = new BN(+process.env.SPENDING_BALANCE!);
-  const defaultTimeout: number = 120000;
-
-  const m1KeyPairs: KeyringPair[] = new Array();
-  const m2KeyPairs: KeyringPair[] = new Array();
-
-  let apiWrapper: ApiWrapper;
-  let sudo: KeyringPair;
-
-  before(async function () {
-    this.timeout(defaultTimeout);
-    registerJoystreamTypes();
-    const provider = new WsProvider(nodeUrl);
-    apiWrapper = await ApiWrapper.create(provider);
-  });
-
-  membershipTest(m1KeyPairs);
-  membershipTest(m2KeyPairs);
-  councilTest(m1KeyPairs, m2KeyPairs);
-
-  it('Spending proposal test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri);
-    const description: string = 'spending proposal which is used for API network testing with some mock data';
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee();
-
-    // Topping the balances
-    const proposalStake: BN = await apiWrapper.getRequiredProposalStake(25, 10000);
-    const runtimeProposalFee: BN = apiWrapper.estimateProposeSpendingFee(
-      description,
-      description,
-      proposalStake,
-      spendingBalance,
-      sudo.address
-    );
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, runtimeProposalFee.add(proposalStake));
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee);
-
-    // Proposal creation
-    const proposalPromise = apiWrapper.expectProposalCreated();
-    await apiWrapper.proposeSpending(
-      m1KeyPairs[0],
-      'testing spending' + uuid().substring(0, 8),
-      'spending to test proposal functionality' + uuid().substring(0, 8),
-      proposalStake,
-      spendingBalance,
-      sudo.address
-    );
-    const proposalNumber = await proposalPromise;
-
-    // Approving runtime update proposal
-    const runtimePromise = apiWrapper.expectProposalFinalized();
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber);
-    await runtimePromise;
-  }).timeout(defaultTimeout);
-
-  after(() => {
-    apiWrapper.close();
-  });
-});

+ 0 - 68
tests/network-tests/src/tests/proposals/textProposalTest.ts

@@ -1,68 +0,0 @@
-import { initConfig } from '../../utils/config';
-import { Keyring, WsProvider } from '@polkadot/api';
-import { KeyringPair } from '@polkadot/keyring/types';
-import { membershipTest } from '../membershipCreationTest';
-import { councilTest } from '../electingCouncilTest';
-import { registerJoystreamTypes } from '@joystream/types';
-import { ApiWrapper } from '../../utils/apiWrapper';
-import { v4 as uuid } from 'uuid';
-import BN = require('bn.js');
-
-describe.skip('Text proposal network tests', () => {
-  initConfig();
-  const keyring = new Keyring({ type: 'sr25519' });
-  const nodeUrl: string = process.env.NODE_URL!;
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!;
-  const defaultTimeout: number = 180000;
-
-  const m1KeyPairs: KeyringPair[] = new Array();
-  const m2KeyPairs: KeyringPair[] = new Array();
-
-  let apiWrapper: ApiWrapper;
-  let sudo: KeyringPair;
-
-  before(async function () {
-    this.timeout(defaultTimeout);
-    registerJoystreamTypes();
-    const provider = new WsProvider(nodeUrl);
-    apiWrapper = await ApiWrapper.create(provider);
-  });
-
-  membershipTest(m1KeyPairs);
-  membershipTest(m2KeyPairs);
-  councilTest(m1KeyPairs, m2KeyPairs);
-
-  it('Text proposal test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri);
-    const proposalTitle: string = 'Testing proposal ' + uuid().substring(0, 8);
-    const description: string = 'Testing text proposal ' + uuid().substring(0, 8);
-    const proposalText: string = 'Text of the testing proposal ' + uuid().substring(0, 8);
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee();
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee);
-
-    // Proposal stake calculation
-    const proposalStake: BN = await apiWrapper.getRequiredProposalStake(25, 10000);
-    const runtimeProposalFee: BN = apiWrapper.estimateProposeTextFee(
-      proposalStake,
-      description,
-      description,
-      proposalText
-    );
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, runtimeProposalFee.add(proposalStake));
-
-    // Proposal creation
-    const proposalPromise = apiWrapper.expectProposalCreated();
-    await apiWrapper.proposeText(m1KeyPairs[0], proposalStake, proposalTitle, description, proposalText);
-    const proposalNumber = await proposalPromise;
-
-    // Approving runtime update proposal
-    const textProposalPromise = apiWrapper.expectProposalFinalized();
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber);
-    await textProposalPromise;
-  }).timeout(defaultTimeout);
-
-  after(() => {
-    apiWrapper.close();
-  });
-});

+ 0 - 81
tests/network-tests/src/tests/proposals/updateRuntimeTest.ts

@@ -1,81 +0,0 @@
-import { initConfig } from '../../utils/config';
-import { Keyring, WsProvider } from '@polkadot/api';
-import { Bytes } from '@polkadot/types';
-import { KeyringPair } from '@polkadot/keyring/types';
-import { membershipTest } from '../membershipCreationTest';
-import { councilTest } from '../electingCouncilTest';
-import { registerJoystreamTypes } from '@joystream/types';
-import { ApiWrapper } from '../../utils/apiWrapper';
-import { v4 as uuid } from 'uuid';
-import BN = require('bn.js');
-
-describe.skip('Runtime upgrade networt tests', () => {
-  initConfig();
-  const keyring = new Keyring({ type: 'sr25519' });
-  const nodeUrl: string = process.env.NODE_URL!;
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!;
-  const defaultTimeout: number = 120000;
-
-  const m1KeyPairs: KeyringPair[] = new Array();
-  const m2KeyPairs: KeyringPair[] = new Array();
-
-  let apiWrapper: ApiWrapper;
-  let sudo: KeyringPair;
-
-  before(async function () {
-    this.timeout(defaultTimeout);
-    registerJoystreamTypes();
-    const provider = new WsProvider(nodeUrl);
-    apiWrapper = await ApiWrapper.create(provider);
-  });
-
-  membershipTest(m1KeyPairs);
-  membershipTest(m2KeyPairs);
-  councilTest(m1KeyPairs, m2KeyPairs);
-
-  it('Upgrading the runtime test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri);
-    const runtime: Bytes = await apiWrapper.getRuntime();
-    const description: string = 'runtime upgrade proposal which is used for API network testing';
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee();
-
-    // Topping the balances
-    const proposalStake: BN = await apiWrapper.getRequiredProposalStake(1, 100);
-    const runtimeProposalFee: BN = apiWrapper.estimateProposeRuntimeUpgradeFee(
-      proposalStake,
-      description,
-      description,
-      runtime
-    );
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, runtimeProposalFee.add(proposalStake));
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee);
-
-    // Proposal creation
-    console.log('proposing new runtime');
-    const proposalPromise = apiWrapper.expectProposalCreated();
-    console.log('sending extr');
-    await apiWrapper.proposeRuntime(
-      m1KeyPairs[0],
-      proposalStake,
-      'testing runtime' + uuid().substring(0, 8),
-      'runtime to test proposal functionality' + uuid().substring(0, 8),
-      runtime
-    );
-    const proposalNumber = await proposalPromise;
-    console.log('proposed');
-
-    // Approving runtime update proposal
-    console.log('block number ' + apiWrapper.getBestBlock());
-    console.log('approving new runtime');
-    const runtimePromise = apiWrapper.expectProposalFinalized();
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber);
-    await runtimePromise;
-  }).timeout(defaultTimeout);
-
-  membershipTest(new Array<KeyringPair>());
-
-  after(() => {
-    apiWrapper.close();
-  });
-});

+ 0 - 74
tests/network-tests/src/tests/proposals/workingGroupMintCapacityProposalTest.ts

@@ -1,74 +0,0 @@
-import { initConfig } from '../../utils/config';
-import { Keyring, WsProvider } from '@polkadot/api';
-import { KeyringPair } from '@polkadot/keyring/types';
-import { membershipTest } from '../membershipCreationTest';
-import { councilTest } from '../electingCouncilTest';
-import { registerJoystreamTypes } from '@joystream/types';
-import { ApiWrapper } from '../../utils/apiWrapper';
-import { v4 as uuid } from 'uuid';
-import BN = require('bn.js');
-
-describe.skip('Mint capacity proposal network tests', () => {
-  initConfig();
-  const keyring = new Keyring({ type: 'sr25519' });
-  const nodeUrl: string = process.env.NODE_URL!;
-  const sudoUri: string = process.env.SUDO_ACCOUNT_URI!;
-  const mintingCapacity: BN = new BN(+process.env.MINTING_CAPACITY!);
-  const defaultTimeout: number = 120000;
-
-  const m1KeyPairs: KeyringPair[] = new Array();
-  const m2KeyPairs: KeyringPair[] = new Array();
-
-  let apiWrapper: ApiWrapper;
-  let sudo: KeyringPair;
-
-  before(async function () {
-    this.timeout(defaultTimeout);
-    registerJoystreamTypes();
-    const provider = new WsProvider(nodeUrl);
-    apiWrapper = await ApiWrapper.create(provider);
-  });
-
-  membershipTest(m1KeyPairs);
-  membershipTest(m2KeyPairs);
-  councilTest(m1KeyPairs, m2KeyPairs);
-
-  // TODO implement the test
-  it('Mint capacity proposal test', async () => {
-    // Setup
-    sudo = keyring.addFromUri(sudoUri);
-    const description: string = 'spending proposal which is used for API network testing';
-    const runtimeVoteFee: BN = apiWrapper.estimateVoteForProposalFee();
-
-    // Topping the balances
-    const proposalStake: BN = await apiWrapper.getRequiredProposalStake(25, 10000);
-    const runtimeProposalFee: BN = apiWrapper.estimateProposeWorkingGroupMintCapacityFee(
-      description,
-      description,
-      proposalStake,
-      mintingCapacity
-    );
-    await apiWrapper.transferBalance(sudo, m1KeyPairs[0].address, runtimeProposalFee.add(proposalStake));
-    await apiWrapper.transferBalanceToAccounts(sudo, m2KeyPairs, runtimeVoteFee);
-
-    // Proposal creation
-    const proposalPromise = apiWrapper.expectProposalCreated();
-    await apiWrapper.proposeWorkingGroupMintCapacity(
-      m1KeyPairs[0],
-      'testing mint capacity' + uuid().substring(0, 8),
-      'mint capacity to test proposal functionality' + uuid().substring(0, 8),
-      proposalStake,
-      mintingCapacity
-    );
-    const proposalNumber = await proposalPromise;
-
-    // Approving runtime update proposal
-    const runtimePromise = apiWrapper.expectProposalFinalized();
-    await apiWrapper.batchApproveProposal(m2KeyPairs, proposalNumber);
-    await runtimePromise;
-  }).timeout(defaultTimeout);
-
-  after(() => {
-    apiWrapper.close();
-  });
-});

+ 2 - 2
tests/network-tests/src/utils/apiWrapper.ts

@@ -62,8 +62,8 @@ export class ApiWrapper {
   }
 
   public async transferBalanceToAccounts(from: KeyringPair, to: KeyringPair[], amount: BN): Promise<void> {
-    for (let i = 0; i < to.length; i++) {
-      await this.transferBalance(from, to[i].address, amount);
+    for (const keyPair of to) {
+      await this.transferBalance(from, keyPair.address, amount);
     }
     return;
   }