radiator 0.4.9 → 0.5.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.
@@ -38,7 +38,8 @@ module Radiator
38
38
  vcr_cassette('get_key_references') do
39
39
  keys = ['STM71f6yWztimJuREVyyMXNqAVbx1FzPVW6LLXNoQ35dHwKuszmHX']
40
40
  @api.get_key_references(keys: keys) do |account_names|
41
- assert_equal Hashie::Mash, account_names.class, account_names.inspect
41
+ assert_equal Hashie::Array, account_names.class, account_names.inspect
42
+ assert_equal 'steemit1', account_names.first.first
42
43
  end
43
44
  end
44
45
  end
@@ -30,6 +30,7 @@ module Radiator
30
30
  vcr_cassette('api_all_methods') do
31
31
  @api.method_names.each do |key|
32
32
  begin
33
+ next if key.to_s.start_with?('broadcast_')
33
34
  assert @api.send key
34
35
  rescue Steem::ArgumentError
35
36
  next
@@ -42,9 +43,8 @@ module Radiator
42
43
 
43
44
  def test_get_accounts_no_argument
44
45
  vcr_cassette('get_accounts_no_argument') do
45
- assert_raises Steem::ArgumentError do
46
- @api.get_accounts
47
- end
46
+ response = @api.get_accounts
47
+ assert response
48
48
  end
49
49
  end
50
50
 
@@ -24,24 +24,28 @@ module Radiator
24
24
 
25
25
  def test_all_methods
26
26
  vcr_cassette('chain_stats_api_all_methods') do
27
- skip 'This plugin is not typically enabled.'
27
+ skip_integration_test 'This plugin is not typically enabled.'
28
28
 
29
29
  @api.method_names.each do |key|
30
30
  begin
31
31
  assert @api.send key
32
32
  rescue Steem::ArgumentError
33
33
  next
34
+ rescue Steem::RemoteNodeError
35
+ next
36
+ rescue ApiError
37
+ next
34
38
  end
35
39
  end
36
40
  end
37
41
  end
38
42
 
39
43
  def test_get_stats_for_time
40
- skip 'This plugin is not typically enabled.'
44
+ skip_integration_test 'This plugin is not typically enabled.'
41
45
 
42
46
  vcr_cassette('get_stats_for_time') do
43
47
  @api.get_stats_for_time("20161031T235959", 1000) do |stats|
44
- assert_equal NilClass, stats.class, stats.inspect
48
+ assert_nil stats, stats.inspect
45
49
  end
46
50
  end
47
51
  end
@@ -113,21 +113,27 @@ module Radiator
113
113
  end
114
114
 
115
115
  def test_followed_by
116
- skip
117
116
  vcr_cassette('followed_by') do
118
- refute_nil @chain.followed_by('inertia')
117
+ error = assert_raises ApiError do
118
+ @chain.followed_by('inertia')
119
+ end
120
+
121
+ assert_includes error.to_s, 'follow_api.get_followers'
119
122
  end
120
123
  end
121
124
 
122
125
  def test_following
123
- skip
124
126
  vcr_cassette('following') do
125
- refute_nil @chain.following('inertia')
127
+ error = assert_raises ApiError do
128
+ @chain.following('inertia')
129
+ end
130
+
131
+ assert_includes error.to_s, 'follow_api.get_following'
126
132
  end
127
133
  end
128
134
 
129
135
  def test_post!
130
- skip 'Seems like archived post edits are now possible, so we will skip this test to avoid spamming.'
136
+ skip_integration_test 'Seems like archived post edits are now possible, so we will skip this test to avoid spamming.'
131
137
 
132
138
  options = {
133
139
  title: 'title of my post',
@@ -27,6 +27,7 @@ module Radiator
27
27
  vcr_cassette('condenser_all_all_methods') do
28
28
  @silent_api.method_names.each do |key|
29
29
  begin
30
+ next if key.to_s.start_with?('broadcast_')
30
31
  assert @silent_api.send key
31
32
  rescue Steem::ArgumentError
32
33
  next
@@ -24,24 +24,27 @@ module Radiator
24
24
 
25
25
  def test_all_methods
26
26
  vcr_cassette('follow_api_all_methods') do
27
- skip
28
27
  @api.method_names.each do |key|
29
28
  begin
30
29
  assert @api.send key
31
30
  rescue Steem::ArgumentError
32
31
  next
32
+ rescue Steem::RemoteNodeError
33
+ next
34
+ rescue ApiError
35
+ next
33
36
  end
34
37
  end
35
38
  end
36
39
  end
37
40
 
38
41
  def test_get_followers
39
- skip
40
42
  vcr_cassette('get_followers') do
41
- @api.get_followers(account: 'inertia', start: 0, type: 'blog', limit: 100) do |followers|
42
- assert_equal Hashie::Array, followers.class, followers.inspect
43
- assert followers
43
+ error = assert_raises ApiError do
44
+ @api.get_followers(account: 'inertia', start: 0, type: 'blog', limit: 100)
44
45
  end
46
+
47
+ assert_includes error.to_s, 'follow_api.get_followers'
45
48
  end
46
49
  end
47
50
  end
@@ -26,7 +26,8 @@ module Radiator
26
26
  vcr_cassette('market_history_api_all_methods') do
27
27
  @api.method_names.each do |key|
28
28
  begin
29
- assert @api.send key
29
+ response = @api.send key
30
+ assert response
30
31
  rescue Steem::ArgumentError
31
32
  next
32
33
  end
@@ -36,9 +37,9 @@ module Radiator
36
37
 
37
38
  def test_get_market_history
38
39
  vcr_cassette('get_market_history') do
39
- @api.get_market_history(nil, nil, nil) do |history|
40
- assert_equal Hashie::Mash, history.class, history.inspect
41
- assert_equal history.buckets, []
40
+ @api.get_market_history do |history|
41
+ assert_equal Hashie::Array, history.class, history.inspect
42
+ assert_equal [], history
42
43
  end
43
44
  end
44
45
  end
@@ -46,8 +47,8 @@ module Radiator
46
47
  def test_get_market_history_buckets
47
48
  vcr_cassette('get_market_history_buckets') do
48
49
  @api.get_market_history_buckets do |buckets|
49
- assert_equal Hashie::Mash, buckets.class, buckets.inspect
50
- assert buckets
50
+ assert_equal Hashie::Array, buckets.class, buckets.inspect
51
+ assert buckets.any?
51
52
  end
52
53
  end
53
54
  end
@@ -64,8 +65,8 @@ module Radiator
64
65
  def test_get_recent_trades
65
66
  vcr_cassette('get_recent_trades') do
66
67
  @api.get_recent_trades(limit: 10) do |trades|
67
- assert_equal Hashie::Mash, trades.class, trades.inspect
68
- assert trades.trades
68
+ assert_equal Hashie::Array, trades.class, trades.inspect
69
+ assert trades.any?
69
70
  end
70
71
  end
71
72
  end
@@ -81,9 +82,9 @@ module Radiator
81
82
 
82
83
  def test_get_trade_history
83
84
  vcr_cassette('get_trade_history') do
84
- @api.get_trade_history(nil, nil, nil) do |history|
85
- assert_equal Hashie::Mash, history.class, history.inspect
86
- assert_equal history.trades, []
85
+ @api.get_trade_history do |history|
86
+ assert_equal Hashie::Array, history.class, history.inspect
87
+ assert_equal [], history
87
88
  end
88
89
  end
89
90
  end
@@ -26,8 +26,11 @@ module Radiator
26
26
  def test_all_methods
27
27
  vcr_cassette('network_broadcast_api_all_methods') do
28
28
  @silent_api.method_names.each do |key|
29
+ next if [:broadcast_transaction, :broadcast_transaction_synchronous].include?(key)
30
+
29
31
  begin
30
- assert @silent_api.send key
32
+ response = @silent_api.send key
33
+ assert response
31
34
  rescue Steem::ArgumentError
32
35
  next
33
36
  rescue Steem::RemoteNodeError
@@ -39,9 +42,11 @@ module Radiator
39
42
 
40
43
  def test_broadcast_transaction
41
44
  vcr_cassette('broadcast_transaction') do
42
- assert_raises Steem::RemoteNodeError do
43
- @silent_api.broadcast_transaction
45
+ error = assert_raises ApiError do
46
+ @silent_api.broadcast_transaction({})
44
47
  end
48
+
49
+ assert_includes error.to_s, 'network_broadcast_api.broadcast_transaction'
45
50
  end
46
51
  end
47
52
  end
@@ -24,24 +24,32 @@ module Radiator
24
24
 
25
25
  def test_all_methods
26
26
  vcr_cassette('stream_all_methods') do
27
- skip "cannot execute an asynchronous request in tests"
27
+ skip_integration_test "cannot execute an asynchronous request in tests"
28
28
 
29
29
  @api.method_names.each do |key|
30
30
  begin
31
- assert @api.send key
31
+ response = @api.send key
32
+ assert response unless response.nil?
32
33
  rescue Steem::ArgumentError
33
34
  next
35
+ rescue Steem::RemoteNodeError
36
+ next
37
+ rescue Hive::BaseError
38
+ next
39
+ rescue ApiError
40
+ next
34
41
  end
35
42
  end
36
43
  end
37
44
  end
38
45
 
39
46
  def test_get_operations
40
- skip "cannot execute an asynchronous request in tests"
47
+ skip_integration_test "cannot execute an asynchronous request in tests"
41
48
 
42
49
  vcr_cassette('get_operations') do
43
- @api.operations
44
- assert_equal Hashie::Mash, response.class, response.inspect
50
+ assert_raises Hive::BaseError do
51
+ @api.operations
52
+ end
45
53
  end
46
54
  end
47
55
  end
@@ -24,14 +24,15 @@ module Radiator
24
24
 
25
25
  def test_all_methods
26
26
  vcr_cassette('tag_api_all_methods') do
27
- skip
28
- vcr_cassette('all_methods') do
29
- @api.method_names.each do |key|
30
- begin
31
- assert @api.send key
32
- rescue Steem::ArgumentError
33
- next
34
- end
27
+ @api.method_names.each do |key|
28
+ begin
29
+ assert @api.send key
30
+ rescue Steem::ArgumentError
31
+ next
32
+ rescue Steem::RemoteNodeError
33
+ next
34
+ rescue ApiError
35
+ next
35
36
  end
36
37
  end
37
38
  end
@@ -423,9 +423,10 @@ module Radiator
423
423
  '8e0dc15c41c784b1862f132378382230d68b59e3592e72a32f310f8' +
424
424
  '8ea4baddb361a3709b664ba7375'
425
425
 
426
- skip "Suspect the original compare string might be incorrect."
427
426
  op_hex = sub_hex(hex_segments)
428
- assert compare.include?(op_hex), 'expect final comparison from original test'
427
+ expected_body_hex = hexlify(varint(op[:body].dup.force_encoding('BINARY').size) + op[:body].dup.force_encoding('BINARY'))
428
+ assert_equal expected_body_hex, hex_segments[:body], 'expect UTF-8 body serialization'
429
+ assert op_hex.include?(expected_body_hex), 'expect serialized operation to include UTF-8 body'
429
430
  end
430
431
 
431
432
  # See: https://github.com/steemit/steem-python/blob/master/tests/steem/test_transactions.py#L600
@@ -727,7 +728,7 @@ module Radiator
727
728
  expected_payload = @transaction.send :payload
728
729
  assert_equal expected_payload, @transaction.send(:payload)
729
730
  @transaction.send :prepare
730
- refute_equal expected_payload, @transaction.send(:payload)
731
+ refute_same expected_payload, @transaction.send(:payload)
731
732
  end
732
733
  private
733
734
  def seg(hex)
data/test/test_helper.rb CHANGED
@@ -1,5 +1,8 @@
1
1
  $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
2
2
 
3
+ ENV['RADIATOR_TEST_MODE'] ||= 'true'
4
+ ENV['RADIATOR_TEST_SUITE'] ||= 'default'
5
+
3
6
  if ENV["HELL_ENABLED"]
4
7
  require 'simplecov'
5
8
  SimpleCov.start
@@ -18,6 +21,25 @@ require 'awesome_print'
18
21
  VCR.configure do |c|
19
22
  c.cassette_library_dir = 'test/fixtures/vcr_cassettes'
20
23
  c.hook_into :webmock
24
+
25
+ c.register_request_matcher :jsonrpc_body do |request_1, request_2|
26
+ normalize = lambda do |request|
27
+ body = request.body.to_s
28
+ parsed = JSON.parse(body) rescue body
29
+
30
+ if parsed.is_a?(Hash)
31
+ parsed = parsed.reject { |k, _| k == 'id' }
32
+ elsif parsed.is_a?(Array)
33
+ parsed = parsed.map do |entry|
34
+ entry.is_a?(Hash) ? entry.reject { |k, _| k == 'id' } : entry
35
+ end
36
+ end
37
+
38
+ parsed
39
+ end
40
+
41
+ normalize.call(request_1) == normalize.call(request_2)
42
+ end
21
43
  end
22
44
 
23
45
  if ENV["HELL_ENABLED"]
@@ -36,7 +58,7 @@ if defined? WebMock
36
58
  WebMock.disable_net_connect!(allow_localhost: false, allow: 'codeclimate.com:443')
37
59
  end
38
60
 
39
- class Radiator::Test < MiniTest::Test
61
+ class Radiator::Test < Minitest::Test
40
62
  defined? prove_it! and prove_it!
41
63
 
42
64
  def chain_options
@@ -52,14 +74,24 @@ class Radiator::Test < MiniTest::Test
52
74
  end
53
75
 
54
76
  # Most likely modes: 'once' and 'new_episodes'
55
- VCR_RECORD_MODE = (ENV['VCR_RECORD_MODE'] || 'new_episodes').to_sym
77
+ # Default to :once so ordinary test runs do not silently rewrite cassettes.
78
+ # Use VCR_RECORD_MODE=new_episodes when intentionally refreshing fixtures.
79
+ VCR_RECORD_MODE = (ENV['VCR_RECORD_MODE'] || 'once').to_sym
56
80
 
57
81
  def vcr_cassette(name, &block)
58
- VCR.use_cassette(name, record: VCR_RECORD_MODE, match_requests_on: [:method, :uri, :body]) do
82
+ VCR.use_cassette(name, record: VCR_RECORD_MODE, match_requests_on: [:method, :uri, :jsonrpc_body]) do
59
83
  yield
60
84
  end
61
85
  end
62
86
 
87
+ def integration_test?
88
+ ENV['RADIATOR_TEST_SUITE'] == 'integration'
89
+ end
90
+
91
+ def skip_integration_test(message)
92
+ skip message unless integration_test?
93
+ end
94
+
63
95
  LOGGER = Logger.new(nil).tap do |logger|
64
96
  logger.progname = 'nil-logger'
65
97
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: radiator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Martin
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-07-30 00:00:00.000000000 Z
11
+ date: 2026-05-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -54,22 +54,22 @@ dependencies:
54
54
  name: minitest
55
55
  requirement: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - "~>"
58
- - !ruby/object:Gem::Version
59
- version: '5.10'
60
57
  - - ">="
61
58
  - !ruby/object:Gem::Version
62
59
  version: 5.10.3
60
+ - - "<"
61
+ - !ruby/object:Gem::Version
62
+ version: '7'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - "~>"
68
- - !ruby/object:Gem::Version
69
- version: '5.10'
70
67
  - - ">="
71
68
  - !ruby/object:Gem::Version
72
69
  version: 5.10.3
70
+ - - "<"
71
+ - !ruby/object:Gem::Version
72
+ version: '7'
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: minitest-line
75
75
  requirement: !ruby/object:Gem::Requirement
@@ -130,14 +130,14 @@ dependencies:
130
130
  requirements:
131
131
  - - "~>"
132
132
  - !ruby/object:Gem::Version
133
- version: 0.21.2
133
+ version: 0.22.0
134
134
  type: :development
135
135
  prerelease: false
136
136
  version_requirements: !ruby/object:Gem::Requirement
137
137
  requirements:
138
138
  - - "~>"
139
139
  - !ruby/object:Gem::Version
140
- version: 0.21.2
140
+ version: 0.22.0
141
141
  - !ruby/object:Gem::Dependency
142
142
  name: vcr
143
143
  requirement: !ruby/object:Gem::Requirement
@@ -275,7 +275,7 @@ dependencies:
275
275
  version: '1.0'
276
276
  - - ">="
277
277
  - !ruby/object:Gem::Version
278
- version: 1.0.3
278
+ version: 1.0.6
279
279
  type: :runtime
280
280
  prerelease: false
281
281
  version_requirements: !ruby/object:Gem::Requirement
@@ -285,7 +285,7 @@ dependencies:
285
285
  version: '1.0'
286
286
  - - ">="
287
287
  - !ruby/object:Gem::Version
288
- version: 1.0.3
288
+ version: 1.0.6
289
289
  - !ruby/object:Gem::Dependency
290
290
  name: json
291
291
  requirement: !ruby/object:Gem::Requirement
@@ -354,26 +354,6 @@ dependencies:
354
354
  - - '='
355
355
  - !ruby/object:Gem::Version
356
356
  version: 0.0.20
357
- - !ruby/object:Gem::Dependency
358
- name: ffi
359
- requirement: !ruby/object:Gem::Requirement
360
- requirements:
361
- - - "~>"
362
- - !ruby/object:Gem::Version
363
- version: '1.9'
364
- - - ">="
365
- - !ruby/object:Gem::Version
366
- version: 1.9.18
367
- type: :runtime
368
- prerelease: false
369
- version_requirements: !ruby/object:Gem::Requirement
370
- requirements:
371
- - - "~>"
372
- - !ruby/object:Gem::Version
373
- version: '1.9'
374
- - - ">="
375
- - !ruby/object:Gem::Version
376
- version: 1.9.18
377
357
  - !ruby/object:Gem::Dependency
378
358
  name: awesome_print
379
359
  requirement: !ruby/object:Gem::Requirement
@@ -480,6 +460,7 @@ files:
480
460
  - test/fixtures/vcr_cassettes/base_per_mvest.yml
481
461
  - test/fixtures/vcr_cassettes/block_time.yml
482
462
  - test/fixtures/vcr_cassettes/broadcast_transaction.yml
463
+ - test/fixtures/vcr_cassettes/chain_stats_api_all_methods.yml
483
464
  - test/fixtures/vcr_cassettes/chain_stats_api_jsonrpc.yml
484
465
  - test/fixtures/vcr_cassettes/condenser_all_all_methods.yml
485
466
  - test/fixtures/vcr_cassettes/condenser_api_jsonrpc.yml
@@ -487,19 +468,25 @@ files:
487
468
  - test/fixtures/vcr_cassettes/find_account.yml
488
469
  - test/fixtures/vcr_cassettes/find_block.yml
489
470
  - test/fixtures/vcr_cassettes/find_comment.yml
471
+ - test/fixtures/vcr_cassettes/follow_api_all_methods.yml
490
472
  - test/fixtures/vcr_cassettes/follow_api_jsonrpc.yml
473
+ - test/fixtures/vcr_cassettes/followed_by.yml
474
+ - test/fixtures/vcr_cassettes/following.yml
491
475
  - test/fixtures/vcr_cassettes/get_account_count.yml
492
476
  - test/fixtures/vcr_cassettes/get_account_references.yml
493
477
  - test/fixtures/vcr_cassettes/get_accounts.yml
494
478
  - test/fixtures/vcr_cassettes/get_accounts_no_argument.yml
495
479
  - test/fixtures/vcr_cassettes/get_dynamic_global_properties.yml
496
480
  - test/fixtures/vcr_cassettes/get_feed_history.yml
481
+ - test/fixtures/vcr_cassettes/get_followers.yml
497
482
  - test/fixtures/vcr_cassettes/get_hardfork_version.yml
498
483
  - test/fixtures/vcr_cassettes/get_key_references.yml
499
484
  - test/fixtures/vcr_cassettes/get_market_history.yml
500
485
  - test/fixtures/vcr_cassettes/get_market_history_buckets.yml
486
+ - test/fixtures/vcr_cassettes/get_operations.yml
501
487
  - test/fixtures/vcr_cassettes/get_order_book.yml
502
488
  - test/fixtures/vcr_cassettes/get_recent_trades.yml
489
+ - test/fixtures/vcr_cassettes/get_stats_for_time.yml
503
490
  - test/fixtures/vcr_cassettes/get_ticker.yml
504
491
  - test/fixtures/vcr_cassettes/get_trade_history.yml
505
492
  - test/fixtures/vcr_cassettes/get_vesting_delegations.yml
@@ -520,6 +507,7 @@ files:
520
507
  - test/fixtures/vcr_cassettes/ssc_contracts_find.yml
521
508
  - test/fixtures/vcr_cassettes/ssc_contracts_find_one.yml
522
509
  - test/fixtures/vcr_cassettes/stream_jsonrpc.yml
510
+ - test/fixtures/vcr_cassettes/tag_api_all_methods.yml
523
511
  - test/fixtures/vcr_cassettes/tag_api_jsonrpc.yml
524
512
  - test/fixtures/vcr_cassettes/transaction_expiration_initialize_nil.yml
525
513
  - test/fixtures/vcr_cassettes/transaction_jsonrpc.yml
@@ -544,7 +532,7 @@ homepage: https://github.com/inertia186/radiator
544
532
  licenses:
545
533
  - CC0-1.0
546
534
  metadata: {}
547
- post_install_message:
535
+ post_install_message:
548
536
  rdoc_options: []
549
537
  require_paths:
550
538
  - lib
@@ -559,8 +547,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
559
547
  - !ruby/object:Gem::Version
560
548
  version: '0'
561
549
  requirements: []
562
- rubygems_version: 3.2.3
563
- signing_key:
550
+ rubygems_version: 3.4.19
551
+ signing_key:
564
552
  specification_version: 4
565
553
  summary: Hive/Steem RPC Ruby Client
566
554
  test_files: []