Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion certified_builder/solana_explorer_url.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
def extract_solana_explorer_url(solana_response: dict) -> str:
# alteração: função isolada para extrair a URL do explorer da resposta do serviço
# alteração: extrai a URL do explorer do bloco "blockchain" conforme contrato oficial
explorer_url = solana_response.get("blockchain", {}).get("explorer_url", "")
return explorer_url

Expand Down
27 changes: 22 additions & 5 deletions tests/test_certified_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,15 +84,32 @@ def test_build_certificates(certified_builder, mock_participant, mock_certificat
# comentário: mock do download de imagens e da resposta do serviço Solana para evitar chamada externa
with patch('certified_builder.utils.fetch_file_certificate.fetch_file_certificate', side_effect=[mock_certificate_template, mock_logo]), \
patch('certified_builder.certified_builder.CertificatesOnSolana.register_certificate_on_solana', return_value={
"status": "encontrado",
"explorer_url": "https://explorer.solana.com/tx/abc123?cluster=devnet",
# comentário: mock alinhado ao contrato atual do serviço
"status": "sucesso",
"certificado": {
"event": "evento de teste",
"uuid": "uuid-123",
"name": "user test",
"email": "user@test.com",
"certificate_code": "ABC-123-XYZ",
"time": "2025-10-31 12:05:38"
"uuid": "uuid-123",
"time": "2025-10-31 12:05:38",
"json_canonico": {"fake": "data"},
"hash_sha256": "deadbeef",
"txid_solana": "fake_txid_abc123",
"network": "devnet",
"timestamp": "2025-10-31 12:05:39",
"timestamp_unix": 1730366739
},
"blockchain": {
"rede": "Solana Devnet",
"explorer_url": "https://explorer.solana.com/tx/fake_txid_abc123?cluster=devnet",
"verificacao_url": "http://localhost:8000/certificados/verify/fake_txid_abc123",
"memo_program": "MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr"
},
"validacao": {
"como_validar": "Recrie o JSON canonizado e compare o hash SHA-256",
"json_canonico_string": "{}",
"hash_esperado": "deadbeef",
"comando_validacao": "printf '{}' | shasum -a 256"
}
}), \
patch.object(certified_builder, 'save_certificate') as mock_save:
Expand Down