Skip to content

Commit

Permalink
update proto service (#863)
Browse files Browse the repository at this point in the history
* make sure CI commands have grpc gen files available

* update for updated packet_router proto service

- service name `gateway` -> `packet`
- rpc `send_packet` -> `route`
  • Loading branch information
michaeldjeffrey authored Oct 5, 2022
1 parent 5f9bd68 commit c4cad7b
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 19 deletions.
10 changes: 6 additions & 4 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ jobs:
mkdir _build
tar -xvf build.tar.gz -C _build
- name: xref
run: ./rebar3 xref
run: make xref
eunit:
needs: build
runs-on: ubuntu-latest
Expand All @@ -90,7 +90,7 @@ jobs:
mkdir _build
tar -xvf build.tar.gz -C _build
- name: eunit
run: ./rebar3 eunit -v
run: make eunit -v
dialyzer:
needs: build
runs-on: ubuntu-latest
Expand All @@ -111,7 +111,7 @@ jobs:
mkdir _build
tar -xvf build.tar.gz -C _build
- name: dialyzer
run: ./rebar3 dialyzer
run: make dialyzer
suites:
runs-on: ubuntu-latest
outputs:
Expand Down Expand Up @@ -161,4 +161,6 @@ jobs:
mkdir _build
tar -xvf build.tar.gz -C _build
- name: ct ${{ matrix.suite }}
run: CT_LAGER=DEBUG ./rebar3 ct --suite=${{ matrix.suite }} --readable=true
run: |
make grpc
CT_LAGER=DEBUG ./rebar3 ct --suite=${{ matrix.suite }} --readable=true
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,10 @@ grpc:
$(grpc_services_directory):
@echo "grpc service directory $(directory) does not exist, generating services"
$(REBAR) get-deps
$(MAKE) grpc
REBAR_CONFIG="config/grpc_server_gen.config" $(REBAR) grpc gen
REBAR_CONFIG="config/grpc_client_gen.config" $(REBAR) grpc gen
REBAR_CONFIG="config/grpc_packet_router_client_gen.config" $(REBAR) grpc gen

# Pass all unknown targets straight to rebar3 (e.g. `make dialyzer`)
%:
%: | $(grpc_services_directory)
$(REBAR) $@
2 changes: 1 addition & 1 deletion config/sys.config.src
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
services => #{
'helium.router' => helium_router_service,
'helium.state_channel' => blockchain_grpc_sc_server_handler,
'helium.packet_router.gateway' => helium_gateway_service
'helium.packet_router.packet' => helium_packet_service
}
},
transport_opts => #{ssl => false},
Expand Down
2 changes: 1 addition & 1 deletion config/test.config
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
services => #{
'helium.router' => helium_router_service,
'helium.state_channel' => blockchain_grpc_sc_server_handler,
'helium.packet_router.gateway' => helium_gateway_service
'helium.packet_router.packet' => helium_packet_service
}
},
transport_opts => #{ssl => false},
Expand Down
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{inet_cidr, "1.1.0", {pkg, erl_cidr}},
{throttle, "0.3.0", {pkg, lambda_throttle}},
{e2qc, {git, "https://github.com/helium/e2qc.git", {branch, "master"}}},
{helium_proto, {git, "https://github.com/helium/proto.git", {branch, "macpie/packet_router"}}}
{helium_proto, {git, "https://github.com/helium/proto.git", {branch, "dpezely/packet_router"}}}
]}.

{plugins, [
Expand Down
2 changes: 1 addition & 1 deletion rebar.lock
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
{<<"hackney">>,{pkg,<<"hackney">>,<<"1.18.1">>},0},
{<<"helium_proto">>,
{git,"https://github.com/helium/proto.git",
{ref,"b23331346b3cc1167cea33bdbb00efef443b4cc7"}},
{ref,"25fc8c711857e9dc2be59fa6d7f7019f796fa4f8"}},
0},
{<<"hpack">>,{pkg,<<"hpack_erl">>,<<"0.2.3">>},2},
{<<"httpc_aws">>,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
-module(helium_gateway_service).
-module(helium_packet_service).

-behavior(helium_packet_router_gateway_bhvr).
-behavior(helium_packet_router_packet_bhvr).

-include("../grpc/autogen/client/packet_router_client_pb.hrl").
-include("autogen/client/packet_router_client_pb.hrl").
-include_lib("helium_proto/include/packet_pb.hrl").

-define(JOIN_REQUEST, 2#000).

-export([
init/2,
send_packet/2,
route/2,
handle_info/2
]).

-spec init(atom(), grpcbox_stream:t()) -> grpcbox_stream:t().
init(_Rpc, Stream) ->
Stream.

-spec send_packet(packet_router_pb:packet_router_packet_up_v1_pb(), grpcbox_stream:t()) ->
-spec route(packet_router_pb:packet_router_packet_up_v1_pb(), grpcbox_stream:t()) ->
{ok, grpcbox_stream:t()} | grpcbox_stream:grpc_error_response().
send_packet(PacketUp, StreamState) ->
route(PacketUp, StreamState) ->
ct:print("got a packet"),
case verify(PacketUp) of
false ->
{grpc_error, {grpcbox_stream:code_to_status(2), <<"bad signature">>}};
Expand Down
6 changes: 3 additions & 3 deletions test/router_grpc_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ join_grpc_gateway_test(Config) ->
PubKeyBin = libp2p_crypto:pubkey_to_bin(PubKey),

%% create a client stream
{ok, Stream} = helium_packet_router_gateway_client:send_packet(ctx:new()),
{ok, Stream} = helium_packet_router_packet_client:route(ctx:new()),
ct:print("stream: ~p", [Stream]),

%% create a join packet
Expand Down Expand Up @@ -143,7 +143,7 @@ join_from_unknown_device_grpc_gateway_test(_Config) ->
),

%% create a client stream
{ok, Stream} = helium_packet_router_gateway_client:send_packet(ctx:new()),
{ok, Stream} = helium_packet_router_packet_client:route(ctx:new()),
ct:print("stream: ~p", [Stream]),

{ok, PubKey, SigFun, _} = blockchain_swarm:keys(),
Expand Down Expand Up @@ -244,7 +244,7 @@ packet_from_known_device_no_downlink_gateway_test(Config) ->
PubKeyBin = libp2p_crypto:pubkey_to_bin(PubKey),

%% create client stream
{ok, Stream} = helium_packet_router_gateway_client:send_packet(ctx:new()),
{ok, Stream} = helium_packet_router_packet_client:route(ctx:new()),

%% create a join packet
JoinNonce = crypto:strong_rand_bytes(2),
Expand Down

0 comments on commit c4cad7b

Please sign in to comment.