anchor.diff:                              , parameters = Parameters
                               , events = Events
                               , pid = Pid },
  -            Devices = orddict:store( Device#device.id, Device, State#state.devices ),
  +            Devices = orddict:store( DeviceId, Device, State#state.devices ),
               NewState = State#state{ devices = Devices },
               { reply, { ok, Device#device.id }, NewState };
           { error, _ } = Error ->
  
positive.code:                  fun( _Driver, _Parameters ) -> { error, enoent } end ),
      StartResult = start_device( Pid, dummy_driver_config( ) ),
      [ { "error propagated", ?_assertMatch( { error, _Error }, StartResult ) } ].
  
  
  
  test_add_list_devices( Pid ) ->
  
negative.code:     { reply, { ok, DeviceList }, State };
  
  
  handle_call( stop, _From, State ) ->
      { stop, shutdown, ok, State }.
  
  
  handle_cast( { poll_device_event, DeviceId, Event }, State ) ->
      case maybe_get_device_pid( DeviceId, Event, State#state.devices ) of
          { ok, Pid } ->
              Token = lurch_driver_port:request_event_async( Pid, Event ),
              NewState = State#state{ polls = [ Token | State#state.polls ] },
              { noreply, NewState };
          _ ->
              % FIXME - log?
              { noreply, State }
      end;
  
  handle_cast( _Request, State ) ->
      { noreply, State }.
  
  
  handle_info( _Info, State ) ->
      { noreply, State }.
  
  
  terminate( _Reason, _State ) ->
      ok.
  
  
  code_change( _OldVsn, State, _Extra ) ->
      { ok, State }.
  
  
  
  %% ===================================================================
  %% Internal functions
  %% ===================================================================
  
  maybe_get_device_pid( DeviceId, Event, Devices ) ->
      case orddict:find( DeviceId, Devices ) of
          { ok, Device } ->
              case lists:member( Event, Device#device.events ) of
                  true -> { ok, Device#device.pid };
                  false -> { error, no_such_event }
              end;
          error ->
              { error, no_such_device }
      end.
  
  device_to_proplist( Device ) ->
      [ { id, Device#device.id }
  