Skip to content

Commit 1c9e0b4

Browse files
authored
[ᚬmaster] fix: wrong cell status (#537)
[ᚬmaster] fix: wrong cell status
2 parents 0040352 + 7522100 commit 1c9e0b4

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

app/models/ckb_sync/node_data_processor.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,8 @@ def update_tx_fee_related_data(local_block, input_capacities)
468468
CellInput.import!(updated_inputs, validate: false, on_duplicate_key_update: [:previous_cell_output_id])
469469
CellOutput.import!(updated_outputs, validate: false, on_duplicate_key_update: [:consumed_by_id, :status])
470470
AccountBook.import!(account_books, validate: false)
471+
updated_inputs.map(&:flush_cache)
472+
updated_outputs.map(&:flush_cache)
471473
end
472474
end
473475
end

test/models/ckb_sync/node_data_processor_test.rb

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,15 +1098,28 @@ class NodeDataProcessorTest < ActiveSupport::TestCase
10981098

10991099
test "#process_block should fill all cell input's previous cell output id without cellbase's cell input" do
11001100
VCR.use_cassette("blocks/#{DEFAULT_NODE_BLOCK_NUMBER}") do
1101+
redis_cache_store = ActiveSupport::Cache.lookup_store(:redis_cache_store)
1102+
Rails.stubs(:cache).returns(redis_cache_store)
1103+
Rails.cache.extend(CacheRealizer)
11011104
node_block = fake_node_block("0x3307186493c5da8b91917924253a5ffd35231151649d0c7e2941aa8801815063")
11021105
block = create(:block, :with_block_hash)
11031106
ckb_transaction1 = create(:ckb_transaction, tx_hash: "0x498315db9c7ba144cca74d2e9122ac9b3a3da1641b2975ae321d91ec34f1c0e3", block: block)
11041107
ckb_transaction2 = create(:ckb_transaction, tx_hash: "0x598315db9c7ba144cca74d2e9122ac9b3a3da1641b2975ae321d91ec34f1c0e3", block: block)
11051108
create(:cell_output, ckb_transaction: ckb_transaction1, cell_index: 1, tx_hash: "0x498315db9c7ba144cca74d2e9122ac9b3a3da1641b2975ae321d91ec34f1c0e3", generated_by: ckb_transaction2, block: block)
11061109
create(:cell_output, ckb_transaction: ckb_transaction2, cell_index: 2, tx_hash: "0x598315db9c7ba144cca74d2e9122ac9b3a3da1641b2975ae321d91ec34f1c0e3", generated_by: ckb_transaction1, block: block)
1107-
local_block = node_data_processor.process_block(node_block)
1110+
cell_outputs = CellOutput.all
1111+
cell_outputs.each do |cell_output|
1112+
tx = cell_output.ckb_transaction
1113+
tx.display_outputs
1114+
assert_not_nil Rails.cache.realize("normal_tx_display_outputs_previews_false_#{tx.id}")
1115+
end
11081116

1117+
local_block = node_data_processor.process_block(node_block)
11091118
assert_empty local_block.cell_inputs.where(from_cell_base: false, previous_cell_output_id: nil)
1119+
cell_outputs.each do |cell_output|
1120+
tx = cell_output.ckb_transaction
1121+
assert_nil Rails.cache.realize("normal_tx_display_outputs_previews_false_#{tx.id}")
1122+
end
11101123
end
11111124
end
11121125

0 commit comments

Comments
 (0)