difftreelog
test(collator-selection) intermediate changes and fixes to tests + minor refactor
in: master
6 files changed
pallets/collator-selection/src/lib.rsdiffbeforeafterbothno syntactic changes
pallets/collator-selection/src/tests.rsdiffbeforeafterboth50 });50 });51}51}5253// todo:collator add more tests later525453#[test]55#[test]54fn it_should_set_invulnerables() {56fn it_should_add_invulnerables() {55 new_test_ext().execute_with(|| {57 new_test_ext().execute_with(|| {56 let new_set = vec![1, 2, 3, 4];58 assert_ok!(CollatorSelection::add_invulnerable(59 RuntimeOrigin::signed(RootAccount::get()),60 161 ));57 assert_ok!(CollatorSelection::set_invulnerables(62 assert_ok!(CollatorSelection::add_invulnerable(58 RuntimeOrigin::signed(RootAccount::get()),63 RuntimeOrigin::signed(RootAccount::get()),59 new_set.clone()64 260 ));65 ));61 assert_eq!(CollatorSelection::invulnerables(), new_set);66 assert_eq!(CollatorSelection::invulnerables(), vec![1, 2]);626763 // cannot set with non-root.68 // cannot set with non-root.64 assert_noop!(69 assert_noop!(65 CollatorSelection::set_invulnerables(RuntimeOrigin::signed(1), new_set.clone()),70 CollatorSelection::add_invulnerable(RuntimeOrigin::signed(1), 3),66 BadOrigin71 BadOrigin67 );72 );687369 // cannot set invulnerables without associated validator keys74 // cannot set invulnerables without associated validator keys70 let invulnerables = vec![7];71 assert_noop!(75 assert_noop!(72 CollatorSelection::set_invulnerables(76 CollatorSelection::add_invulnerable(73 RuntimeOrigin::signed(RootAccount::get()),77 RuntimeOrigin::signed(RootAccount::get()),74 invulnerables.clone()78 775 ),79 ),76 Error::<Test>::ValidatorNotRegistered80 Error::<Test>::ValidatorNotRegistered77 );81 );78 });82 });79}83}8485#[test]86fn it_should_remove_invulnerables() {87 new_test_ext().execute_with(|| {88 assert_ok!(CollatorSelection::add_invulnerable(89 RuntimeOrigin::signed(RootAccount::get()),90 191 ));92 assert_ok!(CollatorSelection::add_invulnerable(93 RuntimeOrigin::signed(RootAccount::get()),94 295 ));9697 // cannot remove with non-root.98 assert_noop!(99 CollatorSelection::remove_invulnerable(RuntimeOrigin::signed(1), 3),100 BadOrigin101 );102103 assert_ok!(CollatorSelection::remove_invulnerable(104 RuntimeOrigin::signed(RootAccount::get()),105 2106 ));107 assert_eq!(CollatorSelection::invulnerables(), vec![1]);108109 // cannot remove an invulnerable if there would be 0 invulnerables.110 assert_noop!(111 CollatorSelection::add_invulnerable(112 RuntimeOrigin::signed(RootAccount::get()), 113 1114 ),115 Error::<Test>::NotInvulnerable116 );117 });118}8011981#[test]120#[test]82fn set_desired_candidates_works() {121fn set_desired_candidates_works() {404 deposit: 10,443 deposit: 10,405 };444 };406 assert_eq!(CollatorSelection::candidates(), vec![collator]);445 assert_eq!(CollatorSelection::candidates(), vec![collator]);446 assert_eq!(CollatorSelection::kick_threshold(), 1);407 assert_eq!(CollatorSelection::last_authored_block(4), 20);447 assert_eq!(CollatorSelection::last_authored_block(4), 20);408 initialize_to_block(30);448 initialize_to_block(30);409 // 3 gets kicked after 1 session delay449 // 3 gets kicked after 1 session delay457 let collator_selection = collator_selection::GenesisConfig::<Test> {497 let collator_selection = collator_selection::GenesisConfig::<Test> {458 desired_candidates: 2,498 desired_candidates: 2,459 candidacy_bond: 10,499 candidacy_bond: 10,500 kick_threshold: 1,460 invulnerables,501 invulnerables,461 };502 };462 // collator selection must be initialized before session.503 // collator selection must be initialized before session.primitives/common/src/constants.rsdiffbeforeafterboth47/// Amount of Balance reserved for candidate registration.47/// Amount of Balance reserved for candidate registration.48pub const GENESIS_CANDIDACY_BOND: u128 = EXISTENTIAL_DEPOSIT;48pub const GENESIS_CANDIDACY_BOND: u128 = EXISTENTIAL_DEPOSIT;49/// How long a periodic session lasts in blocks.49/// How long a periodic session lasts in blocks.50pub const SESSION_LENGTH: BlockNumber = MINUTES;50pub const SESSION_LENGTH: BlockNumber = HOURS;515152// Targeting 0.1 UNQ per transfer52// Targeting 0.1 UNQ per transfer53pub const WEIGHT_TO_FEE_COEFF: u32 = /*<weight2fee>*/175_199_920/*</weight2fee>*/;53pub const WEIGHT_TO_FEE_COEFF: u32 = /*<weight2fee>*/175_199_920/*</weight2fee>*/;tests/package.jsondiffbeforeafterboth85 "testSchedulingEVM": "mocha --timeout 9999999 -r ts-node/register ./**/eth/scheduling.test.ts",85 "testSchedulingEVM": "mocha --timeout 9999999 -r ts-node/register ./**/eth/scheduling.test.ts",86 "testPalletPresence": "mocha --timeout 9999999 -r ts-node/register ./**/pallet-presence.test.ts",86 "testPalletPresence": "mocha --timeout 9999999 -r ts-node/register ./**/pallet-presence.test.ts",87 "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts",87 "testBlockProduction": "mocha --timeout 9999999 -r ts-node/register ./**/block-production.test.ts",88 "testCollatorSelection": "mocha --timeout 9999999 -r ts-node/register ./**/collatorSelection.test.ts",88 "testCollatorSelection": "mocha --timeout 9999999 -r ts-node/register ./**/collatorSelection.*test.ts",89 "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts",89 "testEnableDisableTransfers": "mocha --timeout 9999999 -r ts-node/register ./**/enableDisableTransfer.test.ts",90 "testLimits": "mocha --timeout 9999999 -r ts-node/register ./**/limits.test.ts",90 "testLimits": "mocha --timeout 9999999 -r ts-node/register ./**/limits.test.ts",91 "testEthCreateNFTCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createNFTCollection.test.ts",91 "testEthCreateNFTCollection": "mocha --timeout 9999999 -r ts-node/register ./**/eth/createNFTCollection.test.ts",tests/src/collatorSelection.seqtest.tsdiffbeforeafterbothno changes
tests/src/collatorSelection.test.tsdiffbeforeafterbothno changes