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

Migrate contract tests to new API based on promises #19208

Merged
merged 1 commit into from
Mar 13, 2024

Conversation

ilmotta
Copy link
Contributor

@ilmotta ilmotta commented Mar 12, 2024

Summary

This PR changes contract test code to use the new API previously implemented for integration tests. Both types of test share similar characteristics and thus, can use the same API.

I have also renamed the utility function h/integration-test to h/async-test because it's a general solution used now for both contract & integration tests.

Steps to test

make test-contract

status: ready

@ilmotta ilmotta self-assigned this Mar 12, 2024
@ilmotta ilmotta force-pushed the ilmotta/rewrite-integration-tests-to-use-new-api branch from a65b43f to d81a616 Compare March 12, 2024 15:25
:on-success action
:on-error on-error}))
(defn call-rpc
[method & args]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could change the signature to become very similar to a synchronous function call because now there's no point in passing on-success and on-error callbacks.

@@ -182,6 +182,29 @@
(restore-fn)
(done))))))))

(defn test-app-initialization
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I extracted these 2 tests here because they are identical for contract & integration tests.

Copy link
Contributor

Choose a reason for hiding this comment

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

🙌

@status-im-auto
Copy link
Member

status-im-auto commented Mar 12, 2024

Jenkins Builds

Click to see older builds (4)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 0b229b9 #3 2024-03-12 15:37:23 ~5 min tests 📄log
✔️ 0b229b9 #3 2024-03-12 15:39:10 ~7 min android-e2e 🤖apk 📲
✔️ 0b229b9 #3 2024-03-12 15:39:16 ~7 min android 🤖apk 📲
✔️ 0b229b9 #3 2024-03-12 15:42:43 ~10 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 2ceece5 #4 2024-03-12 15:57:04 ~6 min tests 📄log
✔️ 2ceece5 #4 2024-03-12 15:58:17 ~7 min ios 📱ipa 📲
✔️ 2ceece5 #4 2024-03-12 15:59:16 ~8 min android-e2e 🤖apk 📲
✔️ 2ceece5 #4 2024-03-12 15:59:22 ~8 min android 🤖apk 📲
✔️ 5cbfbda #5 2024-03-13 12:30:27 ~5 min tests 📄log
✔️ 5cbfbda #5 2024-03-13 12:32:11 ~7 min android-e2e 🤖apk 📲
✔️ 5cbfbda #5 2024-03-13 12:32:17 ~7 min android 🤖apk 📲
✔️ 5cbfbda #5 2024-03-13 12:32:34 ~7 min ios 📱ipa 📲

@@ -141,7 +140,7 @@
(-> (wait-for [:messenger-started])
(.then #(assert-messenger-started))))))

(defn integration-test
(defn test-async
Copy link
Contributor

Choose a reason for hiding this comment

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

👍

_ (contract-utils/call-rpc
:accounts_saveAccount
(data-store/<-account (merge default-account {:emoji test-emoji})))
accounts (contract-utils/call-rpc :accounts_getAccounts)]
Copy link
Contributor

Choose a reason for hiding this comment

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

hmm, I don't like the idea of making the rpc calls keywords if we're using strings in the application call instead. Should be similar imo. i.e: (contract-utils/call-rpc "accounts_getAccounts")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I intend to change all usages of RPC calls to keywords @J-Son89, then it will be the opposite, it would be weird to use strings. Then have a function schema to reinforce that too. There's no reason to use strings because the value is immediately transformed to a string anyway to make the real RPC call. Feels more Clojurey to use keywords for unique values in the repo.

I've been using a keyword so far in the repo already. But I will change for this PR and do the changes in one go, no problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done 2ceece5

Copy link
Contributor

Choose a reason for hiding this comment

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

All good to leave as is if you're going to change them anyway 👍

Copy link
Contributor

Choose a reason for hiding this comment

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

too quick on the draw :) - I'm fine with changing them to keywords provided the intention is to do the same for the other uses in the app 👌

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noo really you're correct. This kind of change should be consistently applied in the repo. I put the cart before the horse 🤷🏼

Copy link
Contributor

@mohsen-ghafouri mohsen-ghafouri left a comment

Choose a reason for hiding this comment

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

Awesome, Contract tests are far better now

@ilmotta ilmotta force-pushed the ilmotta/rewrite-integration-tests-to-use-new-api branch from 2ceece5 to 5cbfbda Compare March 13, 2024 12:24
@ilmotta ilmotta merged commit 4fa9a27 into develop Mar 13, 2024
6 checks passed
@ilmotta ilmotta deleted the ilmotta/rewrite-integration-tests-to-use-new-api branch March 13, 2024 12:38
@FFFra
Copy link
Contributor

FFFra commented Mar 13, 2024

Amazing! So elegant!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants