Skip to content

Commit

Permalink
test: fix test
Browse files Browse the repository at this point in the history
Signed-off-by: Miles Zhang <[email protected]>
  • Loading branch information
zmcNotafraid committed Dec 30, 2024
1 parent a4ad405 commit faf41b4
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
3 changes: 2 additions & 1 deletion app/models/ckb_sync/new_node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ def process_withdraw_dao_events!(local_block, _new_dao_depositors,
addrs_withdraw_info[address.id][:is_depositor] = false
dao_events_attributes << {
ckb_transaction_id: dao_input.ckb_transaction_id,
cell_index: nil,
block_id: local_block.id,
block_timestamp: local_block.timestamp,
address_id: previous_cell_output.address_id,
Expand Down Expand Up @@ -353,7 +354,7 @@ def process_deposit_dao_events!(local_block, new_dao_depositors, dao_contract)
addresses_deposit_info = {}
# build deposit dao events
local_block.cell_outputs.nervos_dao_deposit.select(:id, :address_id, :capacity,
:ckb_transaction_id).find_in_batches do |dao_outputs|
:ckb_transaction_id, :cell_index).find_in_batches do |dao_outputs|
deposit_dao_events_attributes = []
dao_outputs.each do |dao_output|
address = dao_output.address
Expand Down
18 changes: 9 additions & 9 deletions test/models/ckb_sync/dao_events_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,9 @@ class DaoEventsTest < ActiveSupport::TestCase

deposit_to_dao_events = Block.find_by(number: node_block.header.number).dao_events.where(event_type: "withdraw_from_dao")
assert_equal ["processed"], deposit_to_dao_events.pluck(:status).uniq
assert_equal %w(block_id ckb_transaction_id address_id contract_id event_type value status block_timestamp), deposit_to_dao_events.first.attribute_names.reject { |attribute|
attribute.in?(%w(created_at updated_at id))
}
assert_equal %w(block_id ckb_transaction_id address_id contract_id event_type value status block_timestamp withdrawn_transaction_id cell_index), deposit_to_dao_events.first.attribute_names.reject { |attribute|
attribute.in?(%w(created_at updated_at id))
}
end
end

Expand Down Expand Up @@ -420,9 +420,9 @@ class DaoEventsTest < ActiveSupport::TestCase

deposit_to_dao_events = Block.find_by(number: node_block.header.number).dao_events.where(event_type: "withdraw_from_dao")
assert_equal ["processed"], deposit_to_dao_events.pluck(:status).uniq
assert_equal %w(block_id ckb_transaction_id address_id contract_id event_type value status block_timestamp), deposit_to_dao_events.first.attribute_names.reject { |attribute|
attribute.in?(%w(created_at updated_at id))
}
assert_equal %w(block_id ckb_transaction_id address_id contract_id event_type value status block_timestamp withdrawn_transaction_id cell_index), deposit_to_dao_events.first.attribute_names.reject { |attribute|
attribute.in?(%w(created_at updated_at id))
}
end
end

Expand Down Expand Up @@ -732,9 +732,9 @@ class DaoEventsTest < ActiveSupport::TestCase

deposit_to_dao_events = Block.find_by(number: node_block.header.number).dao_events.where(event_type: "new_dao_depositor")
assert_equal ["processed"], deposit_to_dao_events.pluck(:status).uniq
assert_equal %w(block_id ckb_transaction_id address_id contract_id event_type value status block_timestamp), deposit_to_dao_events.first.attribute_names.reject { |attribute|
attribute.in?(%w(created_at updated_at id))
}
assert_equal %w(block_id ckb_transaction_id address_id contract_id event_type value status block_timestamp withdrawn_transaction_id cell_index), deposit_to_dao_events.first.attribute_names.reject { |attribute|
attribute.in?(%w(created_at updated_at id))
}
end
end

Expand Down
2 changes: 1 addition & 1 deletion test/models/dao_event_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class DaoEventTest < ActiveSupport::TestCase

test "should have correct columns" do
dao_event = create(:dao_event)
expected_attributes = %w(address_id block_id block_timestamp contract_id created_at event_type id status ckb_transaction_id updated_at value).sort
expected_attributes = %w(address_id block_id block_timestamp contract_id created_at event_type id status ckb_transaction_id updated_at value cell_index withdrawn_transaction_id).sort
assert_equal expected_attributes, dao_event.attributes.keys.sort
end
end

0 comments on commit faf41b4

Please sign in to comment.