Skip to content

Commit dc876fd

Browse files
committed
Merge branch 'develop' into staging
2 parents 6200717 + a3caf63 commit dc876fd

File tree

4 files changed

+45
-2
lines changed

4 files changed

+45
-2
lines changed

app/workers/token_collection_tag_worker.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def invalid_char?(name)
3535
end
3636

3737
def invisible_char?(name)
38-
(name =~ /^[\x21-\x7E\u4E00-\u9FFF]+(?:\s[\x21-\x7E\u4E00-\u9FFF]+)?$/).nil?
38+
(name =~ /^[\x21-\x7E\u4E00-\u9FFF]+(?:\s[\x21-\x7E\u4E00-\u9FFF]+)*$/).nil?
3939
end
4040

4141
def out_of_length?(name)
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
namespace :migration do
2+
desc "Usage: RAILS_ENV=production bundle exec rake migration:check_dao_event"
3+
task check_dao_event: :environment do
4+
error_tx_ids = []
5+
CkbTransaction.where("tags @> array[?]::varchar[]", ["dao"]).find_each do |tx|
6+
tx.outputs.where(cell_type: :nervos_dao_deposit).each do |output|
7+
unless DaoEvent.where(ckb_transaction_id: tx.id, address_id: output.address_id, value: output.capacity, event_type: "deposit_to_dao", cell_index: output.cell_index).exists?
8+
error_tx_ids << tx.id
9+
end
10+
end
11+
tx.cell_inputs.where(cell_type: :nervos_dao_withdrawing).each do |input|
12+
previous_cell_output = CellOutput.
13+
where(id: input.previous_cell_output_id).
14+
select(:address_id, :block_id, :ckb_transaction_id, :dao, :cell_index, :capacity, :occupied_capacity).
15+
take!
16+
interest = CkbUtils.dao_interest(previous_cell_output)
17+
unless DaoEvent.where(ckb_transaction_id: tx.id, address_id: previous_cell_output.address_id, value: interest, event_type: "issue_interest", cell_index: input.index).exists?
18+
error_tx_ids << tx.id
19+
20+
end
21+
end
22+
tx.cell_inputs.where(cell_type: :nervos_dao_deposit).each do |input|
23+
previous_cell_output =
24+
CellOutput.
25+
where(id: input.previous_cell_output_id).
26+
select(:address_id, :ckb_transaction_id, :cell_index, :capacity).
27+
take!
28+
unless DaoEvent.where(ckb_transaction_id: tx.id, address_id: previous_cell_output.address_id, value: previous_cell_output.capacity, event_type: "withdraw_from_dao",
29+
cell_index: input.index).exists?
30+
error_tx_ids << tx.id
31+
end
32+
end
33+
end
34+
puts error_tx_ids.join(",")
35+
end
36+
end

test/models/ckb_sync/node_data_processor_test.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1254,6 +1254,7 @@ class NodeDataProcessorTest < ActiveSupport::TestCase
12541254
address2 = Address.find_by(lock_hash: lock2.compute_hash)
12551255
address3 = Address.find_by(lock_hash: lock3.compute_hash)
12561256
CkbSync::Api.any_instance.stubs(:get_tip_block_number).returns(block.number + 1)
1257+
DaoContract.default_contract.update!(deposit_transactions_count: 4)
12571258
VCR.use_cassette("blocks/#{DEFAULT_NODE_BLOCK_NUMBER}",
12581259
record: :new_episodes) do
12591260
node_data_processor.call
@@ -3839,7 +3840,7 @@ class NodeDataProcessorTest < ActiveSupport::TestCase
38393840
Sidekiq::Testing.inline!
38403841
block = node_data_processor.process_block(node_block)
38413842
CkbSync::Api.any_instance.stubs(:get_tip_block_number).returns(block.number + 1)
3842-
3843+
DaoContract.default_contract.update!(deposit_transactions_count: 4)
38433844
VCR.use_cassette("blocks/#{DEFAULT_NODE_BLOCK_NUMBER}",
38443845
record: :new_episodes) do
38453846
node_data_processor.call

test/workers/token_collection_tag_worker_test.rb

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ class TokenCollectionTagWorkerTest < ActiveJob::TestCase
1919
assert_equal ["suspicious"], TokenCollection.last.tags
2020
end
2121

22+
test "add suspicious tag to token_collection when blanks are not continuous" do
23+
create(:token_collection, name: "C K B B", cell_id: @cell.id, creator_id: @address.id)
24+
TokenCollectionTagWorker.new.perform
25+
assert_equal ["rgb++", "layer-1-asset"], TokenCollection.last.tags
26+
end
27+
2228
test "add out-of-length-range tag to token_collection" do
2329
create(:token_collection, name: "C" * 66, cell_id: @cell.id, creator_id: @address.id)
2430
TokenCollectionTagWorker.new.perform

0 commit comments

Comments
 (0)