spec/client_spec.rb in bitbank-0.0.1 vs spec/client_spec.rb in bitbank-0.1.0

- old
+ new

@@ -56,10 +56,26 @@ it 'should return the number of blocks in the longest block chain' do @client.block_count.should == 130361 end end + describe 'block_number' do + use_vcr_cassette 'client/block_number' + + it 'should return the block number of the latest block in the longest chain' do + @client.block_number.should == 132426 + end + end + + describe 'connection_count' do + use_vcr_cassette 'client/connection_count' + + it 'should return the number of connections to other nodes' do + @client.connection_count.should == 8 + end + end + describe 'difficulty' do use_vcr_cassette 'client/difficulty' it 'should return the current difficulty' do @client.difficulty.should == 567358.22457067 @@ -76,12 +92,27 @@ work.has_key?(key).should be_true end end end - context 'when data is supplied' do - it 'checks my answer' - it 'gives me more work' + context 'with data' do + context 'and the block solution is successful' do + use_vcr_cassette 'client/get_work_data_true' + + it 'should return true' do + data = "00000001aa1d7a0acb6102db122de979b3eef4e2387f61ce0ca68abb00000eba000000006f35688764fa1d99a8f66b02a25399568a3445af4dfa169448282b02b91f70024dfa59f51a13218573b87d00000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000" + @client.get_work(data).should be_true + end + end + + context 'and the block solution is not successful' do + use_vcr_cassette 'client/get_work_data_false' + + it 'should return false' do + data = "00000001aa1d7a0acb6102db122de979b3eef4e2387f61ce0ca68abb00000eba000000006f35688764fa1d99a8f66b02a25399568a3445af4dfa169448282b02b91f70024dfa59f51a13218573b87d00000000800000000000000000000000000000000000000000000000000000000000000000000000000000000080020000" + @client.get_work(data).should be_false + end + end end end describe 'info' do use_vcr_cassette 'client/info'