|
8 | 8 | # Start old server on port 9001 |
9 | 9 | GS_REST_DEV_PORT=9001 make serve-old |
10 | 10 |
|
11 | | - # Start new FastAPI server on port 9002 |
12 | | - uv run uvicorn gsrest.app:create_app --factory --port 9002 |
| 11 | + # Start new FastAPI server on port 9000 |
| 12 | + uv run uvicorn gsrest.app:create_app --factory --port 9000 |
13 | 13 |
|
14 | 14 | # Run comparison tests |
15 | 15 | uv run pytest tests/test_fastapi_migration.py -v -s |
|
33 | 33 |
|
34 | 34 | # Server endpoints - can be overridden via environment variables |
35 | 35 | OLD_SERVER = os.environ.get("OLD_SERVER", "http://localhost:9001") |
36 | | -NEW_SERVER = os.environ.get("NEW_SERVER", "http://localhost:9002") |
| 36 | +NEW_SERVER = os.environ.get("NEW_SERVER", "http://localhost:9000") |
37 | 37 |
|
38 | 38 | HEADERS = {"Content-Type": "application/json", "Accept": "application/json"} |
39 | 39 |
|
40 | 40 | # Test data constants |
41 | 41 | BTC_ADDRESS = "1Archive1n2C579dMsAu3iC6tWzuQJz8dN" |
| 42 | +BTC_ADDRESS_PRIVATE_TAGS = "3D4gm7eGSXiEkWS5V3hN9kDVo2eDGBK4eA" # Address with potentially private tags |
42 | 43 | ETH_ADDRESS = "0xdac17f958d2ee523a2206206994597c13d831ec7" |
43 | 44 | BTC_ENTITY = 109578 |
44 | 45 | BTC_TX = "4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b" |
@@ -681,6 +682,55 @@ def test_supported_tokens(self): |
681 | 682 | self.assert_endpoint_equal("eth/supported_tokens") |
682 | 683 |
|
683 | 684 |
|
| 685 | +class TestAddressObfuscation(MigrationTestBase): |
| 686 | + """Test address/entity endpoints to verify tag obfuscation behavior is consistent. |
| 687 | +
|
| 688 | + These tests verify that tag/actor obfuscation works identically between |
| 689 | + the old aiohttp and new FastAPI implementations for addresses with: |
| 690 | + - Public tags (1Archive1n2C579dMsAu3iC6tWzuQJz8dN - Internet Archive) |
| 691 | + - Potentially private tags (3D4gm7eGSXiEkWS5V3hN9kDVo2eDGBK4eA) |
| 692 | +
|
| 693 | + Tests use endpoints where obfuscation is actually applied: |
| 694 | + - /addresses/{addr}/entity - obfuscates best_address_tag and actors |
| 695 | + - /addresses/{addr}/tag_summary - obfuscates via tag_transformer in service |
| 696 | + - /entities/{entity}/tags - obfuscates private tag labels |
| 697 | + """ |
| 698 | + |
| 699 | + @pytest.mark.migration |
| 700 | + @pytest.mark.parametrize("address", [BTC_ADDRESS, BTC_ADDRESS_PRIVATE_TAGS]) |
| 701 | + def test_address_entity_obfuscation(self, address): |
| 702 | + """Test address entity endpoint (obfuscation applies to best_address_tag and actors).""" |
| 703 | + self.assert_endpoint_equal(f"btc/addresses/{address}/entity") |
| 704 | + |
| 705 | + @pytest.mark.migration |
| 706 | + @pytest.mark.parametrize("address", [BTC_ADDRESS, BTC_ADDRESS_PRIVATE_TAGS]) |
| 707 | + def test_tag_summary_obfuscation(self, address): |
| 708 | + """Test tag_summary endpoint with obfuscation. |
| 709 | +
|
| 710 | + This endpoint uses a tag_transformer in the service layer which checks |
| 711 | + should_obfuscate_private_tags(). Without private group headers, |
| 712 | + private tags should be obfuscated. |
| 713 | + """ |
| 714 | + self.assert_endpoint_equal( |
| 715 | + f"btc/addresses/{address}/tag_summary?include_best_cluster_tag=true" |
| 716 | + ) |
| 717 | + |
| 718 | + @pytest.mark.migration |
| 719 | + @pytest.mark.parametrize("address", [BTC_ADDRESS, BTC_ADDRESS_PRIVATE_TAGS]) |
| 720 | + def test_entity_tags_obfuscation(self, address): |
| 721 | + """Test entity tags endpoint (obfuscation applies to private tags). |
| 722 | +
|
| 723 | + Looks up the entity ID from the address first, then compares entity tags. |
| 724 | + """ |
| 725 | + # Get entity ID from address |
| 726 | + data, status, _ = get_response(NEW_SERVER, f"btc/addresses/{address}/entity") |
| 727 | + assert status == 200, f"Failed to get entity for {address}" |
| 728 | + entity_id = data["entity"] |
| 729 | + |
| 730 | + # Compare entity tags between old and new |
| 731 | + self.assert_endpoint_equal(f"btc/entities/{entity_id}/tags") |
| 732 | + |
| 733 | + |
684 | 734 | class TestSearchParameters(MigrationTestBase): |
685 | 735 | """Test search endpoint with various parameter configurations.""" |
686 | 736 |
|
|
0 commit comments