3737% % a new route with a remote router node. This function should also be itempotent
3838% % so that it can be called only once.
3939register (_M1 , M2 , Opts ) ->
40- ? event (debug_pete , {register , {msg , M2 }}),
4140 Registered = hb_opts :get (registered , false , Opts ),
4241 case Registered of
4342 true ->
@@ -61,11 +60,18 @@ register(_M1, M2, Opts) ->
6160
6261 MissingParams = [Param || {Param , Value } <- Missing , Value =:= not_found ],
6362
64- {ok , Attestion } = dev_snp :generate (#{}, #{}, Opts ),
63+ {ok , Attestion } = dev_snp :generate (
64+ #{},
65+ #{},
66+ #{
67+ priv_wallet => hb :wallet (),
68+ snp_hashes => hb_opts :get (snp_hashes , #{}, Opts )
69+ }
70+ ),
71+ ? event (dev_router , {attestion , Attestion }),
6572 case MissingParams of
6673 [] ->
67- % All required parameters are present, proceed with registration
68- Req = #{
74+ case hb_http :post (RouterNode , #{
6975 <<" path" >> => <<" /router~n ode-process@1.0/schedule" >>,
7076 <<" method" >> => <<" POST" >>,
7177 <<" body" >> =>
@@ -82,8 +88,7 @@ register(_M1, M2, Opts) ->
8288 },
8389 Opts
8490 )
85- },
86- case hb_http :post (RouterNode , Req , Opts ) of
91+ }, Opts ) of
8792 {ok , _ } ->
8893 hb_http_server :set_opts (Opts #{ registered => true }),
8994 {ok , <<" Route registered." >>};
@@ -695,18 +700,16 @@ dynamic_router_test() ->
695700 {ok , Script } = file :read_file (" scripts/dynamic-router.lua" ),
696701 Run = hb_util :bin (rand :uniform (1337 )),
697702 Node = hb_http_server :start_node (Opts = #{
698- trusted => [
699- #{
700- vcpus => 1 ,
701- vcpu_type => 5 ,
702- vmm_type => 1 ,
703- guest_features => 1 ,
704- firmware => <<" b8c5d4082d5738db6b0fb0294174992738645df70c44cdecf7fad3a62244b788e7e408c582ee48a74b289f3acec78510" >>,
705- kernel => <<" 69d0cd7d13858e4fcef6bc7797aebd258730f215bc5642c4ad8e4b893cc67576" >>,
706- initrd => <<" da6dffff50373e1d393bf92cb9b552198b1930068176a046dda4e23bb725b3bb" >>,
707- append => <<" aaf13c9ed2e821ea8c82fcc7981c73a14dc2d01c855f09262d42090fa0424422" >>
708- }
709- ],
703+ trusted => [#{
704+ vcpus => 1 ,
705+ vcpu_type => 5 ,
706+ vmm_type => 1 ,
707+ guest_features => 1 ,
708+ firmware => <<" b8c5d4082d5738db6b0fb0294174992738645df70c44cdecf7fad3a62244b788e7e408c582ee48a74b289f3acec78510" >>,
709+ kernel => <<" 69d0cd7d13858e4fcef6bc7797aebd258730f215bc5642c4ad8e4b893cc67576" >>,
710+ initrd => <<" da6dffff50373e1d393bf92cb9b552198b1930068176a046dda4e23bb725b3bb" >>,
711+ append => <<" aaf13c9ed2e821ea8c82fcc7981c73a14dc2d01c855f09262d42090fa0424422" >>
712+ }],
710713 store => [
711714 #{
712715 <<" store-module" >> => hb_store_fs ,
@@ -719,7 +722,7 @@ dynamic_router_test() ->
719722 },
720723 route_provider => #{
721724 <<" path" >> =>
722- <<" /router~n ode-process@1.0/compute/routes~m essage@1.0" >>
725+ <<" /router~n ode-process@1.0/compute/routes~m essage@1.0" >>
723726 },
724727 node_processes => #{
725728 <<" router" >> => #{
@@ -785,7 +788,7 @@ dynamic_router_test() ->
785788 {Status , NodeRoutes } = hb_http :get (Node , <<" /router~n ode-process@1.0/now" >>, #{}),
786789 ? event (debug_dynrouter , {got_node_routes , NodeRoutes }),
787790 % Meta info is a part of the exempt routes. Make sure this returns our address
788- {ok , _Res } = hb_http :get (Node , <<" /~m eta@1.0/info/address" >>, Opts ),
791+ {ok , _ } = hb_http :get (Node , <<" /~m eta@1.0/info/address" >>, Opts ),
789792 % ?assertEqual(hb_util:human_id(ar_wallet:to_address(hb_opts:get(priv_wallet, not_found, Opts))), Res),
790793 % {Status, _} = hb_http:get(Node, <<"/RhguwWmQJ-wWCXhRH_NtTDHRRgfCqNDZckXtJK52zKs~process@1.0/compute&slot=1">>, Opts),
791794 ? assertEqual (ok , Status ).
0 commit comments