@@ -31,7 +31,7 @@ use std::time::Duration;
3131pub type HeaderId = relay_utils:: HeaderId < millau_runtime:: Hash , millau_runtime:: BlockNumber > ;
3232
3333/// Millau chain definition.
34- #[ derive( Debug , Clone , Copy ) ]
34+ #[ derive( Debug , Clone , Copy , PartialEq ) ]
3535pub struct Millau ;
3636
3737impl ChainBase for Millau {
@@ -154,8 +154,8 @@ impl TransactionSignScheme for Millau {
154154 let extra = & tx. signature . as_ref ( ) ?. 2 ;
155155 Some ( UnsignedTransaction {
156156 call : tx. function . into ( ) ,
157- nonce : Compact :: < IndexOf < Self :: Chain > > :: decode ( & mut & extra. 4 . encode ( ) [ ..] ) . ok ( ) ?. into ( ) ,
158- tip : Compact :: < BalanceOf < Self :: Chain > > :: decode ( & mut & extra. 6 . encode ( ) [ ..] )
157+ nonce : Compact :: < IndexOf < Self :: Chain > > :: decode ( & mut & extra. 5 . encode ( ) [ ..] ) . ok ( ) ?. into ( ) ,
158+ tip : Compact :: < BalanceOf < Self :: Chain > > :: decode ( & mut & extra. 7 . encode ( ) [ ..] )
159159 . ok ( ) ?
160160 . into ( ) ,
161161 } )
@@ -167,3 +167,32 @@ pub type SigningParams = sp_core::sr25519::Pair;
167167
168168/// Millau header type used in headers sync.
169169pub type SyncHeader = relay_substrate_client:: SyncHeader < millau_runtime:: Header > ;
170+
171+ #[ cfg( test) ]
172+ mod tests {
173+ use super :: * ;
174+ use relay_substrate_client:: TransactionEra ;
175+
176+ #[ test]
177+ fn parse_transaction_works ( ) {
178+ let unsigned = UnsignedTransaction {
179+ call : millau_runtime:: Call :: System ( millau_runtime:: SystemCall :: remark {
180+ remark : b"Hello world!" . to_vec ( ) ,
181+ } )
182+ . into ( ) ,
183+ nonce : 777 ,
184+ tip : 888 ,
185+ } ;
186+ let signed_transaction = Millau :: sign_transaction ( SignParam {
187+ spec_version : 42 ,
188+ transaction_version : 50000 ,
189+ genesis_hash : [ 42u8 ; 64 ] . into ( ) ,
190+ signer : sp_core:: sr25519:: Pair :: from_seed_slice ( & [ 1u8 ; 32 ] ) . unwrap ( ) ,
191+ era : TransactionEra :: immortal ( ) ,
192+ unsigned : unsigned. clone ( ) ,
193+ } )
194+ . unwrap ( ) ;
195+ let parsed_transaction = Millau :: parse_transaction ( signed_transaction) . unwrap ( ) ;
196+ assert_eq ! ( parsed_transaction, unsigned) ;
197+ }
198+ }
0 commit comments