btcruby 1.1.4 → 1.1.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/RELEASE_NOTES.md +7 -0
- data/lib/btcruby.rb +1 -1
- data/lib/btcruby/address.rb +1 -0
- data/lib/btcruby/open_assets/asset_marker.rb +1 -0
- data/lib/btcruby/script/opcode.rb +3 -0
- data/lib/btcruby/script/script.rb +2 -1
- data/lib/btcruby/script/script_chunk.rb +1 -0
- data/lib/btcruby/script/script_error.rb +41 -37
- data/lib/btcruby/script/script_interpreter.rb +2 -0
- data/lib/btcruby/script/script_interpreter_plugin.rb +2 -0
- data/lib/btcruby/transaction_builder.rb +1 -0
- data/lib/btcruby/version.rb +1 -1
- data/spec/address_spec.rb +22 -22
- data/spec/base58_spec.rb +8 -8
- data/spec/block_header_spec.rb +4 -4
- data/spec/block_spec.rb +4 -4
- data/spec/currency_formatter_spec.rb +30 -30
- data/spec/data_spec.rb +3 -3
- data/spec/key_spec.rb +11 -11
- data/spec/keychain_spec.rb +12 -12
- data/spec/merkle_tree_spec.rb +3 -3
- data/spec/open_assets/asset_address_spec.rb +7 -7
- data/spec/open_assets/asset_id_spec.rb +3 -3
- data/spec/open_assets/asset_marker_spec.rb +5 -5
- data/spec/open_assets/asset_processor_spec.rb +48 -48
- data/spec/open_assets/asset_transaction_builder_spec.rb +26 -26
- data/spec/open_assets/asset_transaction_spec.rb +9 -9
- data/spec/open_assets/issuance_id_spec.rb +3 -3
- data/spec/script_interpreter_spec.rb +4 -4
- data/spec/script_spec.rb +23 -23
- data/spec/spec_helper.rb +33 -31
- data/spec/transaction_builder_spec.rb +33 -33
- data/spec/transaction_spec.rb +18 -18
- data/spec/wire_format_spec.rb +5 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a64dd3f298bb55c7d1bc660b6318771030fa6e6f
|
4
|
+
data.tar.gz: 6f9d6e72597bc798b2f025c3003d093f972a50ff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38c83c30020fdc804fcd467bf20bd241709924c7b7708e8da72202c23717e9cb59b54c9916e6d5a09902b067107ebd8d4c14fa26b854495e4f1ac34693eb8ac7
|
7
|
+
data.tar.gz: 7cbd2dc8332ae5e4756d813b207f592d541ff1d878b512bb902853b9b8fb6d626f28505cd1aea90f54706871544fcde1c45c9d1ccd81927aa85f2ff39e18e9ec
|
data/RELEASE_NOTES.md
CHANGED
@@ -2,6 +2,13 @@
|
|
2
2
|
BTCRuby Release Notes
|
3
3
|
=====================
|
4
4
|
|
5
|
+
1.1.5 (August 20, 2015)
|
6
|
+
-----------------------
|
7
|
+
|
8
|
+
* Fixed namespace issues with `BTC::Opcodes`.
|
9
|
+
* All tests are running with explicit namespaces.
|
10
|
+
|
11
|
+
|
5
12
|
1.1.4 (August 18, 2015)
|
6
13
|
-----------------------
|
7
14
|
|
data/lib/btcruby.rb
CHANGED
@@ -15,6 +15,7 @@ require_relative 'btcruby/big_number.rb'
|
|
15
15
|
require_relative 'btcruby/base58.rb'
|
16
16
|
|
17
17
|
require_relative 'btcruby/constants.rb'
|
18
|
+
require_relative 'btcruby/script/opcode.rb'
|
18
19
|
require_relative 'btcruby/currency_formatter.rb'
|
19
20
|
require_relative 'btcruby/network.rb'
|
20
21
|
require_relative 'btcruby/address.rb'
|
@@ -35,7 +36,6 @@ require_relative 'btcruby/script/script_number.rb'
|
|
35
36
|
require_relative 'btcruby/script/script_chunk.rb'
|
36
37
|
require_relative 'btcruby/script/script.rb'
|
37
38
|
require_relative 'btcruby/script/script_interpreter.rb'
|
38
|
-
require_relative 'btcruby/script/opcode.rb'
|
39
39
|
require_relative 'btcruby/script/signature_hashtype.rb'
|
40
40
|
require_relative 'btcruby/script/signature_checker.rb'
|
41
41
|
require_relative 'btcruby/script/test_signature_checker.rb'
|
data/lib/btcruby/address.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
module BTC
|
2
2
|
# ScriptChunk represents either an opcode or a pushdata command.
|
3
3
|
class ScriptChunk
|
4
|
+
include Opcodes
|
4
5
|
# Raw data for this chunk.
|
5
6
|
# 1 byte for regular opcode, 1 or more bytes for pushdata command.
|
6
7
|
# We do not call it 'data' to avoid confusion with `pushdata` (see below).
|
@@ -1,47 +1,51 @@
|
|
1
1
|
module BTC
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
2
|
+
module ScriptErrors
|
3
|
+
SCRIPT_ERR_OK = 0
|
4
|
+
SCRIPT_ERR_UNKNOWN_ERROR = 1
|
5
|
+
SCRIPT_ERR_EVAL_FALSE = 2
|
6
|
+
SCRIPT_ERR_OP_RETURN = 3
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
8
|
+
# Max sizes
|
9
|
+
SCRIPT_ERR_SCRIPT_SIZE = 4
|
10
|
+
SCRIPT_ERR_PUSH_SIZE = 5
|
11
|
+
SCRIPT_ERR_OP_COUNT = 6
|
12
|
+
SCRIPT_ERR_STACK_SIZE = 7
|
13
|
+
SCRIPT_ERR_SIG_COUNT = 8
|
14
|
+
SCRIPT_ERR_PUBKEY_COUNT = 9
|
14
15
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
16
|
+
# Failed verify operations
|
17
|
+
SCRIPT_ERR_VERIFY = 10
|
18
|
+
SCRIPT_ERR_EQUALVERIFY = 11
|
19
|
+
SCRIPT_ERR_CHECKMULTISIGVERIFY = 12
|
20
|
+
SCRIPT_ERR_CHECKSIGVERIFY = 13
|
21
|
+
SCRIPT_ERR_NUMEQUALVERIFY = 14
|
21
22
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
23
|
+
# Logical/Format/Canonical errors
|
24
|
+
SCRIPT_ERR_BAD_OPCODE = 15
|
25
|
+
SCRIPT_ERR_DISABLED_OPCODE = 16
|
26
|
+
SCRIPT_ERR_INVALID_STACK_OPERATION = 17
|
27
|
+
SCRIPT_ERR_INVALID_ALTSTACK_OPERATION = 18
|
28
|
+
SCRIPT_ERR_UNBALANCED_CONDITIONAL = 19
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
|
30
|
+
# OP_CHECKLOCKTIMEVERIFY
|
31
|
+
SCRIPT_ERR_NEGATIVE_LOCKTIME = 20
|
32
|
+
SCRIPT_ERR_UNSATISFIED_LOCKTIME = 21
|
32
33
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
34
|
+
# BIP62
|
35
|
+
SCRIPT_ERR_SIG_HASHTYPE = 22
|
36
|
+
SCRIPT_ERR_SIG_DER = 23
|
37
|
+
SCRIPT_ERR_MINIMALDATA = 24
|
38
|
+
SCRIPT_ERR_SIG_PUSHONLY = 25
|
39
|
+
SCRIPT_ERR_SIG_HIGH_S = 26
|
40
|
+
SCRIPT_ERR_SIG_NULLDUMMY = 27
|
41
|
+
SCRIPT_ERR_PUBKEYTYPE = 28
|
42
|
+
SCRIPT_ERR_CLEANSTACK = 29
|
42
43
|
|
43
|
-
|
44
|
-
|
44
|
+
# softfork safeness
|
45
|
+
SCRIPT_ERR_DISCOURAGE_UPGRADABLE_NOPS = 30
|
46
|
+
end
|
47
|
+
|
48
|
+
include ScriptErrors
|
45
49
|
|
46
50
|
class ScriptError
|
47
51
|
attr_reader :code
|
@@ -12,6 +12,8 @@ module BTC
|
|
12
12
|
# returning a bool indicating valid or not. There are no loops.
|
13
13
|
class ScriptInterpreter
|
14
14
|
include ScriptFlags
|
15
|
+
include ScriptErrors
|
16
|
+
include Opcodes
|
15
17
|
|
16
18
|
# Flags specified for this interpreter, not including flags added by plugins.
|
17
19
|
attr_accessor :flags
|
@@ -9,6 +9,8 @@ module BTC
|
|
9
9
|
# - hook for handling the opcodes
|
10
10
|
module ScriptInterpreterPlugin
|
11
11
|
include ScriptFlags
|
12
|
+
include ScriptErrors
|
13
|
+
include Opcodes
|
12
14
|
|
13
15
|
# Returns additional flags to be available to #flag? checks during script execution.
|
14
16
|
# This way one plugin can affect evaluation of another.
|
data/lib/btcruby/version.rb
CHANGED
data/spec/address_spec.rb
CHANGED
@@ -32,7 +32,7 @@ describe BTC::Address do
|
|
32
32
|
|
33
33
|
address.data.must_equal "243f1394f44554f4ce3fd68649c19adc483ce924".from_hex
|
34
34
|
|
35
|
-
address2 = BTC::PublicKeyAddress.new(hash: "243f1394f44554f4ce3fd68649c19adc483ce924".from_hex, network: Network.testnet)
|
35
|
+
address2 = BTC::PublicKeyAddress.new(hash: "243f1394f44554f4ce3fd68649c19adc483ce924".from_hex, network: BTC::Network.testnet)
|
36
36
|
|
37
37
|
address2.to_s.must_equal("mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRfn")
|
38
38
|
address2.data.must_equal("243f1394f44554f4ce3fd68649c19adc483ce924".from_hex)
|
@@ -40,13 +40,13 @@ describe BTC::Address do
|
|
40
40
|
|
41
41
|
it "should detect invalid pay-to-pubkey-hash address" do
|
42
42
|
lambda { BTC::Address.parse(nil) }.must_raise ArgumentError
|
43
|
-
lambda { BTC::Address.parse("") }.must_raise FormatError
|
44
|
-
lambda { BTC::Address.parse("18FGfswVqxNubJbh1NW8A4t51T9x9RDVWQ") }.must_raise FormatError
|
45
|
-
lambda { BTC::Address.parse("19FGfswVqxNubJbh1NW8A4t51T9x9RDvwq") }.must_raise FormatError
|
46
|
-
lambda { BTC::Address.parse("19FGfswVqxNubJbh1NW8A4t51T9x9RD") }.must_raise FormatError
|
47
|
-
lambda { BTC::Address.parse("mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRf") }.must_raise FormatError
|
48
|
-
lambda { BTC::Address.parse("m") }.must_raise FormatError
|
49
|
-
lambda { BTC::Address.parse("mipc") }.must_raise FormatError
|
43
|
+
lambda { BTC::Address.parse("") }.must_raise BTC::FormatError
|
44
|
+
lambda { BTC::Address.parse("18FGfswVqxNubJbh1NW8A4t51T9x9RDVWQ") }.must_raise BTC::FormatError
|
45
|
+
lambda { BTC::Address.parse("19FGfswVqxNubJbh1NW8A4t51T9x9RDvwq") }.must_raise BTC::FormatError
|
46
|
+
lambda { BTC::Address.parse("19FGfswVqxNubJbh1NW8A4t51T9x9RD") }.must_raise BTC::FormatError
|
47
|
+
lambda { BTC::Address.parse("mipcBbFg9gMiCh81Kj8tqqdgoZub1ZJRf") }.must_raise BTC::FormatError
|
48
|
+
lambda { BTC::Address.parse("m") }.must_raise BTC::FormatError
|
49
|
+
lambda { BTC::Address.parse("mipc") }.must_raise BTC::FormatError
|
50
50
|
end
|
51
51
|
|
52
52
|
it "should decode/encode mainnet pay-to-script-hash address" do
|
@@ -89,12 +89,12 @@ describe BTC::Address do
|
|
89
89
|
end
|
90
90
|
|
91
91
|
it "should detect invalid pay-to-script-hash address" do
|
92
|
-
lambda { BTC::Address.parse("3ektnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX") }.must_raise FormatError
|
93
|
-
lambda { BTC::Address.parse("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzqX") }.must_raise FormatError
|
94
|
-
lambda { BTC::Address.parse("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSg") }.must_raise FormatError
|
95
|
-
lambda { BTC::Address.parse("2mzQwSSnBHWHqSAqtTVQ6v47XtaisrJa1Vc") }.must_raise FormatError
|
96
|
-
lambda { BTC::Address.parse("2MzQwSSnBHWHqSAqtTVQ6v47XtaisrJa1vc") }.must_raise FormatError
|
97
|
-
lambda { BTC::Address.parse("2MzQwSSnBHWHqSAqtTVQ6v47XtaisrJ") }.must_raise FormatError
|
92
|
+
lambda { BTC::Address.parse("3ektnHQD7RiAE6uzMj2ZifT9YgRrkSgzQX") }.must_raise BTC::FormatError
|
93
|
+
lambda { BTC::Address.parse("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSgzqX") }.must_raise BTC::FormatError
|
94
|
+
lambda { BTC::Address.parse("3EktnHQD7RiAE6uzMj2ZifT9YgRrkSg") }.must_raise BTC::FormatError
|
95
|
+
lambda { BTC::Address.parse("2mzQwSSnBHWHqSAqtTVQ6v47XtaisrJa1Vc") }.must_raise BTC::FormatError
|
96
|
+
lambda { BTC::Address.parse("2MzQwSSnBHWHqSAqtTVQ6v47XtaisrJa1vc") }.must_raise BTC::FormatError
|
97
|
+
lambda { BTC::Address.parse("2MzQwSSnBHWHqSAqtTVQ6v47XtaisrJ") }.must_raise BTC::FormatError
|
98
98
|
end
|
99
99
|
|
100
100
|
|
@@ -139,12 +139,12 @@ describe BTC::Address do
|
|
139
139
|
end
|
140
140
|
|
141
141
|
it "should detect invalid private key address" do
|
142
|
-
lambda { BTC::Address.parse("5kJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS") }.must_raise FormatError
|
143
|
-
lambda { BTC::Address.parse("5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hs") }.must_raise FormatError
|
144
|
-
lambda { BTC::Address.parse("5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZ") }.must_raise FormatError
|
145
|
-
lambda { BTC::Address.parse("L3P8oAcQTtuokSCRHQ7i4MhjWc9zornvpJLfmg62sYpLRJF9woSu") }.must_raise FormatError
|
146
|
-
lambda { BTC::Address.parse("L3p8oAcQTtuokSCRHQ7i4MhjWc9zornvpJLfmg62sYpLRJF9woSU") }.must_raise FormatError
|
147
|
-
lambda { BTC::Address.parse("L3p8oAcQTtuokSCRHQ7i4MhjWc9zornvpJLfmg62sYpLRJ") }.must_raise FormatError
|
142
|
+
lambda { BTC::Address.parse("5kJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hS") }.must_raise BTC::FormatError
|
143
|
+
lambda { BTC::Address.parse("5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZXj3hs") }.must_raise BTC::FormatError
|
144
|
+
lambda { BTC::Address.parse("5KJvsngHeMpm884wtkJNzQGaCErckhHJBGFsvd3VyK5qMZ") }.must_raise BTC::FormatError
|
145
|
+
lambda { BTC::Address.parse("L3P8oAcQTtuokSCRHQ7i4MhjWc9zornvpJLfmg62sYpLRJF9woSu") }.must_raise BTC::FormatError
|
146
|
+
lambda { BTC::Address.parse("L3p8oAcQTtuokSCRHQ7i4MhjWc9zornvpJLfmg62sYpLRJF9woSU") }.must_raise BTC::FormatError
|
147
|
+
lambda { BTC::Address.parse("L3p8oAcQTtuokSCRHQ7i4MhjWc9zornvpJLfmg62sYpLRJ") }.must_raise BTC::FormatError
|
148
148
|
end
|
149
149
|
|
150
150
|
it "should convert strings and addresses into normalized address" do
|
@@ -191,8 +191,8 @@ describe BTC::Address do
|
|
191
191
|
it "should detect if wrong subclass is used when parsing an address" do
|
192
192
|
btc_addr_string = "19FGfswVqxNubJbh1NW8A4t51T9x9RDVWQ"
|
193
193
|
asset_addr_string = "akB4NBW9UuCmHuepksob6yfZs6naHtRCPNy"
|
194
|
-
btc_addr = Address.parse(btc_addr_string)
|
195
|
-
asset_addr = Address.parse(asset_addr_string)
|
194
|
+
btc_addr = BTC::Address.parse(btc_addr_string)
|
195
|
+
asset_addr = BTC::Address.parse(asset_addr_string)
|
196
196
|
|
197
197
|
->{ BTC::AssetAddress.parse(btc_addr_string) }.must_raise ArgumentError
|
198
198
|
->{ BTC::AssetAddress.parse(btc_addr) }.must_raise ArgumentError
|
data/spec/base58_spec.rb
CHANGED
@@ -2,34 +2,34 @@ require_relative 'spec_helper'
|
|
2
2
|
describe BTC::Base58 do
|
3
3
|
|
4
4
|
def check_invalid_base58(base58_string, expected_class = BTC::FormatError)
|
5
|
-
lambda { Base58.data_from_base58(base58_string) }.must_raise expected_class
|
5
|
+
lambda { BTC::Base58.data_from_base58(base58_string) }.must_raise expected_class
|
6
6
|
end
|
7
7
|
|
8
8
|
def check_invalid_base58check(base58check_string, expected_class = BTC::FormatError)
|
9
|
-
lambda { Base58.data_from_base58check(base58check_string) }.must_raise expected_class
|
9
|
+
lambda { BTC::Base58.data_from_base58check(base58check_string) }.must_raise expected_class
|
10
10
|
end
|
11
11
|
|
12
12
|
def check_valid_base58(hex_string, base58_string)
|
13
13
|
# Convert to Base58
|
14
|
-
Base58.base58_from_data(BTC.from_hex(hex_string)).must_equal(base58_string)
|
14
|
+
BTC::Base58.base58_from_data(BTC.from_hex(hex_string)).must_equal(base58_string)
|
15
15
|
|
16
16
|
# Convert from Base58
|
17
|
-
BTC.to_hex(Base58.data_from_base58(base58_string)).must_equal(hex_string)
|
17
|
+
BTC.to_hex(BTC::Base58.data_from_base58(base58_string)).must_equal(hex_string)
|
18
18
|
end
|
19
19
|
|
20
20
|
def check_valid_base58check(hex, string)
|
21
21
|
# Convert to Base58Check
|
22
|
-
Base58.base58check_from_data(BTC.from_hex(hex)).must_equal(string)
|
22
|
+
BTC::Base58.base58check_from_data(BTC.from_hex(hex)).must_equal(string)
|
23
23
|
|
24
24
|
# Convert from Base58Check
|
25
|
-
BTC.to_hex(Base58.data_from_base58check(string)).must_equal(hex)
|
25
|
+
BTC.to_hex(BTC::Base58.data_from_base58check(string)).must_equal(hex)
|
26
26
|
end
|
27
27
|
|
28
28
|
describe "Base58" do
|
29
29
|
it "should handle valid input" do
|
30
30
|
|
31
|
-
lambda { Base58.data_from_base58(nil) }.must_raise ArgumentError
|
32
|
-
lambda { Base58.base58_from_data(nil) }.must_raise ArgumentError
|
31
|
+
lambda { BTC::Base58.data_from_base58(nil) }.must_raise ArgumentError
|
32
|
+
lambda { BTC::Base58.base58_from_data(nil) }.must_raise ArgumentError
|
33
33
|
check_valid_base58("", "")
|
34
34
|
check_valid_base58("13", "L")
|
35
35
|
check_valid_base58("2e", "o")
|
data/spec/block_header_spec.rb
CHANGED
@@ -3,15 +3,15 @@ describe BTC::BlockHeader do
|
|
3
3
|
|
4
4
|
describe "Genesis Mainnet" do
|
5
5
|
it "should have a correct hash" do
|
6
|
-
BlockHeader.genesis_mainnet.block_id.must_equal "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
|
7
|
-
BlockHeader.genesis_mainnet.height.must_equal 0
|
6
|
+
BTC::BlockHeader.genesis_mainnet.block_id.must_equal "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
|
7
|
+
BTC::BlockHeader.genesis_mainnet.height.must_equal 0
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "Genesis Testnet" do
|
12
12
|
it "should have a correct hash" do
|
13
|
-
BlockHeader.genesis_testnet.block_id.must_equal "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"
|
14
|
-
BlockHeader.genesis_testnet.height.must_equal 0
|
13
|
+
BTC::BlockHeader.genesis_testnet.block_id.must_equal "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"
|
14
|
+
BTC::BlockHeader.genesis_testnet.height.must_equal 0
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
data/spec/block_spec.rb
CHANGED
@@ -3,15 +3,15 @@ describe BTC::Block do
|
|
3
3
|
|
4
4
|
describe "Genesis Mainnet" do
|
5
5
|
it "should have a correct hash" do
|
6
|
-
Block.genesis_mainnet.block_id.must_equal "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
|
7
|
-
Block.genesis_mainnet.height.must_equal 0
|
6
|
+
BTC::Block.genesis_mainnet.block_id.must_equal "000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"
|
7
|
+
BTC::Block.genesis_mainnet.height.must_equal 0
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
describe "Genesis Testnet" do
|
12
12
|
it "should have a correct hash" do
|
13
|
-
Block.genesis_testnet.block_id.must_equal "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"
|
14
|
-
Block.genesis_testnet.height.must_equal 0
|
13
|
+
BTC::Block.genesis_testnet.block_id.must_equal "000000000933ea01ad0ee984209779baaec3ced90fa3f408719526f8d77f4943"
|
14
|
+
BTC::Block.genesis_testnet.height.must_equal 0
|
15
15
|
end
|
16
16
|
end
|
17
17
|
|
@@ -5,42 +5,42 @@ describe BTC::CurrencyFormatter do
|
|
5
5
|
it "should support normal bitcoin formatting" do
|
6
6
|
fm = BTC::CurrencyFormatter.btc_formatter
|
7
7
|
|
8
|
-
fm.string_from_number(1*COIN).must_equal("1.0")
|
9
|
-
fm.string_from_number(42*COIN).must_equal("42.0")
|
10
|
-
fm.string_from_number(42000*COIN).must_equal("42000.0")
|
11
|
-
fm.string_from_number(42000*COIN + 123).must_equal("42000.00000123")
|
12
|
-
fm.string_from_number(42000*COIN + 123000).must_equal("42000.00123")
|
13
|
-
fm.string_from_number(42000*COIN + 123456).must_equal("42000.00123456")
|
14
|
-
fm.string_from_number(42000*COIN + COIN/2).must_equal("42000.5")
|
8
|
+
fm.string_from_number(1*BTC::COIN).must_equal("1.0")
|
9
|
+
fm.string_from_number(42*BTC::COIN).must_equal("42.0")
|
10
|
+
fm.string_from_number(42000*BTC::COIN).must_equal("42000.0")
|
11
|
+
fm.string_from_number(42000*BTC::COIN + 123).must_equal("42000.00000123")
|
12
|
+
fm.string_from_number(42000*BTC::COIN + 123000).must_equal("42000.00123")
|
13
|
+
fm.string_from_number(42000*BTC::COIN + 123456).must_equal("42000.00123456")
|
14
|
+
fm.string_from_number(42000*BTC::COIN + BTC::COIN/2).must_equal("42000.5")
|
15
15
|
|
16
|
-
fm.number_from_string("1").must_equal 1*COIN
|
17
|
-
fm.number_from_string("1.").must_equal 1*COIN
|
18
|
-
fm.number_from_string("1.0").must_equal 1*COIN
|
19
|
-
fm.number_from_string("42").must_equal 42*COIN
|
20
|
-
fm.number_from_string("42.123").must_equal 42*COIN + 12300000
|
21
|
-
fm.number_from_string("42.12345678").must_equal 42*COIN + 12345678
|
22
|
-
fm.number_from_string("42.10000000").must_equal 42*COIN + 10000000
|
23
|
-
fm.number_from_string("42.10000").must_equal 42*COIN + 10000000
|
16
|
+
fm.number_from_string("1").must_equal 1*BTC::COIN
|
17
|
+
fm.number_from_string("1.").must_equal 1*BTC::COIN
|
18
|
+
fm.number_from_string("1.0").must_equal 1*BTC::COIN
|
19
|
+
fm.number_from_string("42").must_equal 42*BTC::COIN
|
20
|
+
fm.number_from_string("42.123").must_equal 42*BTC::COIN + 12300000
|
21
|
+
fm.number_from_string("42.12345678").must_equal 42*BTC::COIN + 12345678
|
22
|
+
fm.number_from_string("42.10000000").must_equal 42*BTC::COIN + 10000000
|
23
|
+
fm.number_from_string("42.10000").must_equal 42*BTC::COIN + 10000000
|
24
24
|
end
|
25
25
|
|
26
26
|
it "should support long bitcoin formatting" do
|
27
27
|
fm = BTC::CurrencyFormatter.btc_long_formatter
|
28
28
|
|
29
|
-
fm.string_from_number(1*COIN).must_equal("1.00000000")
|
30
|
-
fm.string_from_number(42*COIN).must_equal("42.00000000")
|
31
|
-
fm.string_from_number(42000*COIN).must_equal("42000.00000000")
|
32
|
-
fm.string_from_number(42000*COIN + 123).must_equal("42000.00000123")
|
33
|
-
fm.string_from_number(42000*COIN + 123000).must_equal("42000.00123000")
|
34
|
-
fm.string_from_number(42000*COIN + 123456).must_equal("42000.00123456")
|
35
|
-
fm.string_from_number(42000*COIN + COIN/2).must_equal("42000.50000000")
|
29
|
+
fm.string_from_number(1*BTC::COIN).must_equal("1.00000000")
|
30
|
+
fm.string_from_number(42*BTC::COIN).must_equal("42.00000000")
|
31
|
+
fm.string_from_number(42000*BTC::COIN).must_equal("42000.00000000")
|
32
|
+
fm.string_from_number(42000*BTC::COIN + 123).must_equal("42000.00000123")
|
33
|
+
fm.string_from_number(42000*BTC::COIN + 123000).must_equal("42000.00123000")
|
34
|
+
fm.string_from_number(42000*BTC::COIN + 123456).must_equal("42000.00123456")
|
35
|
+
fm.string_from_number(42000*BTC::COIN + BTC::COIN/2).must_equal("42000.50000000")
|
36
36
|
|
37
|
-
fm.number_from_string("1").must_equal 1*COIN
|
38
|
-
fm.number_from_string("1.").must_equal 1*COIN
|
39
|
-
fm.number_from_string("1.0").must_equal 1*COIN
|
40
|
-
fm.number_from_string("42").must_equal 42*COIN
|
41
|
-
fm.number_from_string("42.123").must_equal 42*COIN + 12300000
|
42
|
-
fm.number_from_string("42.12345678").must_equal 42*COIN + 12345678
|
43
|
-
fm.number_from_string("42.10000000").must_equal 42*COIN + 10000000
|
44
|
-
fm.number_from_string("42.10000").must_equal 42*COIN + 10000000
|
37
|
+
fm.number_from_string("1").must_equal 1*BTC::COIN
|
38
|
+
fm.number_from_string("1.").must_equal 1*BTC::COIN
|
39
|
+
fm.number_from_string("1.0").must_equal 1*BTC::COIN
|
40
|
+
fm.number_from_string("42").must_equal 42*BTC::COIN
|
41
|
+
fm.number_from_string("42.123").must_equal 42*BTC::COIN + 12300000
|
42
|
+
fm.number_from_string("42.12345678").must_equal 42*BTC::COIN + 12345678
|
43
|
+
fm.number_from_string("42.10000000").must_equal 42*BTC::COIN + 10000000
|
44
|
+
fm.number_from_string("42.10000").must_equal 42*BTC::COIN + 10000000
|
45
45
|
end
|
46
46
|
end
|