Skip to content

Commit

Permalink
[ᚬmaster] fix: wrong cell status (#537)
Browse files Browse the repository at this point in the history
[ᚬmaster] fix: wrong cell status
  • Loading branch information
shaojunda authored Jan 2, 2020
2 parents 0040352 + 7522100 commit 1c9e0b4
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 2 additions & 0 deletions app/models/ckb_sync/node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,8 @@ def update_tx_fee_related_data(local_block, input_capacities)
CellInput.import!(updated_inputs, validate: false, on_duplicate_key_update: [:previous_cell_output_id])
CellOutput.import!(updated_outputs, validate: false, on_duplicate_key_update: [:consumed_by_id, :status])
AccountBook.import!(account_books, validate: false)
updated_inputs.map(&:flush_cache)
updated_outputs.map(&:flush_cache)
end
end
end
Expand Down
15 changes: 14 additions & 1 deletion test/models/ckb_sync/node_data_processor_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1098,15 +1098,28 @@ class NodeDataProcessorTest < ActiveSupport::TestCase

test "#process_block should fill all cell input's previous cell output id without cellbase's cell input" do
VCR.use_cassette("blocks/#{DEFAULT_NODE_BLOCK_NUMBER}") do
redis_cache_store = ActiveSupport::Cache.lookup_store(:redis_cache_store)
Rails.stubs(:cache).returns(redis_cache_store)
Rails.cache.extend(CacheRealizer)
node_block = fake_node_block("0x3307186493c5da8b91917924253a5ffd35231151649d0c7e2941aa8801815063")
block = create(:block, :with_block_hash)
ckb_transaction1 = create(:ckb_transaction, tx_hash: "0x498315db9c7ba144cca74d2e9122ac9b3a3da1641b2975ae321d91ec34f1c0e3", block: block)
ckb_transaction2 = create(:ckb_transaction, tx_hash: "0x598315db9c7ba144cca74d2e9122ac9b3a3da1641b2975ae321d91ec34f1c0e3", block: block)
create(:cell_output, ckb_transaction: ckb_transaction1, cell_index: 1, tx_hash: "0x498315db9c7ba144cca74d2e9122ac9b3a3da1641b2975ae321d91ec34f1c0e3", generated_by: ckb_transaction2, block: block)
create(:cell_output, ckb_transaction: ckb_transaction2, cell_index: 2, tx_hash: "0x598315db9c7ba144cca74d2e9122ac9b3a3da1641b2975ae321d91ec34f1c0e3", generated_by: ckb_transaction1, block: block)
local_block = node_data_processor.process_block(node_block)
cell_outputs = CellOutput.all
cell_outputs.each do |cell_output|
tx = cell_output.ckb_transaction
tx.display_outputs
assert_not_nil Rails.cache.realize("normal_tx_display_outputs_previews_false_#{tx.id}")
end

local_block = node_data_processor.process_block(node_block)
assert_empty local_block.cell_inputs.where(from_cell_base: false, previous_cell_output_id: nil)
cell_outputs.each do |cell_output|
tx = cell_output.ckb_transaction
assert_nil Rails.cache.realize("normal_tx_display_outputs_previews_false_#{tx.id}")
end
end
end

Expand Down

0 comments on commit 1c9e0b4

Please sign in to comment.