Skip to content

Commit

Permalink
chore: adjust tests (#1691)
Browse files Browse the repository at this point in the history
  • Loading branch information
rabbitz authored Mar 20, 2024
1 parent d6c1752 commit 53db71e
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
4 changes: 4 additions & 0 deletions app/serializers/ckb_transaction_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,4 +100,8 @@ class CkbTransactionSerializer
attribute :max_cycles do
EpochStatistic.max_tx_cycles
end

attribute :is_rgb_transaction do |object|
object.rgb_transaction?
end
end
3 changes: 2 additions & 1 deletion test/controllers/api/v1/ckb_transactions_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ module V1
class CkbTransactionsControllerTest < ActionDispatch::IntegrationTest
TransactionKeys = %w(
block_number transaction_hash block_timestamp transaction_fee bytes version display_inputs
display_outputs is_cellbase income witnesses cell_deps header_deps tx_status detailed_message largest_tx largest_tx_in_epoch cycles max_cycles_in_epoch max_cycles
display_outputs is_cellbase income witnesses cell_deps header_deps tx_status detailed_message
largest_tx largest_tx_in_epoch cycles max_cycles_in_epoch max_cycles is_rgb_transaction
).sort
setup do
CkbSync::Api.any_instance.stubs(:get_blockchain_info).returns(OpenStruct.new(chain: "ckb_testnet"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class DaoContractTransactionsControllerTest < ActionDispatch::IntegrationTest

test "should return corresponding ckb transaction with given transaction hash and the tx's input is dao cell" do
ckb_transaction = create(:ckb_transaction)
create(:cell_output, ckb_transaction: ckb_transaction,
create(:cell_output, ckb_transaction:,
cell_index: 0,
tx_hash: "0x498315db9c7ba144cca74d2e9122ac9b3a3da1641b2975ae321d91ec34f1c0e3",
consumed_by: ckb_transaction,
Expand All @@ -98,7 +98,7 @@ class DaoContractTransactionsControllerTest < ActionDispatch::IntegrationTest

test "should return corresponding ckb transaction with given transaction hash and the tx's output is dao cell" do
ckb_transaction = create(:ckb_transaction)
create(:cell_output, ckb_transaction: ckb_transaction,
create(:cell_output, ckb_transaction:,
cell_index: 0,
tx_hash: "0x498315db9c7ba144cca74d2e9122ac9b3a3da1641b2975ae321d91ec34f1c0e3",
consumed_by: ckb_transaction,
Expand All @@ -114,7 +114,7 @@ class DaoContractTransactionsControllerTest < ActionDispatch::IntegrationTest
test "should contain right keys in the serialized object when call show" do
prepare_node_data(8)
ckb_transaction = create(:ckb_transaction)
create(:cell_output, ckb_transaction: ckb_transaction,
create(:cell_output, ckb_transaction:,
cell_index: 0,
tx_hash: "0x498315db9c7ba144cca74d2e9122ac9b3a3da1641b2975ae321d91ec34f1c0e3",
consumed_by: ckb_transaction,
Expand All @@ -126,7 +126,9 @@ class DaoContractTransactionsControllerTest < ActionDispatch::IntegrationTest
valid_get api_v1_dao_contract_transaction_url(ckb_transaction.tx_hash)

response_tx_transaction = json["data"]
assert_equal %w(block_number transaction_hash block_timestamp transaction_fee version bytes display_inputs display_outputs is_cellbase income witnesses cell_deps header_deps tx_status detailed_message largest_tx largest_tx_in_epoch cycles max_cycles_in_epoch max_cycles).sort, response_tx_transaction["attributes"].keys.sort
assert_equal %w(block_number transaction_hash block_timestamp transaction_fee version bytes display_inputs
display_outputs is_cellbase income witnesses cell_deps header_deps tx_status detailed_message
largest_tx largest_tx_in_epoch cycles max_cycles_in_epoch max_cycles is_rgb_transaction).sort, response_tx_transaction["attributes"].keys.sort
end

test "should return error object when given tx hash corresponds to a normal transaction" do
Expand Down

0 comments on commit 53db71e

Please sign in to comment.