|
@@ -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();
|
|
|
- });
|
|
|
-});
|