@@ -57,33 +57,38 @@ fn test_no_extrinsic_index() {
57
57
} ) ;
58
58
}
59
59
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 {
64
67
assert_ok ! ( Blobs :: submit_blob(
65
68
RuntimeOrigin :: signed( alice( ) ) ,
66
69
i,
67
70
blob. clone( )
68
71
) ) ;
69
72
}
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) ;
78
73
} ) ;
79
74
}
80
75
81
76
#[ test]
82
77
#[ should_panic = "Maximum blob limit exceeded" ]
83
78
fn test_max_blobs_exceeded ( ) {
84
79
let max_blobs: u32 = <Test as pallet_blobs:: Config >:: MaxBlobs :: get ( ) ;
80
+
85
81
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 ( ) ) ;
87
92
} ) ;
88
93
}
89
94
@@ -94,7 +99,14 @@ fn test_max_total_blob_size_reached() {
94
99
let blobs_needed = max_total_blobs_size / max_blob_size;
95
100
96
101
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
+ }
98
110
} ) ;
99
111
}
100
112
@@ -106,7 +118,15 @@ fn test_max_total_blob_size_exceeded() {
106
118
let blobs_needed = max_total_blobs_size / max_blob_size;
107
119
108
120
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 ( ) ) ;
110
130
} ) ;
111
131
}
112
132
0 commit comments