btcruby 1.0.9 → 1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,14 +3,14 @@ require_relative '../spec_helper'
3
3
  describe BTC::IssuanceID do
4
4
  it "should encode script to a correct address" do
5
5
  key = Key.new(private_key: "18E14A7B6A307F426A94F8114701E7C8E774E7F9A47E2C2035DB29A206321725".from_hex, public_key_compressed: false)
6
- issuance_id = IssuanceID.new(outpoint: TransactionOutpoint.new(transaction_hash: BTC.hash256("tx1"), index:0), amount:100, network: Network.mainnet)
7
- issuance_id.hash.to_hex.must_equal "5e398b12cce30c0e1550e29f9d1b8f024772ac69"
8
- issuance_id.to_s.must_equal "SVtDV3pMkQQu11CQMzsziCmFBx4Ff5FnPT"
6
+ issuance_id = IssuanceID.new(outpoint: TransactionOutpoint.new(transaction_hash: BTC.hash256("tx1"), index:1), amount:100, network: Network.mainnet)
7
+ issuance_id.hash.to_hex.must_equal "29d2765469a299d1219a1cbf7561534eae4595f7"
8
+ issuance_id.to_s.must_equal "SR78rsv5RCMMay22D3ZUZmMgPkRGpqphnQ"
9
9
  issuance_id.is_a?(BTC::IssuanceID).must_equal true
10
10
  end
11
11
  it "should decode an asset address" do
12
- issuance_id = Address.parse("SVtDV3pMkQQu11CQMzsziCmFBx4Ff5FnPT")
12
+ issuance_id = Address.parse("SR78rsv5RCMMay22D3ZUZmMgPkRGpqphnQ")
13
13
  issuance_id.is_a?(BTC::IssuanceID).must_equal true
14
- issuance_id.hash.to_hex.must_equal "5e398b12cce30c0e1550e29f9d1b8f024772ac69"
14
+ issuance_id.hash.to_hex.must_equal "29d2765469a299d1219a1cbf7561534eae4595f7"
15
15
  end
16
16
  end
@@ -219,7 +219,7 @@ describe BTC::WireFormat do
219
219
  verify_fixint(:int32le, 0x7eadbeef, "efbead7e")
220
220
  verify_fixint(:int32le, 0x7fffffff, "ffffff7f")
221
221
  verify_fixint(:int32le, -1, "ffffffff")
222
-
222
+
223
223
  verify_fixint(:int32be, 0, "00000000")
224
224
  verify_fixint(:int32be, 0x7f, "0000007f")
225
225
  verify_fixint(:int32be, 0x80, "00000080")
@@ -245,7 +245,7 @@ describe BTC::WireFormat do
245
245
  verify_fixint(:int64le, -1, "ffffffffffffffff")
246
246
 
247
247
  end
248
-
248
+
249
249
  def verify_uleb128(int, hex)
250
250
 
251
251
  raw = hex.from_hex
@@ -280,8 +280,8 @@ describe BTC::WireFormat do
280
280
  BTC::WireFormat.read_uleb128(stream: io1, offset: 4).must_equal [int, 4 + raw.bytesize]
281
281
  BTC::WireFormat.read_uleb128(stream: io2, offset: 4).must_equal [int, 4 + raw.bytesize]
282
282
  end
283
-
284
-
283
+
284
+
285
285
  it "should encode/decode LEB128-encoded unsigned integers" do
286
286
  verify_uleb128(0, "00")
287
287
  verify_uleb128(1, "01")
@@ -296,4 +296,22 @@ describe BTC::WireFormat do
296
296
  verify_uleb128(2**64, "80808080808080808002")
297
297
  end
298
298
 
299
+ it "should encode/decode varint-prefixed arrays" do
300
+
301
+ txs = [
302
+ Transaction.new,
303
+ Transaction.new(inputs:[TransactionInput.new]),
304
+ Transaction.new(outputs:[TransactionOutput.new])
305
+ ]
306
+ data = WireFormat.encode_array(txs) {|t|t.data}
307
+ data.bytes[0].must_equal txs.size
308
+ data.must_equal txs.inject("\x03".b){|d,t| d+t.data}
309
+
310
+ stream = StringIO.new(data)
311
+ txs2 = WireFormat.read_array(stream: stream){ Transaction.new(stream: stream) }
312
+ txs2[0].data.must_equal txs[0].data
313
+ txs2[1].data.must_equal txs[1].data
314
+ txs2[2].data.must_equal txs[2].data
315
+ end
316
+
299
317
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: btcruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.9
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Oleg Andreev
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-07-20 00:00:00.000000000 Z
12
+ date: 2015-07-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi
@@ -85,7 +85,6 @@ files:
85
85
  - lib/btcruby/keychain.rb
86
86
  - lib/btcruby/merkle_tree.rb
87
87
  - lib/btcruby/network.rb
88
- - lib/btcruby/opcode.rb
89
88
  - lib/btcruby/open_assets.rb
90
89
  - lib/btcruby/open_assets/asset.rb
91
90
  - lib/btcruby/open_assets/asset_address.rb
@@ -104,8 +103,16 @@ files:
104
103
  - lib/btcruby/openssl.rb
105
104
  - lib/btcruby/proof_of_work.rb
106
105
  - lib/btcruby/safety.rb
107
- - lib/btcruby/script.rb
108
- - lib/btcruby/signature_hashtype.rb
106
+ - lib/btcruby/script/opcode.rb
107
+ - lib/btcruby/script/script.rb
108
+ - lib/btcruby/script/script_error.rb
109
+ - lib/btcruby/script/script_flags.rb
110
+ - lib/btcruby/script/script_interpreter.rb
111
+ - lib/btcruby/script/script_number.rb
112
+ - lib/btcruby/script/signature_checker.rb
113
+ - lib/btcruby/script/signature_hashtype.rb
114
+ - lib/btcruby/script/test_signature_checker.rb
115
+ - lib/btcruby/script/transaction_signature_checker.rb
109
116
  - lib/btcruby/transaction.rb
110
117
  - lib/btcruby/transaction_builder.rb
111
118
  - lib/btcruby/transaction_builder/errors.rb