difftreelog
test(CollatorSelection) verification of correct block authoring
in: master
2 files changed
runtime/common/mod.rsdiffbeforeafterboth248 // todo exercise caution, the following is taken from genesis248 // todo exercise caution, the following is taken from genesis249 if frame_system::Pallet::<Runtime>::inc_consumers_without_limit(&account).is_err() {249 if frame_system::Pallet::<Runtime>::inc_consumers_without_limit(&account).is_err() {250 log::warn!(250 log::warn!(251 "We have entered an error with incrementing consumers without limit"251 "We have entered an error with incrementing consumers without limit during the migration"252 );252 );253 // This will leak a provider reference, however it only happens once (at253 // This will leak a provider reference, however it only happens once (at254 // genesis) so it's really not a big deal and we assume that the user wants to254 // genesis) so it's really not a big deal and we assume that the user wants totests/src/shuffleCollators.test.tsdiffbeforeafterboth19import usingApi, { submitTransactionAsync } from './substrate/substrate-api';19import usingApi, {submitTransactionAsync} from './substrate/substrate-api';20import waitNewBlocks from './substrate/wait-new-blocks';20import waitNewBlocks from './substrate/wait-new-blocks';21import {expect} from 'chai';21import {expect} from 'chai';22import { getGenericResult } from './util/helpers';22import {getBlockNumber, getGenericResult} from './util/helpers';232324let alice: IKeyringPair;24let alice: IKeyringPair;25let bob: IKeyringPair;25let bob: IKeyringPair;26let charlie: IKeyringPair;26let charlie: IKeyringPair;27let dave: IKeyringPair;27let dave: IKeyringPair;28let eve: IKeyringPair;28//let eve: IKeyringPair;292930describe('Integration Test: Dynamic shuffling of collators', () => {30describe('Integration Test: Dynamic shuffling of collators', () => {31 before(async () => { 31 before(async () => { 34 bob = privateKey('//Bob');34 bob = privateKey('//Bob');35 charlie = privateKey('//Charlie');35 charlie = privateKey('//Charlie');36 dave = privateKey('//Dave');36 dave = privateKey('//Dave');37 eve = privateKey('//Eve');37 //eve = privateKey('//Eve');38 });38 });39 });39 });404065 const result = getGenericResult(events);65 const result = getGenericResult(events);66 expect(result.success).to.be.true;66 expect(result.success).to.be.true;676768 let newInvulnerables = (await api.query.collatorSelection.invulnerables()).toJSON();68 const newInvulnerables = (await api.query.collatorSelection.invulnerables()).toJSON();69 expect(newInvulnerables).to.contain(charlie.address).and.contain(dave.address);69 expect(newInvulnerables).to.contain(charlie.address).and.contain(dave.address);70 expect(newInvulnerables).to.be.length(2);70 expect(newInvulnerables).to.be.length(2);717174 while (currentSessionIndex < expectedSessionIndex) {74 while (currentSessionIndex < expectedSessionIndex) {75 await waitNewBlocks(api, 1);75 await waitNewBlocks(api, 1);76 currentSessionIndex = (await api.query.session.currentIndex() as any).toNumber();76 currentSessionIndex = (await api.query.session.currentIndex() as any).toNumber();77 // todo implement a timeout in case new blocks are not being produced77 // todo implement a timeout in case new blocks are not being produced? session length needed78 }78 }797980 let newValidators = (await api.query.session.validators()).toJSON();80 const newValidators = (await api.query.session.validators()).toJSON();81 expect(newValidators).to.contain(charlie.address).and.contain(dave.address);81 expect(newValidators).to.contain(charlie.address).and.contain(dave.address);82 expect(newValidators).to.be.length(2);82 expect(newValidators).to.be.length(2);838384 // todo add delay to check that new blocks are authored by these84 const lastBlockNumber = await getBlockNumber(api);85 await waitNewBlocks(api, 1);86 const lastCharlieBlock = (await api.query.collatorSelection.lastAuthoredBlock(charlie.address) as any).toNumber();87 const lastDaveBlock = (await api.query.collatorSelection.lastAuthoredBlock(dave.address) as any).toNumber();88 expect(lastCharlieBlock >= lastBlockNumber || lastDaveBlock >= lastBlockNumber).to.be.true;85 });89 });86 });90 });8791