Skip to content

Commit

Permalink
fix a bug where decode_capability_ads did not wrap skip_string in…
Browse files Browse the repository at this point in the history
… `prompt_pkt`
  • Loading branch information
ulugbekna committed Jan 29, 2021
1 parent 44c2129 commit 97a1d3b
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 12 deletions.
3 changes: 0 additions & 3 deletions src/not-so-smart/decoder.ml
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ let at_least_one_line decoder =
let pkt_len_unsafe (decoder : decoder) =
let hex = Bytes.of_string "0x0000" in
Bytes.blit decoder.buffer decoder.pos hex 2 4;
Log.debug (fun m ->
m "hex: %s buffer: %s" (Bytes.to_string hex)
(Bytes.to_string decoder.buffer));
int_of_string (Bytes.unsafe_to_string hex)

(* no header *)
Expand Down
9 changes: 3 additions & 6 deletions src/not-so-smart/fetch.ml
Original file line number Diff line number Diff line change
Expand Up @@ -152,20 +152,17 @@ struct
(Proto_vals_v2.Proto_request.upload_pack ~host ~version:2 path))
else return ()
in
let* server_caps =
Wire_proto_v2.(recv ctx Witness.Capability_advertisement)
in
return server_caps
Wire_proto_v2.(recv ctx Witness.Capability_advertisement)

let get_server_capabilities ?(uses_git_transport = false) ~host ~path ctx
flow =
let get_caps =
let get_caps ctx =
let ( let* ) = Wire_proto_v2.( let* ) in
let* caps = connect ~uses_git_transport ~host ~path ctx in
let* () = Wire_proto_v2.send ctx Flush () in
Wire_proto_v2.return caps
in
State_flow.run sched fail io flow get_caps |> prj
State_flow.run sched fail io flow (get_caps ctx) |> prj

(* let connect ?(uses_git_transport = false) ~host path flow access =
Wire_proto_v2_flow *)
Expand Down
2 changes: 1 addition & 1 deletion src/not-so-smart/proto_vals_v2.ml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ module Decoder = struct
value = 1*(ALPHA | DIGIT | " -_.,?\/{}[]()<>!@#$%^&*+=:;") *)
let decode_capability_ads decoder =
(* protocol-version *)
skip_string "version 2" decoder >>= fun () ->
prompt_pkt (skip_string "version 2") decoder >>= fun () ->
let expected = `Pkt [ `Str "key[=value] LF" ] in

(* capability-list
Expand Down
7 changes: 5 additions & 2 deletions test/smart/test.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1685,11 +1685,14 @@ module Proto_v2 = struct
in
let path = "not-found.git" in
let proto_ctx = Wire_proto_v2.Context.make ~client_caps:[] in
let* run =
let* capabilities =
Fetch.V2.get_server_capabilities ~uses_git_transport:false ~host ~path
proto_ctx flow
in
assert (not (List.length run = 0));
Alcotest.(check bool)
"capability list is not empty"
(List.length capabilities > 0)
true;
Lwt.return ()
end

Expand Down

0 comments on commit 97a1d3b

Please sign in to comment.