@@ -801,32 +801,6 @@ pub mod pallet {
801801 }
802802}
803803
804- /// Getting storage keys for messages and lanes states. These keys are normally used when building
805- /// messages and lanes states proofs.
806- pub mod storage_keys {
807- use super :: * ;
808- use sp_core:: storage:: StorageKey ;
809-
810- /// Storage key of the outbound message in the runtime storage.
811- pub fn message_key ( pallet_prefix : & str , lane : & LaneId , nonce : MessageNonce ) -> StorageKey {
812- bp_runtime:: storage_map_final_key_blake2_128concat (
813- pallet_prefix,
814- "OutboundMessages" ,
815- & MessageKey { lane_id : * lane, nonce } . encode ( ) ,
816- )
817- }
818-
819- /// Storage key of the outbound message lane state in the runtime storage.
820- pub fn outbound_lane_data_key ( pallet_prefix : & str , lane : & LaneId ) -> StorageKey {
821- bp_runtime:: storage_map_final_key_blake2_128concat ( pallet_prefix, "OutboundLanes" , lane)
822- }
823-
824- /// Storage key of the inbound message lane state in the runtime storage.
825- pub fn inbound_lane_data_key ( pallet_prefix : & str , lane : & LaneId ) -> StorageKey {
826- bp_runtime:: storage_map_final_key_blake2_128concat ( pallet_prefix, "InboundLanes" , lane)
827- }
828- }
829-
830804/// AccountId of the shared relayer fund account.
831805///
832806/// This account is passed to `MessageDeliveryAndDispatchPayment` trait, and depending
@@ -1159,9 +1133,8 @@ mod tests {
11591133 REGULAR_PAYLOAD , TEST_LANE_ID , TEST_RELAYER_A , TEST_RELAYER_B ,
11601134 } ;
11611135 use bp_messages:: { UnrewardedRelayer , UnrewardedRelayersState } ;
1162- use frame_support:: { assert_noop, assert_ok, weights:: Weight } ;
1136+ use frame_support:: { assert_noop, assert_ok, storage :: generator :: StorageMap , weights:: Weight } ;
11631137 use frame_system:: { EventRecord , Pallet as System , Phase } ;
1164- use hex_literal:: hex;
11651138 use sp_runtime:: DispatchError ;
11661139
11671140 fn get_ready_for_events ( ) {
@@ -1889,45 +1862,6 @@ mod tests {
18891862 } ) ;
18901863 }
18911864
1892- #[ test]
1893- fn storage_message_key_computed_properly ( ) {
1894- // If this test fails, then something has been changed in module storage that is breaking
1895- // all previously crafted messages proofs.
1896- let storage_key = storage_keys:: message_key ( "BridgeMessages" , & * b"test" , 42 ) . 0 ;
1897- assert_eq ! (
1898- storage_key,
1899- hex!( "dd16c784ebd3390a9bc0357c7511ed018a395e6242c6813b196ca31ed0547ea79446af0e09063bd4a7874aef8a997cec746573742a00000000000000" ) . to_vec( ) ,
1900- "Unexpected storage key: {}" ,
1901- hex:: encode( & storage_key) ,
1902- ) ;
1903- }
1904-
1905- #[ test]
1906- fn outbound_lane_data_key_computed_properly ( ) {
1907- // If this test fails, then something has been changed in module storage that is breaking
1908- // all previously crafted outbound lane state proofs.
1909- let storage_key = storage_keys:: outbound_lane_data_key ( "BridgeMessages" , & * b"test" ) . 0 ;
1910- assert_eq ! (
1911- storage_key,
1912- hex!( "dd16c784ebd3390a9bc0357c7511ed0196c246acb9b55077390e3ca723a0ca1f44a8995dd50b6657a037a7839304535b74657374" ) . to_vec( ) ,
1913- "Unexpected storage key: {}" ,
1914- hex:: encode( & storage_key) ,
1915- ) ;
1916- }
1917-
1918- #[ test]
1919- fn inbound_lane_data_key_computed_properly ( ) {
1920- // If this test fails, then something has been changed in module storage that is breaking
1921- // all previously crafted inbound lane state proofs.
1922- let storage_key = storage_keys:: inbound_lane_data_key ( "BridgeMessages" , & * b"test" ) . 0 ;
1923- assert_eq ! (
1924- storage_key,
1925- hex!( "dd16c784ebd3390a9bc0357c7511ed01e5f83cf83f2127eb47afdc35d6e43fab44a8995dd50b6657a037a7839304535b74657374" ) . to_vec( ) ,
1926- "Unexpected storage key: {}" ,
1927- hex:: encode( & storage_key) ,
1928- ) ;
1929- }
1930-
19311865 #[ test]
19321866 fn actual_dispatch_weight_does_not_overlow ( ) {
19331867 run_test ( || {
@@ -2359,4 +2293,25 @@ mod tests {
23592293 ) ;
23602294 } ) ;
23612295 }
2296+
2297+ #[ test]
2298+ fn storage_keys_computed_properly ( ) {
2299+ assert_eq ! (
2300+ OutboundMessages :: <TestRuntime >:: storage_map_final_key( MessageKey {
2301+ lane_id: TEST_LANE_ID ,
2302+ nonce: 42
2303+ } ) ,
2304+ bp_messages:: storage_keys:: message_key( "Messages" , & TEST_LANE_ID , 42 ) . 0 ,
2305+ ) ;
2306+
2307+ assert_eq ! (
2308+ OutboundLanes :: <TestRuntime >:: storage_map_final_key( TEST_LANE_ID ) ,
2309+ bp_messages:: storage_keys:: outbound_lane_data_key( "Messages" , & TEST_LANE_ID ) . 0 ,
2310+ ) ;
2311+
2312+ assert_eq ! (
2313+ InboundLanes :: <TestRuntime >:: storage_map_final_key( TEST_LANE_ID ) ,
2314+ bp_messages:: storage_keys:: inbound_lane_data_key( "Messages" , & TEST_LANE_ID ) . 0 ,
2315+ ) ;
2316+ }
23622317}
0 commit comments