Skip to content

Commit

Permalink
DigixGlobal#70 resend_transactions test randomized
Browse files Browse the repository at this point in the history
  • Loading branch information
bshevchenko committed Sep 11, 2019
1 parent 87c8687 commit 5e48367
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions test/models/watching_transaction_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,9 @@ class WatchingTransactionTest < ActiveSupport::TestCase
user = create(:user)
group_id = SecureRandom.uuid
size = SecureRandom.rand(1..6)
size.times do
transaction_group = (1..size).map do
FactoryBot.create(:watching_transaction, group_id: group_id, user: user)
end
latest = FactoryBot.create(:watching_transaction, group_id: group_id, user: user)

pending_stub = stub_request(:post, EthereumApi::SERVER_URL)
.with(body: /eth_getTransactionByHash/)
Expand All @@ -72,7 +71,7 @@ class WatchingTransactionTest < ActiveSupport::TestCase
)

mined_stub = stub_request(:post, EthereumApi::SERVER_URL)
.with(body: /eth_getTransactionByHash.*#{latest.txhash}/)
.with(body: /eth_getTransactionByHash.*#{transaction_group.sample.txhash}/)
.to_return(
body: {
result: {
Expand All @@ -83,7 +82,7 @@ class WatchingTransactionTest < ActiveSupport::TestCase

WatchingTransaction.resend_transactions

assert_requested(pending_stub, times: size + 1)
assert_requested(pending_stub, times: size)
assert_requested(mined_stub, times: 1)
assert_equal 0, WatchingTransaction.where(group_id: group_id).count,
'should destroy all if one is mined'
Expand Down

0 comments on commit 5e48367

Please sign in to comment.