@@ -1201,49 +1201,46 @@ mod tests {
1201
1201
// Needs to be run to initialize first slot and epoch numbers;
1202
1202
advance_block ( ) ;
1203
1203
1204
- // Scheduled committee goes into effect after a 2-epoch delay
1204
+ // Committee goes into effect 1-epoch and 1-block after selection
1205
1205
set_committee_through_inherent_data ( & [ alice ( ) ] ) ;
1206
1206
until_epoch_after_finalizing ( 1 , & || {
1207
- assert_current_epoch ! ( 0 ) ;
1208
1207
assert_grandpa_weights ( ) ;
1209
1208
assert_grandpa_authorities ! ( [ alice( ) , bob( ) ] ) ;
1210
1209
} ) ;
1211
-
1210
+ for_next_n_blocks_after_finalizing ( 1 , & || {
1211
+ assert_grandpa_weights ( ) ;
1212
+ assert_grandpa_authorities ! ( [ alice( ) , bob( ) ] ) ;
1213
+ } ) ;
1212
1214
set_committee_through_inherent_data ( & [ bob ( ) ] ) ;
1213
1215
for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH , & || {
1214
- assert_current_epoch ! ( 1 ) ;
1215
1216
assert_grandpa_weights ( ) ;
1216
- assert_grandpa_authorities ! ( [ alice( ) , bob ( ) ] ) ;
1217
+ assert_grandpa_authorities ! ( [ alice( ) ] ) ;
1217
1218
} ) ;
1218
1219
set_committee_through_inherent_data ( & [ alice ( ) ] ) ;
1219
1220
for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH , & || {
1220
- assert_current_epoch ! ( 2 ) ;
1221
1221
assert_grandpa_weights ( ) ;
1222
- assert_grandpa_authorities ! ( [ alice ( ) ] ) ;
1222
+ assert_grandpa_authorities ! ( [ bob ( ) ] ) ;
1223
1223
} ) ;
1224
1224
set_committee_through_inherent_data ( & [ alice ( ) , bob ( ) ] ) ;
1225
1225
for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH , & || {
1226
- assert_current_epoch ! ( 3 ) ;
1227
1226
assert_grandpa_weights ( ) ;
1228
- assert_grandpa_authorities ! ( [ bob ( ) ] ) ;
1227
+ assert_grandpa_authorities ! ( [ alice ( ) ] ) ;
1229
1228
} ) ;
1230
1229
set_committee_through_inherent_data ( & [ bob ( ) , alice ( ) ] ) ;
1231
1230
for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH , & || {
1232
- assert_current_epoch ! ( 4 ) ;
1233
1231
assert_grandpa_weights ( ) ;
1234
- assert_grandpa_authorities ! ( [ alice( ) ] ) ;
1232
+ assert_grandpa_authorities ! ( [ alice( ) , bob ( ) ] ) ;
1235
1233
} ) ;
1236
1234
set_committee_through_inherent_data ( & [ alice ( ) ] ) ;
1237
1235
for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH , & || {
1238
- assert_current_epoch ! ( 5 ) ;
1239
1236
assert_grandpa_weights ( ) ;
1240
- assert_grandpa_authorities ! ( [ alice ( ) , bob ( ) ] ) ;
1237
+ assert_grandpa_authorities ! ( [ bob ( ) , alice ( ) ] ) ;
1241
1238
} ) ;
1242
1239
1243
1240
// When there's no new committees being scheduled, the last committee stays in power
1244
1241
for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH * 3 , & || {
1245
1242
assert_grandpa_weights ( ) ;
1246
- assert_grandpa_authorities ! ( [ bob ( ) , alice( ) ] ) ;
1243
+ assert_grandpa_authorities ! ( [ alice( ) ] ) ;
1247
1244
} ) ;
1248
1245
} ) ;
1249
1246
@@ -1260,39 +1257,33 @@ mod tests {
1260
1257
new_test_ext ( ) . execute_with ( || {
1261
1258
// Needs to be run to initialize first slot and epoch numbers;
1262
1259
advance_block ( ) ;
1263
-
1264
- // Scheduled committee goes into effect after a 2-epoch delay
1260
+ // Committee goes into effect 1-epoch and 1-block after selection
1265
1261
set_committee_through_inherent_data ( & [ alice ( ) ] ) ;
1266
1262
until_epoch_after_finalizing ( 1 , & || {
1267
- assert_current_epoch ! ( 0 ) ;
1268
1263
assert_aura_authorities ! ( [ alice( ) , bob( ) ] ) ;
1269
1264
} ) ;
1270
-
1271
- set_committee_through_inherent_data ( & [ bob ( ) ] ) ;
1272
- for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH , & || {
1273
- assert_current_epoch ! ( 1 ) ;
1265
+ for_next_n_blocks_after_finalizing ( 1 , & || {
1274
1266
assert_aura_authorities ! ( [ alice( ) , bob( ) ] ) ;
1275
1267
} ) ;
1276
- set_committee_through_inherent_data ( & [ alice ( ) ] ) ;
1268
+ set_committee_through_inherent_data ( & [ bob ( ) ] ) ;
1277
1269
for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH , & || {
1278
- assert_current_epoch ! ( 2 ) ;
1279
1270
assert_aura_authorities ! ( [ alice( ) ] ) ;
1280
1271
} ) ;
1281
- set_committee_through_inherent_data ( & [ alice ( ) , bob ( ) ] ) ;
1272
+ set_committee_through_inherent_data ( & [ alice ( ) ] ) ;
1282
1273
for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH , & || {
1283
- assert_current_epoch ! ( 3 ) ;
1284
1274
assert_aura_authorities ! ( [ bob( ) ] ) ;
1285
1275
} ) ;
1286
- set_committee_through_inherent_data ( & [ bob ( ) , alice ( ) ] ) ;
1276
+ set_committee_through_inherent_data ( & [ alice ( ) , bob ( ) ] ) ;
1287
1277
for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH , & || {
1288
- assert_current_epoch ! ( 4 ) ;
1289
1278
assert_aura_authorities ! ( [ alice( ) ] ) ;
1290
1279
} ) ;
1291
- set_committee_through_inherent_data ( & [ alice ( ) ] ) ;
1280
+ set_committee_through_inherent_data ( & [ bob ( ) , alice ( ) ] ) ;
1292
1281
for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH , & || {
1293
- assert_current_epoch ! ( 5 ) ;
1294
1282
assert_aura_authorities ! ( [ alice( ) , bob( ) ] ) ;
1295
1283
} ) ;
1284
+ for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH , & || {
1285
+ assert_aura_authorities ! ( [ bob( ) , alice( ) ] ) ;
1286
+ } ) ;
1296
1287
1297
1288
// When there's no new committees being scheduled, the last committee stays in power
1298
1289
for_next_n_blocks_after_finalizing ( SLOTS_PER_EPOCH * 3 , & || {
@@ -1326,9 +1317,7 @@ mod tests {
1326
1317
} ) ;
1327
1318
}
1328
1319
1329
- pub fn set_committee_through_inherent_data (
1330
- expected_authorities : & [ TestKeys ] ,
1331
- ) -> PostDispatchInfo {
1320
+ fn set_committee_through_inherent_data ( expected_authorities : & [ TestKeys ] ) -> PostDispatchInfo {
1332
1321
let epoch = Sidechain :: current_epoch_number ( ) ;
1333
1322
let slot = * pallet_aura:: CurrentSlot :: < Test > :: get ( ) ;
1334
1323
println ! (
0 commit comments