Skip to content

Apply rubocop #3

Open
Open

Description

@kvokka

Project contain tons of hassle which makes reading the code harder, rubocop should heal it

Activity

  1. self-assigned this
    on Oct 8, 2020
  2. topofocus commented on Oct 12, 2020

    @topofocus
    Member

    Hi,
    I was unable to run the tests after applying the changes.
    Got

    newdevel:~/workspace/ib-api$ bundle exec guard
    18:46:25 - INFO - Guard::RSpec is running
    18:46:25 - INFO - Guard is now watching at '/home/ubuntu/workspace/ib-api'
    18:46:54 - INFO - Running: spec/ib/connect_spec.rb
    
    An error occurred while loading spec_helper.
    Failure/Error: self::Classes[message_id] = message_class
    
    FrozenError:
      can't modify frozen Hash
    # ./lib/ib/messages/abstract_message.rb:92:in `def_message'
    # ./lib/ib/messages/outgoing.rb:20:in `<module:Outgoing>'
    # ./lib/ib/messages/outgoing.rb:8:in `<module:Messages>'
    # ./lib/ib/messages/outgoing.rb:6:in `<module:IB>'
    # ./lib/ib/messages/outgoing.rb:5:in `<top (required)>'
    # ./lib/ib/messages.rb:11:in `require'
    # ./lib/ib/messages.rb:11:in `<top (required)>'
    # ./lib/ib/connection.rb:4:in `require'
    # ./lib/ib/connection.rb:4:in `<top (required)>'
    # ./lib/requires.rb:8:in `require'
    # ./lib/requires.rb:8:in `<top (required)>'
    # ./lib/ib-api.rb:6:in `require'
    # ./lib/ib-api.rb:6:in `<top (required)>'
    # ./spec/spec_helper.rb:7:in `require'
    # ./spec/spec_helper.rb:7:in `<top (required)>'

    revoked the merge into to master branch.

    Lets look together, what went wrong (mail me: topofocus@gmail,com)

  3. topofocus commented on Oct 15, 2020

    @topofocus
    Member

    Hi,
    using the improved random id generation I run in some trouble

    newdevel:~/workspace/ib-api/bin$ ./console 
    
    >> IB-Core Interactive Console <<
    ---------------------------------------------
    
    Namespace is IB ! 
    
    ---------------------------------------------
    Connected to server, version: 137,
     connection time: 2020-10-15 12:47:44 +0000 local, 2020-10-15T12:47:43+00:00 remote.
    < ManagedAccounts: DF167347 - DU167348 - DU167349>
    TWS Warning 2107: HMDS data farm connection is inactive but should be available upon demand.ushmds
    newdevel:~/workspace/ib-api/bin$ 
    

    the console does not start

    First I changed the method name to 'generate', because ib-api at some point tests if a Constant responds to call.

    Same result.

    When i switched bach to `random 99999' anything works fine again.
    Then

    newdevel:~/workspace/ib-api/lib$ grep -rn random_id .
    ./ib/connection.rb:44:                   client_id: random_id,
    ./ib/connection.rb:179:        id = random_id
    ./ib/connection.rb:416:		def random_id
    

    leads to the solution: random_id is also used to generate id's for the received-array, where messages arriving from the tws are stored.

       def subscribe *args, &block
          @subscribe_lock.synchronize do
            subscriber = args.last.respond_to?(:call) ? args.pop : block
            id = random_id
    

    Then this experiment reveals the problem.
    Modifiying random_it to

    		def random_id
    			puts SafeRandIdGenerator.generate
    			rand 9999
    		end
    

    ans subsequent usage of the console
    ``'`
    newdevel:~/workspace/ib-api/bin$ ./console

    IB-Core Interactive Console

    Namespace is IB !


    25967018522
    25967018522
    25967018522
    25967018522
    25967018522
    25967018522
    Connected to server, version: 137,
    connection time: 2020-10-15 13:03:38 +0000 local, 2020-10-15T13:03:37+00:00 remote.
    < ManagedAccounts: DF167347 - DU167348 - DU167349>
    Got next valid order id: 14.

    
    exploits that tws-messages went to only one received-array-entry. 
    
    No wonder, that the application crashes.
    
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions