Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integration tests: transferTx_value, transferTx_from #5802

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

churik
Copy link
Member

@churik churik commented Sep 5, 2024

Added first parametrized tests from checking errors in create_multi_transaction method (note, that I just put a random str to from to show that it is easily expandable)
In future will expand with more values

@churik churik self-assigned this Sep 5, 2024
@status-im-auto
Copy link
Member

status-im-auto commented Sep 5, 2024

Jenkins Builds

Click to see older builds (18)
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ 28cf171 #1 2024-09-05 12:17:26 ~1 min tests 📄log
✔️ 28cf171 #1 2024-09-05 12:18:52 ~2 min tests-rpc 📄log
✔️ 28cf171 #1 2024-09-05 12:20:31 ~4 min linux 📦zip
✔️ 28cf171 #1 2024-09-05 12:21:14 ~5 min ios 📦zip
✔️ 28cf171 #1 2024-09-05 12:21:54 ~5 min android 📦aar
✖️ 0d03417 #2 2024-09-09 16:44:22 ~1 min tests 📄log
✔️ 0d03417 #2 2024-09-09 16:44:47 ~1 min android 📦aar
✔️ 0d03417 #2 2024-09-09 16:45:19 ~2 min linux 📦zip
✖️ 0d03417 #2 2024-09-09 16:45:21 ~2 min tests-rpc 📄log
✖️ 14b8222 #3 2024-09-09 16:50:25 ~53 sec tests 📄log
✔️ 14b8222 #3 2024-09-09 16:51:04 ~1 min android 📦aar
✔️ 14b8222 #3 2024-09-09 16:51:34 ~2 min linux 📦zip
✖️ 14b8222 #3 2024-09-09 16:51:42 ~2 min tests-rpc 📄log
✖️ cc2e9ef #4 2024-09-18 16:02:44 ~1 min tests 📄log
✖️ cc2e9ef #4 2024-09-18 16:03:46 ~2 min tests-rpc 📄log
✔️ cc2e9ef #4 2024-09-18 16:05:09 ~3 min linux 📦zip
✔️ cc2e9ef #4 2024-09-18 16:05:54 ~4 min android 📦aar
✔️ cc2e9ef #4 2024-09-18 16:06:02 ~4 min ios 📦zip
Commit #️⃣ Finished (UTC) Duration Platform Result
✖️ b3bfa4f #5 2024-09-18 16:50:16 ~1 min tests 📄log
✔️ b3bfa4f #5 2024-09-18 16:50:33 ~1 min android 📦aar
✔️ b3bfa4f #5 2024-09-18 16:50:58 ~1 min linux 📦zip
✔️ b3bfa4f #5 2024-09-18 16:51:23 ~2 min tests-rpc 📄log
✔️ b3bfa4f #5 2024-09-18 16:52:06 ~3 min ios 📦zip
✔️ 3a7a623 #6 2024-09-18 16:56:03 ~1 min android 📦aar
✔️ 3a7a623 #6 2024-09-18 16:56:31 ~2 min linux 📦zip
✔️ 3a7a623 #6 2024-09-18 16:56:43 ~2 min tests-rpc 📄log
✔️ 3a7a623 #6 2024-09-18 16:57:50 ~3 min ios 📦zip
✔️ 3a7a623 #6 2024-09-18 17:26:30 ~31 min tests 📄log

@@ -9,16 +9,16 @@ class RpcTestCase:
def setup_method(self):
self.network_id = 31337

def verify_is_valid_json_rpc_response(self, response, _id=None):
def verify_is_valid_json_rpc_response(self, response, _id=None, _error=False):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's create a separate method, verify_is_jscon_rpc_error

@@ -29,6 +29,19 @@ def verify_is_valid_json_rpc_response(self, response, _id=None):
raise AssertionError(f"no id in response {response.json()}")
return response

def validate_error_code_content(self, response, error_code: int, error_content):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would appreciate to keep it as assert error code and assert error content in the test itself, meanwhile https://github.com/status-im/status-go/pull/5802/files#r1745360470 will be called first to ensure that we have error instead of result in response

class TransactionTestCase(RpcTestCase):

def wallet_create_multi_transaction(self):
@staticmethod
def _update_multitx_method(params, updates):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is advanced, on my opinion for better readability would be great to pass each parameter explicitly to wallet_create_multi_transaction

@churik
Copy link
Member Author

churik commented Sep 9, 2024

@antdanchenko
review please one more time, thanks!

raise AssertionError(
f"no required text in message: {actual_error_text} instead of expected: {expected_error_text}"
)
with open(f"{option.base_dir}/schemas/wallet_createMultiTransaction/transferTx_error", "r") as schema:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, didn't notice on first review, we can use https://github.com/status-im/status-go/blob/develop/integration-tests/tests/test_cases.py#L45 here, I will also update other tests

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you elaborate please?

response = self.wallet_create_multi_transaction(**changed_values)
self.verify_is_json_rpc_error(response)
actual_error_code, actual_error_text = response.json()['error']['code'], response.json()['error']['message']
if expected_error_code != actual_error_code:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would prefer to have native asserts, e.g.
assert actual_error_code != expected_error_code, f"got code: {actual_error_code} instead of expected: {expected_error_code}"

as result error message will be

AssertionError: got code: -32000 instead of expected: 20000

also saves some space :)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

raise AssertionError(
f"got code: {actual_error_code} instead of expected: {expected_error_code}"
)
if expected_error_text not in actual_error_text:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@churik churik force-pushed the integration-tests/first-validation-tests branch from 14b8222 to cc2e9ef Compare September 18, 2024 16:01
@churik
Copy link
Member Author

churik commented Sep 18, 2024

@antdanchenko I addressed comments, although I'm not sure why Jenkins can't find the files and why it is trying to find it in another dir, /tests-rpc/:

| =================================== FAILURES ===================================

[2024-09-18T16:03:44.121Z] tests-rpc_1                     | _______________ TestTransactionRpc.test_create_multi_transaction _______________

[2024-09-18T16:03:44.121Z] tests-rpc_1                     | tests/test_wallet_rpc.py:47: in test_create_multi_transaction

[2024-09-18T16:03:44.121Z] tests-rpc_1                     |     with open(f"{option.base_dir}/schemas/wallet_createMultiTransaction/transferTx_positive", "r") as schema:

[2024-09-18T16:03:44.121Z] tests-rpc_1                     | E   FileNotFoundError: [Errno 2] No such file or directory: '/tests-rpc/schemas/wallet_createMultiTransaction/transferTx_positive'

[2024-09-18T16:03:44.121Z] tests-rpc_1                     | _ TestTransactionRpc.test_create_multi_transaction_validation[transferTx_value_not_enough_balance-changed_values0--32000-Insufficient funds for gas] _

[2024-09-18T16:03:44.121Z] tests-rpc_1                     | tests/test_wallet_rpc.py:72: in test_create_multi_transaction_validation

[2024-09-18T16:03:44.121Z] tests-rpc_1                     |     with open(f"{option.base_dir}/schemas/wallet_createMultiTransaction/transferTx_error", "r") as schema:

[2024-09-18T16:03:44.121Z] tests-rpc_1                     | E   FileNotFoundError: [Errno 2] No such file or directory: '/tests-rpc/schemas/wallet_createMultiTransaction/transferTx_error'

[2024-09-18T16:03:44.121Z] tests-rpc_1                     | _ TestTransactionRpc.test_create_multi_transaction_validation[transferTx_from_from_invalid_string-changed_values1--32602-cannot unmarshal hex string without 0x prefix] _

[2024-09-18T16:03:44.121Z] tests-rpc_1                     | tests/test_wallet_rpc.py:72: in test_create_multi_transaction_validation

[2024-09-18T16:03:44.121Z] tests-rpc_1                     |     with open(f"{option.base_dir}/schemas/wallet_createMultiTransaction/transferTx_error", "r") as schema:

[2024-09-18T16:03:44.121Z] tests-rpc_1                     | E   FileNotFoundError: [Errno 2] No such file or directory: '/tests-rpc/schemas/wallet_createMultiTransaction/transferTx_error'

[2024-09-18T16:03:44.121Z] tests-rpc_1                     | =============================== warnings summary ===============================

as they are committed to this branch.

Should I just store them in main dir?

UPDATE: turned out (who would have thought?) that Linux is case-sensitive for paths and Mac is not.
Small step for humanity, big step for me :)

@churik churik force-pushed the integration-tests/first-validation-tests branch from b3bfa4f to 3a7a623 Compare September 18, 2024 16:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants