15
15
16
16
use super :: * ;
17
17
use cumulus_primitives_core:: XcmpMessageHandler ;
18
- use mock:: { new_test_ext, XcmpQueue } ;
18
+ use mock:: { new_test_ext, Test , XcmpQueue } ;
19
19
20
20
#[ test]
21
21
fn one_message_does_not_panic ( ) {
@@ -27,3 +27,35 @@ fn one_message_does_not_panic() {
27
27
XcmpQueue :: handle_xcmp_messages ( messages. into_iter ( ) , Weight :: max_value ( ) ) ;
28
28
} )
29
29
}
30
+
31
+ #[ test]
32
+ #[ should_panic = "Invalid incoming blob message data" ]
33
+ fn bad_message_is_handled ( ) {
34
+ new_test_ext ( ) . execute_with ( || {
35
+ let bad_data = vec ! [
36
+ 1 , 1 , 3 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 , 64 , 239 , 139 , 0 ,
37
+ 0 , 0 , 64 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 255 , 255 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 37 , 0 ,
38
+ 0 , 0 , 0 , 0 , 0 , 0 , 16 , 0 , 127 , 147 ,
39
+ ] ;
40
+ InboundXcmpMessages :: < Test > :: insert ( ParaId :: from ( 1000 ) , 1 , bad_data) ;
41
+ let format = XcmpMessageFormat :: ConcatenatedEncodedBlob ;
42
+ // This should exit with an error.
43
+ XcmpQueue :: process_xcmp_message ( 1000 . into ( ) , ( 1 , format) , 10_000_000_000 ) ;
44
+ } ) ;
45
+ }
46
+
47
+ #[ test]
48
+ #[ should_panic = "Invalid incoming blob message data" ]
49
+ fn other_bad_message_is_handled ( ) {
50
+ new_test_ext ( ) . execute_with ( || {
51
+ let bad_data = vec ! [
52
+ 1 , 1 , 1 , 1 , 3 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 1 , 0 , 0 , 0 , 64 , 239 ,
53
+ 139 , 0 , 0 , 0 , 64 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 255 , 255 , 0 , 0 , 0 , 0 , 0 , 0 , 0 ,
54
+ 37 , 0 , 0 , 0 , 0 , 0 , 0 , 0 , 16 , 0 , 127 , 147 ,
55
+ ] ;
56
+ InboundXcmpMessages :: < Test > :: insert ( ParaId :: from ( 1000 ) , 1 , bad_data) ;
57
+ let format = XcmpMessageFormat :: ConcatenatedEncodedBlob ;
58
+ // This should exit with an error.
59
+ XcmpQueue :: process_xcmp_message ( 1000 . into ( ) , ( 1 , format) , 10_000_000_000 ) ;
60
+ } ) ;
61
+ }
0 commit comments