spec/bitcoin/spec_helper.rb in bitcoin-ruby-0.0.6 vs spec/bitcoin/spec_helper.rb in bitcoin-ruby-0.0.7
- old
+ new
@@ -7,12 +7,10 @@
SimpleCov.start do
add_group("Bitcoin") do |file|
["bitcoin.rb", "opcodes.rb", "script.rb", "key.rb"].include?(file.filename.split("/").last)
end
add_group "Protocol", "lib/bitcoin/protocol"
- add_group "Storage", "lib/bitcoin/storage"
- add_group "Wallet", "lib/bitcoin/wallet"
add_group("Utilities") do |file|
["logger.rb", "openssl.rb"].include?(file.filename.split("/").last)
end
end
rescue LoadError
@@ -47,39 +45,12 @@
end
@store.store_block(block) if store
block
end
-# create transaction given builder +tx+
-# +outputs+ is an array of [value, key] pairs
-def create_tx(tx, prev_tx, prev_out_index, outputs, key = @key)
- tx.input {|i| i.prev_out prev_tx; i.prev_out_index prev_out_index; i.signature_key key }
- outputs.each do |value, key|
- tx.output {|o| o.value value; o.script {|s| s.recipient key.addr } }
- end
-end
-# create a chain of +n+ blocks, based on +prev_hash+ block.
-# influence chain properties via options:
-# time: start time all other times are based on
-# interval: time between blocks
-# bits: target bits each block must match
-def create_blocks prev_hash, n, opts = {}
- interval = opts[:interval] || 600
- time = opts[:time] || Time.now.to_i
- bits = opts[:bits] || 553713663
- block = @store.get_block(prev_hash)
- n.times do |i|
- block = create_block block.hash, true, [], @key, 50e8, {
- time: time += interval, bits: bits }
- # block = @store.get_block(block.hash)
- # puts "#{i} #{block.hash[0..8]} #{block.prev_block.reverse_hth[0..8]} #{Time.at(block.time).strftime('%Y-%m-%d %H:%M:%S')} c: #{block.chain} b: #{block.bits} n: #{block.nonce} w: #{block.work}"
- end
- block
-end
-
Bitcoin::network = :bitcoin
Bitcoin::NETWORKS[:spec] = {
:project => :bitcoin,
:magic_head => "spec",
@@ -109,31 +80,9 @@
puts "Note: to run all the tests, you will also need: ffi, sequel, sqlite3"
exit 1
end
Bacon.summary_on_exit
require 'minitest/mock'
-
-require 'sequel'
-def setup_db backend, db = nil, conf = {}
- uri = case db
- when :sqlite
- "sqlite:/"
- when :postgres
- ENV["TEST_DB_POSTGRES"].dup rescue nil
- when :mysql
- ENV["TEST_DB_MYSQL"].dup rescue nil
- end
- if [:postgres, :mysql].include?(db)
- unless uri
- puts "Skipping #{db} tests"
- return nil
- end
- db = Sequel.connect(uri)
- db.drop_table(*db.tables, cascade: true)
- end
- Bitcoin::Storage.send(backend, conf.merge(db: uri, log_level: :warn))
-end
-
class Time
class << self
alias_method :real_new, :new
alias_method :new, :now