git.delta.rocks / unique-network / refs/commits / 32beeafd531f

difftreelog

test(CollatorSelection) verification of correct block authoring

Fahrrader2022-04-01parent: #ca41422.patch.diff
in: master

2 files changed

modifiedruntime/common/mod.rsdiffbeforeafterboth
--- a/runtime/common/mod.rs
+++ b/runtime/common/mod.rs
@@ -224,7 +224,7 @@
 					.collect::<Vec<_>>(),
 			)
 			.expect("Existing collators/invulnerables are more than MaxInvulnerables");
-			
+
 			<pallet_collator_selection::Invulnerables<Runtime>>::put(bounded_invulnerables);
 			<pallet_collator_selection::DesiredCandidates<Runtime>>::put(0);
 			<pallet_collator_selection::CandidacyBond<Runtime>>::put(EXISTENTIAL_DEPOSIT * 16);
@@ -248,7 +248,7 @@
 				// todo exercise caution, the following is taken from genesis
 				if frame_system::Pallet::<Runtime>::inc_consumers_without_limit(&account).is_err() {
 					log::warn!(
-						"We have entered an error with incrementing consumers without limit"
+						"We have entered an error with incrementing consumers without limit during the migration"
 					);
 					// This will leak a provider reference, however it only happens once (at
 					// genesis) so it's really not a big deal and we assume that the user wants to
modifiedtests/src/shuffleCollators.test.tsdiffbeforeafterboth
19import 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';
2323
24let 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;
2929
30describe('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 });
4040
65 const result = getGenericResult(events);65 const result = getGenericResult(events);
66 expect(result.success).to.be.true;66 expect(result.success).to.be.true;
6767
68 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);
7171
74 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 needed
78 }78 }
7979
80 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);
8383
84 // 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