@@ -204,8 +204,9 @@ impl Adapter for EthereumAdapter {
204
204
let sess = match & verified. payload . identity {
205
205
Some ( identity) => {
206
206
let contract_address = Address :: from_slice ( identity) ;
207
- let ( _eloop, transport) = web3:: transports:: Http :: new ( & self . config . ethereum_network )
208
- . map_err ( |_| map_error ( "failed to init http transport" ) ) ?;
207
+ let ( _eloop, transport) =
208
+ web3:: transports:: Http :: new ( & self . config . ethereum_network )
209
+ . map_err ( |_| map_error ( "failed to init http transport" ) ) ?;
209
210
let web3 = web3:: Web3 :: new ( transport) ;
210
211
let contract = Contract :: from_json ( web3. eth ( ) , contract_address, & IDENTITY_ABI )
211
212
. map_err ( |_| map_error ( "failed to init identity contract" ) ) ?;
@@ -607,17 +608,21 @@ mod test {
607
608
608
609
// deploy identity contract
609
610
let ( eloop, http) =
610
- web3:: transports:: Http :: new ( "http://localhost:8545" ) . expect ( "failed to init transport" ) ;
611
+ web3:: transports:: Http :: new ( "http://localhost:8545" ) . expect ( "failed to init transport" ) ;
611
612
eloop. into_remote ( ) ;
612
613
613
614
let web3 = web3:: Web3 :: new ( http) ;
614
615
// part of address used in initializing ganache-cli
615
616
let leader_account: Address = "Df08F82De32B8d460adbE8D72043E3a7e25A3B39"
616
617
. parse ( )
617
618
. expect ( "failed to parse leader account" ) ;
618
-
619
- let eth_adapter_address: Address = eth_adapter. whoami ( ) . to_hex_non_prefix_string ( ) . parse ( ) . expect ( "failed to parse eth adapter address" ) ;
620
-
619
+
620
+ let eth_adapter_address: Address = eth_adapter
621
+ . whoami ( )
622
+ . to_hex_non_prefix_string ( )
623
+ . parse ( )
624
+ . expect ( "failed to parse eth adapter address" ) ;
625
+
621
626
let identity_bytecode = include_str ! ( "../test/resources/identitybytecode.json" ) ;
622
627
623
628
// deploy identity contract
@@ -628,17 +633,22 @@ mod test {
628
633
opt. gas_price = Some ( 1 . into ( ) ) ;
629
634
opt. gas = Some ( 6_721_975 . into ( ) ) ;
630
635
} ) )
631
- . execute ( identity_bytecode, (
632
- Token :: Array ( vec ! [ Token :: Address ( eth_adapter_address) ] ) ,
633
- Token :: Array ( vec ! [ Token :: Uint ( 1 . into( ) ) ] )
634
- ) , leader_account)
636
+ . execute (
637
+ identity_bytecode,
638
+ (
639
+ Token :: Array ( vec ! [ Token :: Address ( eth_adapter_address) ] ) ,
640
+ Token :: Array ( vec ! [ Token :: Uint ( 1 . into( ) ) ] ) ,
641
+ ) ,
642
+ leader_account,
643
+ )
635
644
. expect ( "Correct parameters are passed to the constructor." )
636
645
. wait ( )
637
646
. expect ( "failed to wait" ) ;
638
647
639
648
// identity contract address
640
- let identity = <[ u8 ; 20 ] >:: from_hex ( & format ! ( "{:?}" , identity_contract. address( ) ) [ 2 ..] ) . expect ( "failed to deserialize address" ) ;
641
-
649
+ let identity = <[ u8 ; 20 ] >:: from_hex ( & format ! ( "{:?}" , identity_contract. address( ) ) [ 2 ..] )
650
+ . expect ( "failed to deserialize address" ) ;
651
+
642
652
let payload = Payload {
643
653
id : eth_adapter. whoami ( ) . to_hex_checksummed_string ( ) ,
644
654
era : 100_000 ,
@@ -649,11 +659,11 @@ mod test {
649
659
let wallet = eth_adapter. wallet . clone ( ) ;
650
660
let response = ewt_sign ( & wallet. unwrap ( ) , & eth_adapter. keystore_pwd , & payload)
651
661
. expect ( "failed to generate ewt signature" ) ;
652
-
662
+
653
663
// verify since its with identity
654
- let session = eth_adapter. session_from_token ( & response) . expect ( "failed generate session" ) ;
664
+ let session = eth_adapter
665
+ . session_from_token ( & response)
666
+ . expect ( "failed generate session" ) ;
655
667
assert_eq ! ( session. uid. inner( ) , & identity) ;
656
668
}
657
-
658
-
659
669
}
0 commit comments