@@ -64,10 +64,7 @@ class DaoEventsTest < ActiveSupport::TestCase
6464 create ( :block , :with_block_hash , number : node_block . header . number - 1 )
6565 VCR . use_cassette ( "blocks/#{ DEFAULT_NODE_BLOCK_NUMBER } " ) do
6666 fake_dao_withdraw_transaction ( node_block )
67-
68- assert_difference -> { DaoContract . default_contract . withdraw_transactions_count } , 1 do
69- node_data_processor . process_block ( node_block )
70- end
67+ node_data_processor . process_block ( node_block )
7168
7269 deposit_to_dao_events = Block . find_by ( number : node_block . header . number ) . dao_events . where ( event_type : "withdraw_from_dao" )
7370 assert_equal [ "processed" ] , deposit_to_dao_events . pluck ( :status ) . uniq
@@ -220,7 +217,6 @@ class DaoEventsTest < ActiveSupport::TestCase
220217
221218 assert_equal [ "dao" ] , tx . tags
222219 assert_equal [ "dao" ] , tx1 . tags
223- assert_equal 2 , DaoContract . default_contract . ckb_transactions_count
224220 end
225221
226222 test "should increase address dao_deposit when block is invalid and previous output is a dao cell" do
@@ -278,7 +274,7 @@ class DaoEventsTest < ActiveSupport::TestCase
278274 end
279275 end
280276
281- test "should decrease dao contract withdraw_transactions_count when block is invalid and previous output is a dao cell" do
277+ test "when block is invalid and previous output is a dao cell" do
282278 DaoCompensationCalculator . any_instance . stubs ( :call ) . returns ( 1000 )
283279 DaoContract . default_contract . update ( total_deposit : 100000000000000 , depositors_count : 1 )
284280 node_block = fake_node_block ( "0x3307186493c5da8b91917924253a5ffd35231151649d0c7e2941aa8801815063" )
@@ -296,10 +292,7 @@ class DaoEventsTest < ActiveSupport::TestCase
296292 local_block . update ( block_hash : "0x419c632366c8eb9635acbb39ea085f7552ae62e1fdd480893375334a0f37d1bx" )
297293
298294 VCR . use_cassette ( "blocks/#{ DEFAULT_NODE_BLOCK_NUMBER } " , record : :new_episodes ) do
299- assert_difference -> { DaoContract . default_contract . reload . withdraw_transactions_count } , -1 do
300- node_data_processor . call
301- end
302-
295+ node_data_processor . call
303296 dao_events = local_block . dao_events . where ( event_type : "withdraw_from_dao" )
304297 assert_equal [ "reverted" ] , dao_events . pluck ( :status ) . uniq
305298 end
@@ -426,10 +419,8 @@ class DaoEventsTest < ActiveSupport::TestCase
426419 init_total_deposit = ( 10 **8 ) * 10000
427420 init_depositors_count = 3
428421 init_interest_granted = ( 10 **8 ) * 100
429- init_deposit_transactions_count = 2
430- init_withdraw_transactions_count = 1
431422 dao_contract . update ( total_deposit : init_total_deposit , depositors_count : init_depositors_count ,
432- claimed_compensation : init_interest_granted , deposit_transactions_count : init_deposit_transactions_count , withdraw_transactions_count : init_withdraw_transactions_count )
423+ claimed_compensation : init_interest_granted )
433424 create_list ( :dao_event , 3 , status : :processed , contract_id : 1 , event_type : "deposit_to_dao" )
434425 prepare_node_data ( HAS_UNCLES_BLOCK_NUMBER )
435426 local_block = Block . find_by ( number : HAS_UNCLES_BLOCK_NUMBER )
@@ -441,8 +432,6 @@ class DaoEventsTest < ActiveSupport::TestCase
441432 assert_equal init_total_deposit , dao_contract . total_deposit
442433 assert_equal init_depositors_count , dao_contract . depositors_count
443434 assert_equal init_interest_granted , dao_contract . claimed_compensation
444- assert_equal init_deposit_transactions_count , dao_contract . deposit_transactions_count
445- assert_equal init_withdraw_transactions_count , dao_contract . withdraw_transactions_count
446435 end
447436 end
448437
@@ -525,10 +514,7 @@ class DaoEventsTest < ActiveSupport::TestCase
525514 local_block . update ( block_hash : "0x419c632366c8eb9635acbb39ea085f7552ae62e1fdd480893375334a0f37d1bx" )
526515
527516 VCR . use_cassette ( "blocks/#{ DEFAULT_NODE_BLOCK_NUMBER } " , record : :new_episodes ) do
528- assert_difference -> { dao_contract . reload . deposit_transactions_count } , -1 do
529- node_data_processor . call
530- end
531-
517+ node_data_processor . call
532518 deposit_to_dao_events = local_block . dao_events . where ( event_type : "deposit_to_dao" )
533519 assert_equal [ "reverted" ] , deposit_to_dao_events . pluck ( :status ) . uniq
534520 end
@@ -577,19 +563,14 @@ class DaoEventsTest < ActiveSupport::TestCase
577563 create ( :block , :with_block_hash , number : node_block . header . number - 1 )
578564 VCR . use_cassette ( "blocks/#{ DEFAULT_NODE_BLOCK_NUMBER } " ) do
579565 fake_dao_deposit_transaction ( node_block )
580-
581- assert_difference -> { DaoContract . default_contract . deposit_transactions_count } , 1 do
582- node_data_processor . process_block ( node_block )
583- end
584-
566+ node_data_processor . process_block ( node_block )
585567 deposit_to_dao_events = Block . find_by ( number : node_block . header . number ) . dao_events . where ( event_type : "deposit_to_dao" )
586568 assert_equal [ "processed" ] , deposit_to_dao_events . pluck ( :status ) . uniq
587569 end
588570 end
589571
590572 test "#process_block should not update dao contract total depositors count when depositors is already has been recorded" do
591- DaoContract . default_contract . update ( total_deposit : 100000000000000 , depositors_count : 1 ,
592- total_depositors_count : 1 )
573+ DaoContract . default_contract . update ( total_deposit : 100000000000000 , depositors_count : 1 )
593574 CkbSync ::Api . any_instance . stubs ( :calculate_dao_maximum_withdraw ) . returns ( "0x2faf0be8" )
594575
595576 node_block = fake_node_block ( "0x3307186493c5da8b91917924253a5ffd35231151649d0c7e2941aa8801815063" )
@@ -614,10 +595,6 @@ class DaoEventsTest < ActiveSupport::TestCase
614595 output1 . capacity = ( 10 **8 ) * 1000
615596 tx1 . outputs << output1
616597 tx1 . outputs_data << CKB ::Utils . bin_to_hex ( "\x00 " * 8 )
617-
618- assert_no_changes -> { DaoContract . default_contract . total_depositors_count } do
619- node_data_processor . process_block ( node_block )
620- end
621598 end
622599
623600 test "#process_block should not update dao contract depositors count when depositors is already has been recorded" do
@@ -728,7 +705,6 @@ class DaoEventsTest < ActiveSupport::TestCase
728705 tx1 = block . ckb_transactions . where ( is_cellbase : false ) . second
729706 assert_equal [ "dao" ] , tx . tags
730707 assert_equal [ "dao" ] , tx1 . tags
731- assert_equal 2 , DaoContract . default_contract . ckb_transactions_count
732708 end
733709
734710 test "should update tx's tags when output have udt cells and nervos_dao_withdrawing cell" do
@@ -793,7 +769,6 @@ class DaoEventsTest < ActiveSupport::TestCase
793769
794770 tx = block . ckb_transactions . where ( is_cellbase : false ) . first
795771 assert_equal %w[ dao udt ] , tx . tags
796- assert_equal 1 , DaoContract . default_contract . ckb_transactions_count
797772 end
798773
799774 private
0 commit comments