Skip to content

Commit 65b1b48

Browse files
Align to service contract: use blockchain.explorer_url; update test mock to match provided JSON; keep authenticity_verification_url from explorer_url
1 parent aa4d171 commit 65b1b48

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

certified_builder/solana_explorer_url.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
def extract_solana_explorer_url(solana_response: dict) -> str:
2-
# alteração: função isolada para extrair a URL do explorer da resposta do serviço
2+
# alteração: extrai a URL do explorer do bloco "blockchain" conforme contrato oficial
33
explorer_url = solana_response.get("blockchain", {}).get("explorer_url", "")
44
return explorer_url
55

tests/test_certified_builder.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,15 +84,32 @@ def test_build_certificates(certified_builder, mock_participant, mock_certificat
8484
# comentário: mock do download de imagens e da resposta do serviço Solana para evitar chamada externa
8585
with patch('certified_builder.utils.fetch_file_certificate.fetch_file_certificate', side_effect=[mock_certificate_template, mock_logo]), \
8686
patch('certified_builder.certified_builder.CertificatesOnSolana.register_certificate_on_solana', return_value={
87-
"status": "encontrado",
88-
"explorer_url": "https://explorer.solana.com/tx/abc123?cluster=devnet",
87+
# comentário: mock alinhado ao contrato atual do serviço
88+
"status": "sucesso",
8989
"certificado": {
9090
"event": "evento de teste",
91-
"uuid": "uuid-123",
9291
"name": "user test",
9392
"email": "[email protected]",
94-
"certificate_code": "ABC-123-XYZ",
95-
"time": "2025-10-31 12:05:38"
93+
"uuid": "uuid-123",
94+
"time": "2025-10-31 12:05:38",
95+
"json_canonico": {"fake": "data"},
96+
"hash_sha256": "deadbeef",
97+
"txid_solana": "fake_txid_abc123",
98+
"network": "devnet",
99+
"timestamp": "2025-10-31 12:05:39",
100+
"timestamp_unix": 1730366739
101+
},
102+
"blockchain": {
103+
"rede": "Solana Devnet",
104+
"explorer_url": "https://explorer.solana.com/tx/fake_txid_abc123?cluster=devnet",
105+
"verificacao_url": "http://localhost:8000/certificados/verify/fake_txid_abc123",
106+
"memo_program": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"
107+
},
108+
"validacao": {
109+
"como_validar": "Recrie o JSON canonizado e compare o hash SHA-256",
110+
"json_canonico_string": "{}",
111+
"hash_esperado": "deadbeef",
112+
"comando_validacao": "printf '{}' | shasum -a 256"
96113
}
97114
}), \
98115
patch.object(certified_builder, 'save_certificate') as mock_save:

0 commit comments

Comments
 (0)