Permalink
Browse files

add failure detector specs

From node-gossip
  • Loading branch information...
1 parent f749de8 commit 17e1aa5088777a794785eb30ec7f50cdb85c30b5 @grantr committed Apr 20, 2012
Showing with 35 additions and 0 deletions.
  1. +35 −0 spec/dcell-gossip/failure_detector_spec.rb
View
35 spec/dcell-gossip/failure_detector_spec.rb
@@ -0,0 +1,35 @@
+require 'spec_helper'
+
+describe DCell::Gossip::FailureDetector do
+ it 'should have a low phi value after only a second' do
+ time = 0
+ 0.upto(100) do |i|
+ time += 1000
+ subject.add(time)
+ end
+
+ subject.phi(time + 1000).should be < 0.5
+ end
+
+ it 'should have a high phi value after ten seconds' do
+ time = 0
+ 0.upto(100) do |i|
+ time += 1000
+ subject.add(time)
+ end
+
+ subject.phi(time + 10000).should be > 4
+
+ end
+
+ it 'should only keep last 1000 values' do
+ time = 0
+ 0.upto(2000) do |i|
+ time += 1000
+ subject.add(time)
+ end
+
+ subject.intervals.size.should == 1000
+ end
+
+end

0 comments on commit 17e1aa5

Please sign in to comment.