From af45b85d4976e0bfde013e07b74e33da9f3cc902 Mon Sep 17 00:00:00 2001 From: Rabbit Date: Tue, 2 Apr 2024 16:38:20 +0800 Subject: [PATCH] Feat/rgb (#1728) * fix: udt cell amount * chore: adjust test --- app/controllers/concerns/cell_data_comparator.rb | 2 +- .../api/v2/ckb_transactions_controller_test.rb | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/controllers/concerns/cell_data_comparator.rb b/app/controllers/concerns/cell_data_comparator.rb index fb518d30c..3551de378 100644 --- a/app/controllers/concerns/cell_data_comparator.rb +++ b/app/controllers/concerns/cell_data_comparator.rb @@ -69,7 +69,7 @@ def diff_udt_cells(inputs, outputs) amount = output&.dig(:amount).to_f - input&.dig(:amount).to_f capacity = output&.dig(:capacity).to_f - input&.dig(:capacity).to_f - udt_info = udt_infos[k[1]].merge(amount:) + udt_info = udt_infos[k[1]].merge(amount: "%f" % amount) transfers[k[0]] << CkbUtils.hash_value_to_s({ capacity:, cell_type: k[2], udt_info: }) end diff --git a/test/controllers/api/v2/ckb_transactions_controller_test.rb b/test/controllers/api/v2/ckb_transactions_controller_test.rb index f73564bc6..efda76515 100644 --- a/test/controllers/api/v2/ckb_transactions_controller_test.rb +++ b/test/controllers/api/v2/ckb_transactions_controller_test.rb @@ -36,13 +36,13 @@ class CkbTransactionsControllerTest < ActionDispatch::IntegrationTest block: block2, previous_output: { tx_hash: tx1.tx_hash, - index: 0 + index: 0, }) create(:cell_input, ckb_transaction: tx2, block: block2, previous_output: { tx_hash: tx1.tx_hash, - index: 1 + index: 1, }) # create outputs create(:cell_output, ckb_transaction: tx2, @@ -107,13 +107,13 @@ class CkbTransactionsControllerTest < ActionDispatch::IntegrationTest block: block2, previous_output: { tx_hash: tx1.tx_hash, - index: 0 + index: 0, }) create(:cell_input, ckb_transaction: tx2, block: block2, previous_output: { tx_hash: tx1.tx_hash, - index: 1 + index: 1, }) # create outputs create(:cell_output, ckb_transaction: tx2, @@ -141,8 +141,8 @@ class CkbTransactionsControllerTest < ActionDispatch::IntegrationTest transfers2 = data2[0]["transfers"] assert_equal 2, json["data"].size - assert_equal "-2000000000000.0", transfers1[0]["udt_info"]["amount"] - assert_equal "2000000000000.0", transfers2[0]["udt_info"]["amount"] + assert_equal "-2000000000000.000000", transfers1[0]["udt_info"]["amount"] + assert_equal "2000000000000.000000", transfers2[0]["udt_info"]["amount"] end end end