1234567891011121314151617import {ApiPromise} from '@polkadot/api';18import {IKeyringPair} from '@polkadot/types/types';19import privateKey from './substrate/privateKey';20import usingApi, { submitTransactionAsync } from './substrate/substrate-api';21import waitNewBlocks from './substrate/wait-new-blocks';22import {expect} from 'chai';23import { getGenericResult } from './util/helpers';242526let alice: IKeyringPair;27let bob: IKeyringPair;28let charlie: IKeyringPair;29let dave: IKeyringPair;30let eve: IKeyringPair;3132const alice_port = 31200;33const bob_port = 31201;3435describe('Make me a big great cloud', () => {36 before(async () => { 37 await usingApi(async () => {38 alice = privateKey('//Alice');39 bob = privateKey('//Bob');40 charlie = privateKey('//Charlie');41 dave = privateKey('//Dave');42 eve = privateKey('//Eve');43 });44 });4546 it('Can\\t stand the heat', async () => {47 48 49 50 5152 53 54 5556 await usingApi(async (api) => {57 5859 const tx = api.tx.session.setKeys(60 '0x' + Buffer.from(charlie.addressRaw).toString('hex'),61 '0x0'62 );63 const events = await submitTransactionAsync(charlie, tx);64 const result = getGenericResult(events);65 expect(result.success).to.be.true;6667 const tx2 = api.tx.collatorSelection.setInvulnerables([68 bob.address,69 charlie.address70 ]);71 const sudoTx = api.tx.sudo.sudo(tx2 as any);72 const events2 = await submitTransactionAsync(alice, sudoTx);73 const result2 = getGenericResult(events2);74 expect(result2.success).to.be.true;7576 let newInvulnerables = (await api.query.collatorSelection.invulnerables()).toJSON();77 expect(newInvulnerables).to.contain(charlie.address);7879 const expectedSessionIndex = (await api.query.session.currentIndex() as any).toNumber() + 2;80 let currentSessionIndex = -1;81 while (currentSessionIndex < expectedSessionIndex) {82 await waitNewBlocks(api, 1);83 currentSessionIndex = (await api.query.session.currentIndex() as any).toNumber();84 85 }86 });87 });88});