|
5 | 5 | from requests.exceptions import HTTPError
|
6 | 6 |
|
7 | 7 | from node.blockchain.facade import BlockchainFacade
|
8 |
| -from node.blockchain.inner_models import Block |
| 8 | +from node.blockchain.inner_models import Block, BlockConfirmation |
9 | 9 | from node.blockchain.inner_models import Node as InnerNode
|
10 | 10 | from node.blockchain.models import Block as ORMBlock
|
| 11 | +from node.blockchain.models import BlockConfirmation as ORMBlockConfirmation |
11 | 12 | from node.blockchain.models import Node as ORMNode
|
12 | 13 | from node.blockchain.models import PendingBlock
|
13 | 14 | from node.blockchain.tests.factories.block import make_block
|
@@ -114,6 +115,28 @@ def test_send_block_to_address_integration(
|
114 | 115 | PendingBlock.objects.all().delete()
|
115 | 116 |
|
116 | 117 |
|
| 118 | +@pytest.mark.usefixtures('rich_blockchain', 'as_confirmation_validator') |
| 119 | +def test_send_confirmation_to_cv(test_server_address, confirmation_validator_key_pair_2, smart_mocked_node_client): |
| 120 | + assert not ORMBlockConfirmation.objects.exists() |
| 121 | + |
| 122 | + facade = BlockchainFacade.get_instance() |
| 123 | + assert facade.get_next_block_number() >= 4 |
| 124 | + block = facade.get_block_by_number(4) |
| 125 | + |
| 126 | + hash_ = block.make_hash() |
| 127 | + block_confirmation = BlockConfirmation.create( |
| 128 | + block.get_block_number(), hash_, confirmation_validator_key_pair_2.private |
| 129 | + ) |
| 130 | + payload = block_confirmation.json() |
| 131 | + response = smart_mocked_node_client.send_block_confirmation(test_server_address, block_confirmation) |
| 132 | + |
| 133 | + assert response.status_code == 201 |
| 134 | + confirmation_orm = ORMBlockConfirmation.objects.get_or_none(number=block_confirmation.get_number(), hash=hash_) |
| 135 | + assert confirmation_orm |
| 136 | + assert confirmation_orm.signer == confirmation_validator_key_pair_2.public |
| 137 | + assert confirmation_orm.body == payload |
| 138 | + |
| 139 | + |
117 | 140 | @pytest.mark.django_db
|
118 | 141 | @pytest.mark.usefixtures('rich_blockchain')
|
119 | 142 | @pytest.mark.parametrize('block_identifier, block_number', (
|
|
0 commit comments