Commit Graph

156 Commits

Author SHA1 Message Date
Sergi Delgado Segura
dfaec51a3b Updates tests to dissable logging based on 17e6066 2019-10-28 14:49:52 -07:00
Sergi Delgado Segura
f61474216c Fixes and tests updates
Updates tests so they run with the db_manager and fixes some bugs introduced in d7d42c9.
2019-10-28 14:49:40 -07:00
Sergi Delgado Segura
7432eb1373 Improves sim with basic fork logic 2019-10-28 14:38:56 -07:00
Salvatore Ingala
f0143efd14 Move test_sign_appointment after test_add_appointment, as per PR review 2019-10-28 11:11:39 +07:00
Salvatore Ingala
df9a1173a5 Minor refactoring of test_watcher; revert change DEFAULT_PISA_API_SERVER to correct value 2019-10-25 15:03:57 +08:00
Salvatore Ingala
bb090897b4 Test that signature is None if appointment is not added 2019-10-24 12:23:56 +08:00
Salvatore Ingala
a19bfa13ff Separated signing logic of the Watcher in sign_appointment function; added unit test 2019-10-24 12:19:33 +08:00
Salvatore Ingala
e80206c2cd Merge branch 'master' into 13-appointment-signature 2019-10-23 20:51:11 +08:00
Sergi Delgado Segura
52f52f57f8 Apply requested changes
- Adds a PRG based on a hardcoded seed to make the tests reproducible (get_random_value_hex)
- Updates all the tests replacing urandom for get_random_value_hex
- Properly places misplaced bitcoin_cli in bitcoin_sim_tests
- Typos
2019-10-23 12:40:25 +01:00
Salvatore Ingala
cd2f3610f9 Merge branch 'testing' into 13-appointment-signature 2019-10-23 09:19:44 +08:00
Sergi Delgado Segura
af0e9c81b5 Adds some missing tests 2019-10-22 16:38:28 +01:00
Sergi Delgado Segura
9d9d7b1e5b Adds responder unit tests 2019-10-22 15:14:38 +01:00
Sergi Delgado Segura
7a222d43fe Updates test cleaner and removes retry_counter for responder 2019-10-22 15:09:47 +01:00
Sergi Delgado Segura
018faa07d1 Fixes change endianness
Porting change_endianness from Python2 to Python3 introduced a bug.
2019-10-22 14:59:09 +01:00
Salvatore Ingala
1601f0ca15 Renamed constants and default file names for Pisa's private and public keys 2019-10-22 12:13:12 +08:00
Sergi Delgado Segura
94156a67cc Adds generate_blocks 2019-10-21 18:12:05 +01:00
Salvatore Ingala
a73b14bf13 Fix signature verificatio in pisa-cli 2019-10-18 15:40:57 +08:00
Salvatore Ingala
414a4638bd Added signature verification to watcher's add_appointment test 2019-10-18 12:37:06 +08:00
Salvatore Ingala
2881101e36 Fixed missing return value in test 2019-10-18 08:41:44 +08:00
Salvatore Ingala
f4bfd5ef40 Merge branch 'testing' into 13-appointment-signature 2019-10-18 08:32:38 +08:00
Sergi Delgado Segura
6735aac094 Update tests to use bitcoind_sim event-wise
Also clean son unused imports
2019-10-17 19:08:34 +01:00
Sergi Delgado Segura
1643a7b887 Multiple simulator improvements
The simulator has been updated to work with real transaction structures instead of transaction hashes. It now supports:
	- Non-SegWit transaction format
	- Generation of blocks event-wise and time-wise

Some small issues have also been fixed.

With the new approach, the simulator can be used in a broader range of tests. Moreover tests can run faster since they do not have to wait for blocks. Instead, the generation of new blocks can be triggered by the test.
2019-10-17 19:00:15 +01:00
Sergi Delgado Segura
95759793ba Fixes bitcoin_cli
bitcoin_cli as a global variable in the main __init__.py was creating issues related to http.client.CannotSendRequest: Request-sent and connection re-usage. Define a new connection per request.
2019-10-17 17:17:52 +01:00
Salvatore Ingala
db522500c3 Switched to cryptography instead of ecdsa for signatures 2019-10-17 17:02:09 +08:00
Salvatore Ingala
7c1d8b69c7 Changed to_json to to_dict in Appointment and Job; added to_json to Appointment to actually return a string 2019-10-17 09:59:34 +08:00
Sergi Delgado Segura
3e62cb4b70 Parametrize start and end appointment offsets
Also waits an additional  for transactions to be cleaned to be safe
2019-10-16 12:42:50 +01:00
Sergi Delgado Segura
b74df42a2b Runs bitcoin-cli locally 2019-10-14 17:41:09 +01:00
Sergi Delgado Segura
50d892b197 Remove wrong parenthesis 2019-10-14 17:40:49 +01:00
Sergi Delgado Segura
409f8fb5fb Adds Watcher unit tests 2019-10-14 16:58:31 +01:00
Sergi Delgado Segura
5f87705d26 Dissables can_connect_to_bitcoind with a non-running backend
Until a better way of handling the stop of bitcoind the test is dissabled, it created issues with other tests.
2019-10-14 16:57:58 +01:00
Sergi Delgado Segura
d7c89ddc91 Modifies behaviour towards a failed EncryptedBlob decrpytion
The decryption for the `EncryptedBlob` using AES-GCM-128 (the only cipher available atm) raises an `InvalidTag` exception. This was not properly captured by the watcher making it crash. This behavior was already discovered during the `EncryptedBlob` unit testing and left to be fixed in the `Watcher` unit testing.

However, making the EncryptedBlob raise such an exception may not be a good practice, since other ciphers may run into different exceptions. Therefore, the `EncryptedBlob` has been modified to return None upon facing a decryption issue, the `BlockProcessor` will detect that and return a None justice_txm and justice_txid. Upon receiving a None `justice_txid` the `Watcher` will delete the appointment without notifiying the `Responder`.
2019-10-14 16:57:46 +01:00
Sergi Delgado Segura
d43ab76220 Updates conftest fixtures so they do not autorun
The modules that need to run either bitcoind or the api do now reference to the fixture in the first test that needs it. Since the fixtures are definexd session-wise the rest of the modules will have access to them from that point on.
2019-10-14 13:19:54 +01:00
Sergi Delgado Segura
abe359f7d1 Fixes test to work with session fixtures
Test were running fine standalone but failing / having Address reuse issues when running all together. Fixing that.
2019-10-14 13:00:21 +01:00
Sergi Delgado Segura
e5ab943f8c Adds conftest and defines session fixtures 2019-10-14 12:59:22 +01:00
Sergi Delgado Segura
6baa059431 Adds additional unit tests to tools 2019-10-11 20:54:31 +01:00
Sergi Delgado Segura
98c27f6013 Adds basic unit tests for the Carrier
Further testing is required for this one.
2019-10-11 19:51:50 +01:00
Salvatore Ingala
9f25ef8603 Fixes from PR review 2019-10-10 18:22:33 +07:00
Salvatore Ingala
831545ef2c Added simple tests for check_txid_format 2019-10-10 09:59:12 +07:00
Sergi Delgado Segura
db635ef688 Add missing comment 2019-10-09 19:00:08 +01:00
Sergi Delgado Segura
8b62ff9e56 Update some comments/todos/discuss 2019-10-09 17:38:15 +01:00
Sergi Delgado Segura
1de226374d Minot simulator updates 2019-10-09 17:34:44 +01:00
Sergi Delgado Segura
b69ffdc0aa Adds some BlockProcessor unit tests.
The three last methods are missing, since they seem not to belong there (check #36)
2019-10-09 17:34:32 +01:00
Sergi Delgado Segura
c67e41d185 Includes getbestblockhash so it can simulate db loads 2019-10-09 15:58:54 +01:00
Sergi Delgado Segura
e0d0818f6b Removes unused code 2019-10-09 15:32:56 +01:00
Sergi Delgado Segura
ab72c71039 Adds appointment unit test 2019-10-09 15:19:33 +01:00
Sergi Delgado Segura
f59c621cc0 Defines bitcoind fixture session-wise 2019-10-09 14:05:15 +01:00
Sergi Delgado Segura
e7530a53dc Fixes unconsistent test
test_get_all_appointments_responder was failing unconsistently. It was due to how the api fixture was set up.

Fix:
	- Sets up bitcoind and api fixtures to run session-wise (so they are not re-initialized for every test
	- Updates tests accordingly (e.g. reduces the number of MULTIPLE_REQUESTS so it does not cap)
	- Keeps track of all sent appointments so the test_request functionds don't need to create additional ones
2019-10-09 14:01:43 +01:00
Sergi Delgado Segura
fa5f587134 Updates tests to be pytests friedly
pytests already runs all the test_ functions, so there's no need to call them
2019-10-08 18:57:29 +01:00
Sergi Delgado Segura
9a18f759f9 Adds run_bitcoind fixture 2019-10-08 18:56:45 +01:00
Sergi Delgado Segura
e81ccd39a1 Adds API unit tests and modifies bitcoin_sim to be fixture compatible
- Adds unit tests for API
- Updates API to let BlockProcessor deal with block block related JSON-RPC
- Fixes BlockProcessor get_potential_matches return
- Makes bitcoin_sim runnable via function (instead of a main runnable script) to work with pytests fixture
- <3 Fixture
2019-10-08 18:55:27 +01:00