<commit_before>RSpec.describe DCell::Node do
  def wait_for_actor(id)
    30.times do
      begin
        node = DCell::Node[id]
        return node if node and node.ping 1
      rescue
      end
      # :nocov:
      sleep 1
      # :nocov:
    end
    # :nocov:
    raise "Failed to wait for actor"
    # :nocov:
  end

  before :each do
    id = TEST_NODE[:id]
    @node = wait_for_actor id
    expect(@node.id).to eq(id)

    @unique = SecureRandom.hex
    @node[:test_actor].mutable = @unique
  end

  it "finds all available nodes" do
    nodes = DCell::Node.map
    expect(nodes).to include(DCell.me)
  end

  it "finds remote actors" do
    actor = @node[:test_actor]
    expect(actor.value).to eq(42)
  end

  it "lists remote actors" do
    expect(@node.actors).to include :test_actor
    expect(@node.all).to include :test_actor
  end

  it "failes to attach to obviously dead node" do
    expect {DCell::Node.new("corpse", nil)}.to raise_error DCell::DeadNodeError
  end

  it "fails to send complex structures" do
    actor = @node[:test_actor]
    expect {actor.win(->() {'magic'})}.to raise_error
  end

  it "provides fancy name during inspection" do
    expect(@node.inspect).to start_with "#<DCell::Node[#{TEST_NODE[:id]}]"
  end

  context :crashing do
    after :each do
      id = TEST_NODE[:id]
      @node = wait_for_actor id
      expect(@node.id).to eq(id)
    end

    def wait_for_death(time)
      sleep time + 1
      30.times do
        begin
          actor = DCell[:test_actor].first
          return if actor and actor.mutable != @unique<commit_msg>spec:node: increase wait time to please jruby<commit_after>RSpec.describe DCell::Node do
  def wait_for_actor(id)
    60.times do
      begin
        node = DCell::Node[id]
        return node if node and node.ping 1
      rescue
      end
      # :nocov:
      sleep 1
      # :nocov:
    end
    # :nocov:
    raise "Failed to wait for actor"
    # :nocov:
  end

  before :each do
    id = TEST_NODE[:id]
    @node = wait_for_actor id
    expect(@node.id).to eq(id)

    @unique = SecureRandom.hex
    @node[:test_actor].mutable = @unique
  end

  it "finds all available nodes" do
    nodes = DCell::Node.map
    expect(nodes).to include(DCell.me)
  end

  it "finds remote actors" do
    actor = @node[:test_actor]
    expect(actor.value).to eq(42)
  end

  it "lists remote actors" do
    expect(@node.actors).to include :test_actor
    expect(@node.all).to include :test_actor
  end

  it "failes to attach to obviously dead node" do
    expect {DCell::Node.new("corpse", nil)}.to raise_error DCell::DeadNodeError
  end

  it "fails to send complex structures" do
    actor = @node[:test_actor]
    expect {actor.win(->() {'magic'})}.to raise_error
  end

  it "provides fancy name during inspection" do
    expect(@node.inspect).to start_with "#<DCell::Node[#{TEST_NODE[:id]}]"
  end

  context :crashing do
    after :each do
      id = TEST_NODE[:id]
      @node = wait_for_actor id
      expect(@node.id).to eq(id)
    end

    def wait_for_death(time)
      sleep time + 1
      60.times do
        begin
          actor = DCell[:test_actor].first
          return if actor and actor.mutable != @unique
{'fraction_non_alphanumeric': 0.1113892365456821, 'fraction_numerical': 0.005632040050062578, 'mean_word_length': 2.5961754780652417, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4404806', 'n_tokens_mistral': 1106, 'n_tokens_neox': 1076, 'n_words': 307}