Skip to content

Commit

Permalink
test: query special address and normal address
Browse files Browse the repository at this point in the history
  • Loading branch information
shaojunda committed Dec 13, 2019
1 parent 8adef4f commit a65ae58
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
2 changes: 2 additions & 0 deletions config/settings/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
special_addresses:
ckb1qyq0hcfpff4h8w8zvy44uurvlgdrr09tefwqx266dl: ckb1q3w9q60tppt7l3j7r09qcp7lxnp3vcanvgha8pmvsa3jplykxn323t90gna20lusyshreg32qee4fhkt9jj2t6qrqzzqxzq8yqt8kmd9
14 changes: 14 additions & 0 deletions test/controllers/api/v1/addresses_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit a65ae58

Please sign in to comment.