Skip to content

Commit

Permalink
add task more than limit
Browse files Browse the repository at this point in the history
  • Loading branch information
haider-rs committed Jul 19, 2024
1 parent 5ad5702 commit 6d33940
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions pallets/tasks/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1841,6 +1841,36 @@ fn test_multi_shard_distribution() {
});
}

#[test]
fn test_multi_shard_distribution_task_more_than_limit() {
new_test_ext().execute_with(|| {
// Shard creation
for i in 0..3 {
Shards::create_shard(
ETHEREUM,
[[0u8; 32].into(), [1u8; 32].into(), [2u8; 32].into()].to_vec(),
1,
);
ShardState::<Test>::insert(i, ShardStatus::Online);
Tasks::shard_online(i, ETHEREUM);
}

assert_ok!(Tasks::set_shard_task_limit(RawOrigin::Root.into(), ETHEREUM, 5));

// Tasks creation and assingment
for _ in 0..30 {
assert_ok!(Tasks::create_task(
RawOrigin::Signed([0; 32].into()).into(),
mock_task(ETHEREUM, 3)
));
}

assert_eq!(ShardTasks::<Test>::iter_prefix(0).count(), 5);
assert_eq!(ShardTasks::<Test>::iter_prefix(1).count(), 5);
assert_eq!(ShardTasks::<Test>::iter_prefix(2).count(), 5);
});
}

#[test]
fn test_assingment_with_diff_shard_size() {
new_test_ext().execute_with(|| {
Expand Down

0 comments on commit 6d33940

Please sign in to comment.