Skip to content

Commit a1b1861

Browse files
committed
Revert "small tests refactor"
This reverts commit 598ac01.
1 parent 075ead3 commit a1b1861

File tree

1 file changed

+35
-15
lines changed
  • sugondat-chain/pallets/blobs/src

1 file changed

+35
-15
lines changed

sugondat-chain/pallets/blobs/src/tests.rs

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -57,33 +57,38 @@ fn test_no_extrinsic_index() {
5757
});
5858
}
5959

60-
macro_rules! submit_blobs {
61-
([blob_size] $blob_size: expr, [blobs_number] $n_blobs: expr) => {
62-
let blob = get_blob($blob_size);
63-
for i in 0..$n_blobs {
60+
#[test]
61+
fn test_max_blobs_reached() {
62+
let max_blobs: u32 = <Test as pallet_blobs::Config>::MaxBlobs::get();
63+
64+
new_test_ext().execute_with(|| {
65+
let blob = get_blob(1);
66+
for i in 0..max_blobs {
6467
assert_ok!(Blobs::submit_blob(
6568
RuntimeOrigin::signed(alice()),
6669
i,
6770
blob.clone()
6871
));
6972
}
70-
};
71-
}
72-
73-
#[test]
74-
fn test_max_blobs_reached() {
75-
let max_blobs: u32 = <Test as pallet_blobs::Config>::MaxBlobs::get();
76-
new_test_ext().execute_with(|| {
77-
submit_blobs!([blob_size] 1, [blobs_number] max_blobs);
7873
});
7974
}
8075

8176
#[test]
8277
#[should_panic = "Maximum blob limit exceeded"]
8378
fn test_max_blobs_exceeded() {
8479
let max_blobs: u32 = <Test as pallet_blobs::Config>::MaxBlobs::get();
80+
8581
new_test_ext().execute_with(|| {
86-
submit_blobs!([blob_size] 1, [blobs_number] max_blobs + 1);
82+
let blob = get_blob(1);
83+
for i in 0..max_blobs {
84+
assert_ok!(Blobs::submit_blob(
85+
RuntimeOrigin::signed(alice()),
86+
i,
87+
blob.clone()
88+
));
89+
}
90+
91+
let _ = Blobs::submit_blob(RuntimeOrigin::signed(alice()), 0, blob.clone());
8792
});
8893
}
8994

@@ -94,7 +99,14 @@ fn test_max_total_blob_size_reached() {
9499
let blobs_needed = max_total_blobs_size / max_blob_size;
95100

96101
new_test_ext().execute_with(|| {
97-
submit_blobs!([blob_size] max_blob_size, [blobs_number] blobs_needed);
102+
let blob = get_blob(max_blob_size);
103+
for i in 0..blobs_needed {
104+
assert_ok!(Blobs::submit_blob(
105+
RuntimeOrigin::signed(alice()),
106+
i,
107+
blob.clone()
108+
));
109+
}
98110
});
99111
}
100112

@@ -106,7 +118,15 @@ fn test_max_total_blob_size_exceeded() {
106118
let blobs_needed = max_total_blobs_size / max_blob_size;
107119

108120
new_test_ext().execute_with(|| {
109-
submit_blobs!([blob_size] max_blob_size, [blobs_number] blobs_needed + 1);
121+
let blob = get_blob(max_blob_size);
122+
for i in 0..blobs_needed {
123+
assert_ok!(Blobs::submit_blob(
124+
RuntimeOrigin::signed(alice()),
125+
i,
126+
blob.clone()
127+
));
128+
}
129+
let _ = Blobs::submit_blob(RuntimeOrigin::signed(alice()), 0, blob.clone());
110130
});
111131
}
112132

0 commit comments

Comments
 (0)