diff --git a/config/settings/test.yml b/config/settings/test.yml new file mode 100644 index 000000000..d47c4d774 --- /dev/null +++ b/config/settings/test.yml @@ -0,0 +1,2 @@ +special_addresses: + ckb1qyq0hcfpff4h8w8zvy44uurvlgdrr09tefwqx266dl: ckb1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn323t90gna20lusyshreg32qee4fhkt9jj2t6qrqzzqxzq8yqt8kmd9 diff --git a/test/controllers/api/v1/addresses_controller_test.rb b/test/controllers/api/v1/addresses_controller_test.rb index cbb0fe919..a9550259e 100644 --- a/test/controllers/api/v1/addresses_controller_test.rb +++ b/test/controllers/api/v1/addresses_controller_test.rb @@ -99,6 +99,20 @@ class AddressesControllerTest < ActionDispatch::IntegrationTest assert_equal response_json, response.body ENV["CKB_NET_MODE"] = "mainnet" end + + test "should return special address when query address is special" do + address = create(:address, :with_lock_script, address_hash: "ckb1qyq0hcfpff4h8w8zvy44uurvlgdrr09tefwqx266dl") + + valid_get api_v1_address_url(address.address_hash) + assert_equal Settings.special_addresses[address.address_hash], json.dig("data", "attributes", "special_address") + end + + test "should not return special address when query address is not special" do + address = create(:address, :with_lock_script, address_hash: "ckb1qyqdmeuqrsrnm7e5vnrmruzmsp4m9wacf6vsxasryq") + + valid_get api_v1_address_url(address.address_hash) + assert_nil json.dig("data", "attributes", "special_address") + end end end end