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

[#17896] Raw balances using big number #17920

Merged
merged 7 commits into from
Dec 8, 2023

Conversation

ulisesmac
Copy link
Contributor

fixes #17896

Summary

The previous implementation was using js/parseInt to process the raw-balances, this PR stores them as big-number instances in re-frame.

This had some problems, if we had 100 or more units of a token, the calculations resulted in a 0, now using bignumbers that issue has been fixed.

Changes

  • Makes utils.money/add able to receive nil values
  • Store raw-balances as big number instances
  • Update the balance calculation related functions to use big numbers, also now they are using existing utils.money functions.

Testing notes

The app should work as expected. Previously, if we had 100 or more token units, the result listed in the account cards in the wallet home page was $0.00. Now it shows the proper value.

Platforms

  • Android
  • iOS

Areas that maybe impacted

Wallet home page in the account cards.

Steps to test

  • Open Status
  • Navigate to our new wallet implementation
  • Wait for it to load, the account cards should properly display the account balance if we have more than 100 token units in total for an account.

status: ready

Comment on lines 26 to 32
(defn- calculate-raw-balance
[raw-balance decimals]
(if-let [n (utils.number/parse-int raw-balance nil)]
(/ n (Math/pow 10 (utils.number/parse-int decimals)))
0))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

utils.money/token->unit is able to do the same and works with big numbers, so now it is being used

Comment on lines -43 to -52
(* (total-token-value-in-all-chains token)
(-> token :market-values-per-currency :usd :price))))
Copy link
Contributor Author

@ulisesmac ulisesmac Nov 15, 2023

Choose a reason for hiding this comment

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

utils.money/crypto->fiat does the same but supports bignumbers, so now it's being used

@@ -1,6 +1,7 @@
(ns status-im2.contexts.wallet.common.utils
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Besides using functions in utils.money, this file also had a refactor

Comment on lines -105 to +124
(defn- fix-chain-id-keys
(defn- fix-balances-per-chain
[token]
(update token :balances-per-chain update-keys (comp utils.number/parse-int name)))
(-> token
(update :balances-per-chain update-vals #(update % :raw-balance money/bignumber))
(update :balances-per-chain update-keys (comp utils.number/parse-int name))))

(rf/reg-event-fx
:wallet/store-wallet-token
(fn [{:keys [db]} [raw-tokens-data]]
(let [tokens (-> raw-tokens-data
(update-keys name)
(update-vals #(cske/transform-keys csk/->kebab-case %))
(update-vals #(mapv fix-chain-id-keys %)))
(update-vals #(mapv fix-balances-per-chain %)))
Copy link
Contributor Author

@ulisesmac ulisesmac Nov 15, 2023

Choose a reason for hiding this comment

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

Here, when the token raw-balance is received it is being stored as bignumber instances

Comment on lines +89 to +94
(let [result (rf/sub [sub-name])
balance-0x1 (money/bignumber 3250)
balance-0x2 (money/bignumber 2100)]

(is (= {"0x1" 3250 "0x2" 2100}
(rf/sub [sub-name])))))
(is (money/equal-to balance-0x1 (get result "0x1")))
(is (money/equal-to balance-0x2 (get result "0x2"))))))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This file is now testing against bignumber instances. the function utils.money/equal-to is needed to check equality between them.

@status-im-auto
Copy link
Member

status-im-auto commented Nov 15, 2023

Jenkins Builds

Click to see older builds (20)
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 930bc66 #1 2023-11-15 22:41:05 ~9 min android-e2e 🤖apk 📲
✔️ 930bc66 #1 2023-11-15 22:41:22 ~10 min android 🤖apk 📲
✔️ 930bc66 #1 2023-11-15 22:41:52 ~10 min tests 📄log
✔️ 930bc66 #1 2023-11-15 22:44:32 ~13 min ios 📱ipa 📲
✔️ 4b5cb07 #2 2023-11-24 19:48:26 ~6 min ios 📱ipa 📲
✔️ 4b5cb07 #2 2023-11-24 19:51:16 ~8 min android-e2e 🤖apk 📲
✔️ 4b5cb07 #2 2023-11-24 19:54:24 ~12 min android 🤖apk 📲
✔️ 4b5cb07 #2 2023-11-24 19:55:17 ~12 min tests 📄log
✔️ 2fb8a5c #3 2023-12-04 23:17:23 ~7 min android 🤖apk 📲
✔️ 2fb8a5c #3 2023-12-04 23:17:24 ~7 min ios 📱ipa 📲
✔️ 2fb8a5c #3 2023-12-04 23:18:31 ~8 min android-e2e 🤖apk 📲
✔️ 2fb8a5c #3 2023-12-04 23:21:04 ~11 min tests 📄log
✔️ 866f5d1 #4 2023-12-08 00:05:02 ~10 min android 🤖apk 📲
✔️ 866f5d1 #4 2023-12-08 00:05:17 ~10 min android-e2e 🤖apk 📲
✔️ 866f5d1 #4 2023-12-08 00:06:19 ~11 min tests 📄log
✔️ 866f5d1 #4 2023-12-08 00:07:23 ~12 min ios 📱ipa 📲
✔️ 556036f #5 2023-12-08 01:43:19 ~10 min android 🤖apk 📲
✔️ 556036f #5 2023-12-08 01:43:26 ~10 min android-e2e 🤖apk 📲
✔️ 556036f #5 2023-12-08 01:44:31 ~11 min tests 📄log
✔️ 556036f #5 2023-12-08 01:46:16 ~13 min ios 📱ipa 📲
Commit #️⃣ Finished (UTC) Duration Platform Result
✔️ 8b0d40b #6 2023-12-08 02:58:19 ~6 min android-e2e 🤖apk 📲
✔️ 8b0d40b #6 2023-12-08 02:58:28 ~6 min android 🤖apk 📲
✔️ 8b0d40b #6 2023-12-08 03:03:09 ~11 min tests 📄log
✔️ 8b0d40b #6 2023-12-08 03:04:59 ~13 min ios 📱ipa 📲
✔️ 339e235 #7 2023-12-08 19:30:58 ~6 min ios 📱ipa 📲
✔️ 339e235 #7 2023-12-08 19:35:08 ~10 min android-e2e 🤖apk 📲
✔️ 339e235 #7 2023-12-08 19:35:15 ~10 min android 🤖apk 📲
✔️ 339e235 #7 2023-12-08 19:36:38 ~11 min tests 📄log

Comment on lines -207 to +215
(defn add
(defn- add*
[bn1 n2]
(.add ^js bn1 n2))

(def add
"Add with defaults, this version is able to receive `nil` and takes them as 0."
(fnil add* (bignumber 0) (bignumber 0)))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added a more flexible version of add.
I'd really like to get your feedback about this change.

Comparison between this version and the previous one:

(reduce money/add [])
;; Before:
;; Exception about null has no .add method
;; Now:
;; => (bignumber 0)

(reduce money/add [(money/bignumber 10)])
;; Before:
;; => (bignumber 10)
;; Now:
;; => (bignumber 10)

(reduce money/add [(money/bignumber 10) (money/bignumber 20) (money/bignumber 30)])
;; Before:
;; => (bignumber 60)
;; Now:
;; => (bignumber 60)

(money/add (money/bignumber 10))
;; Before:
;; Exception about no method plus() found in null
;; Now:
;; => (bignumber 10)

(money/add (money/bignumber 10) nil)
;; Before:
;; Exception about no method plus() found in null
;; Now:
;; => (bignumber 10)

(money/add nil (money/bignumber 10))
;; Before:
;; Exception about null has no .add method
;; Now:
;; => (bignumber 10)

(money/add nil nil)
;; Before:
;; Exception about null has no .add method
;; Now:
;; => (bignumber 0)

Copy link
Member

Choose a reason for hiding this comment

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

This seems like a perfect solution to me for dealing with nil values as we should not allow the app to crash on nil values.

Thanks for comparsion @ulisesmac!

Copy link
Member

@smohamedjavid smohamedjavid left a comment

Choose a reason for hiding this comment

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

🚀

Comment on lines +30 to +37
(map (comp :raw-balance val))
(reduce money/add)))
Copy link
Member

Choose a reason for hiding this comment

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

❤️

total-units-in-all-chains (-> balances-per-chain
(total-raw-balance-in-all-chains)
(money/token->unit decimals))]
(money/crypto->fiat total-units-in-all-chains usd-price)))
Copy link
Member

Choose a reason for hiding this comment

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

Love the naming of the methods. Clean and neat. 🚀

Comment on lines -207 to +215
(defn add
(defn- add*
[bn1 n2]
(.add ^js bn1 n2))

(def add
"Add with defaults, this version is able to receive `nil` and takes them as 0."
(fnil add* (bignumber 0) (bignumber 0)))

Copy link
Member

Choose a reason for hiding this comment

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

This seems like a perfect solution to me for dealing with nil values as we should not allow the app to crash on nil values.

Thanks for comparsion @ulisesmac!

@churik
Copy link
Member

churik commented Nov 24, 2023

@ulisesmac can you please resolve conflicts and update it?
thank you!

@ulisesmac
Copy link
Contributor Author

@ulisesmac can you please resolve conflicts and update it? thank you!

@churik No problem! done!

@churik
Copy link
Member

churik commented Dec 4, 2023

@ulisesmac
ok, one more time please and I'll prioritize your PR just right after the conflict resolve, apologies for delay:)

@ulisesmac ulisesmac force-pushed the 17896-raw-balances-big-number branch from 4b5cb07 to 2fb8a5c Compare December 4, 2023 23:09
Comment on lines -74 to +78
(let [tokens (map (fn [token]
(assoc token
:networks (utils/network-list token networks)
:total-balance (utils/total-token-value-in-all-chains token)
:total-balance-fiat (utils/calculate-balance token)))
(:tokens account))

sorted-tokens
(sort-by :name compare tokens)
filtered-tokens
(filter #(or (string/starts-with? (string/lower-case (:name %))
(string/lower-case query))
(string/starts-with? (string/lower-case (:symbol %))
(string/lower-case query)))
sorted-tokens)]
(let [tokens (map (fn [token]
(assoc token
:networks (utils/network-list token networks)
:total-balance (utils/total-token-units-in-all-chains token)
:total-balance-fiat 0))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@churik
For the wallet flow:

  1. Select an account
  2. Select Send button
  3. Write an address (0x123..)
  4. Select an address

the fiat balance is being returned as zero as part of this PR.

The reason is that the value has a bug in develop, and its calculation was perfomed using code that I erased in this PR, so instead of fixing that bug here, I created an issue:

to properly address it. And set it as zero for this PR.
cc @briansztamfater

@churik churik self-assigned this Dec 5, 2023
@churik
Copy link
Member

churik commented Dec 5, 2023

@ulisesmac as you mentioned that balance is 0 now (I checked it) I do not think that it is testable right now, is it true?
For this https://etherscan.io/address/0xcf2272205cc0cf96Cfbb9Dd740BD681D1E86901E
I see
IMAGE 2023-12-05 13:16:47

I'm blocking PR for testing until the issue is resolved, let me know when it is ready, thanks!

@churik churik added the blocked label Dec 5, 2023
@churik
Copy link
Member

churik commented Dec 6, 2023

@ulisesmac
I have 667 SNT tokens and 794 RARE in my account https://etherscan.io/address/0xcf2272205cc0cf96Cfbb9Dd740BD681D1E86901E
On the account card the balance is loading correctly, on PR it is 0 everywhere.

Nightly:

FILE.2023-12-06.17.49.05.mp4

PR:

IMG_1884.MP4

@status-im-auto
Copy link
Member

62% of end-end tests have passed

Total executed tests: 48
Failed tests: 14
Expected to fail tests: 4
Passed tests: 30
Not executed tests: 1
IDs of not executed tests: 704615 
IDs of failed tests: 703194,702859,703133,702840,703086,702894,702869,703202,702839,702838,702844,702846,702843,702841 
IDs of expected to fail tests: 702732,703503,702731,702808 

Not executed tests (1)

Click to expand
  • Rerun not executed tests
  • Failed tests (14)

    Click to expand
  • Rerun failed tests

  • Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_reactions, id: 703202

    Device 2: Looking for a message by text: This is a test message to check some reactions.
    Device 2: Find `ChatElementByText` by `xpath`: `//*[starts-with(@text,'This is a test message to check some reactions.')]/ancestor::android.view.ViewGroup[@content-desc='chat-item']`

    critical/chats/test_group_chat.py:108: in test_group_chat_reactions
        self.chats[1].set_reaction(message=message, emoji="thumbs-up")
    ../views/chat_view.py:1072: in set_reaction
        self.chat_element_by_text(message).long_press_until_element_is_shown(element)
    ../views/base_element.py:317: in long_press_until_element_is_shown
        element = self.find_element()
    ../views/chat_view.py:134: in find_element
        self.wait_for_visibility_of_element(20)
    ../views/base_element.py:139: in wait_for_visibility_of_element
        raise TimeoutException(
     Device 2: ChatElementByText by xpath:`//*[starts-with(@text,'This is a test message to check some reactions.')]/ancestor::android.view.ViewGroup[@content-desc='chat-item']` is not found on the screen after wait_for_visibility_of_element
    



    Device sessions

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_several_images_send_reply, id: 703194

    Test setup failed: critical/chats/test_public_chat_browsing.py:320: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:427: in join_community
        self.join_button.click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `show-request-to-join-screen-button` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    2. test_community_one_image_send_reply, id: 702859

    Test setup failed: critical/chats/test_public_chat_browsing.py:320: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:427: in join_community
        self.join_button.click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `show-request-to-join-screen-button` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    3. test_community_emoji_send_copy_paste_reply, id: 702840

    Test setup failed: critical/chats/test_public_chat_browsing.py:320: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:427: in join_community
        self.join_button.click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `show-request-to-join-screen-button` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    4. test_community_mark_all_messages_as_read, id: 703086

    Test setup failed: critical/chats/test_public_chat_browsing.py:320: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:427: in join_community
        self.join_button.click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `show-request-to-join-screen-button` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    5. test_community_contact_block_unblock_offline, id: 702894

    Test setup failed: critical/chats/test_public_chat_browsing.py:320: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:427: in join_community
        self.join_button.click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `show-request-to-join-screen-button` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception 
    

    [[Message can be missed after unblock: https://github.com//issues/16873]]

    6. test_community_message_delete, id: 702839

    Test setup failed: critical/chats/test_public_chat_browsing.py:320: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:427: in join_community
        self.join_button.click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `show-request-to-join-screen-button` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    7. test_community_message_send_check_timestamps_sender_username, id: 702838

    Device 2: Joining community
    Device 2: Find Button by accessibility id: show-request-to-join-screen-button

    Test setup failed: critical/chats/test_public_chat_browsing.py:320: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:427: in join_community
        self.join_button.click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `show-request-to-join-screen-button` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    Device sessions

    8. test_community_links_with_previews_github_youtube_twitter_gif_send_enable, id: 702844

    Test setup failed: critical/chats/test_public_chat_browsing.py:320: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:427: in join_community
        self.join_button.click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `show-request-to-join-screen-button` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    9. test_community_message_edit, id: 702843

    Test setup failed: critical/chats/test_public_chat_browsing.py:320: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:427: in join_community
        self.join_button.click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `show-request-to-join-screen-button` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    10. test_community_unread_messages_badge, id: 702841

    Test setup failed: critical/chats/test_public_chat_browsing.py:320: in prepare_devices
        self.community_2.join_community()
    ../views/chat_view.py:427: in join_community
        self.join_button.click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    ../views/base_element.py:79: in find_element
        raise NoSuchElementException(
     Device 2: Button by accessibility id: `show-request-to-join-screen-button` is not found on the screen; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#no-such-element-exception
    



    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133

    Device 1: Find Button by accessibility id: show-profiles
    Device 1: Tap on found: Button

    critical/chats/test_public_chat_browsing.py:273: in test_restore_multiaccount_with_waku_backup_remove_switch
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Incorrect contacts number restored: 3 instead of 2
    



    Device sessions

    2. test_community_undo_delete_message, id: 702869

    Device 1: Tap on found: Button
    Device 1: Find Button by xpath: //*[@text="Undo"]

    critical/chats/test_public_chat_browsing.py:110: in test_community_undo_delete_message
        self.channel.element_by_text("Undo").click()
    ../views/base_element.py:90: in click
        self.find_element().click()
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webelement.py:94: in click
        self._execute(Command.CLICK_ELEMENT)
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webelement.py:395: in _execute
        return self._parent.execute(command, params)
    /home/jenkins/.local/lib/python3.10/site-packages/selenium/webdriver/remote/webdriver.py:345: in execute
        self.error_handler.check_response(response)
    /home/jenkins/.local/lib/python3.10/site-packages/appium/webdriver/errorhandler.py:122: in check_response
        raise exception_class(msg=message, stacktrace=format_stacktrace(stacktrace))
     The element 'By.xpath: //*[@text="Undo"]' does not exist in DOM anymore; For documentation on this error, please visit: https://www.selenium.dev/documentation/webdriver/troubleshooting/errors#stale-element-reference-exception
    E   Stacktrace:
    E   io.appium.uiautomator2.common.exceptions.StaleElementReferenceException: The element 'By.xpath: //*[@text="Undo"]' does not exist in DOM anymore
    E   	at io.appium.uiautomator2.model.ElementsCache.restore(ElementsCache.java:117)
    E   	at io.appium.uiautomator2.model.ElementsCache.get(ElementsCache.java:153)
    E   	at io.appium.uiautomator2.handler.Click.safeHandle(Click.java:36)
    E   	at io.appium.uiautomator2.handler.request.SafeRequestHandler.handle(SafeRequestHandler.java:59)
    E   	at io.appium.uiautomator2.server.AppiumServlet.handleRequest(AppiumServlet.java:277)
    E   	at io.appium.uiautomator2.server.AppiumServlet.handleHttpRequest(AppiumServlet.java:271)
    E   	at io.appium.uiautomator2.http.ServerHandler.channelRead(ServerHandler.java:68)
    E   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
    E   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
    E   	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
    E   	at io.netty.handler.codec.MessageToMessageDecoder.channelRead(MessageToMessageDecoder.java:102)
    E   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
    E   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
    E   	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
    E   	at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.fireChannelRead(CombinedChannelDuplexHandler.java:435)
    E   	at io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:293)
    E   	at io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:267)
    E   	at io.netty.channel.CombinedChannelDuplexHandler.channelRead(CombinedChannelDuplexHandler.java:250)
    E   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
    E   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
    E   	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
    E   	at io.netty.handler.timeout.IdleStateHandler.channelRead(IdleStateHandler.java:266)
    E   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
    E   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
    E   	at io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:345)
    E   	at io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1294)
    E   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:366)
    E   	at io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:352)
    E   	at io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:911)
    E   	at io.netty.channel.nio.AbstractNioByteChannel$NioByteUnsafe.read(AbstractNioByteChannel.java:131)
    E   	at io.netty.channel.nio.NioEventLoop.processSelectedKey(NioEventLoop.java:611)
    E   	at io.netty.channel.nio.NioEventLoop.processSelectedKeysOptimized(NioEventLoop.java:552)
    E   	at io.netty.channel.nio.NioEventLoop.processSelectedKeys(NioEventLoop.java:466)
    E   	at io.netty.channel.nio.NioEventLoop.run(NioEventLoop.java:438)
    E   	at io.netty.util.concurrent.SingleThreadEventExecutor$2.run(SingleThreadEventExecutor.java:140)
    E   	at io.netty.util.concurrent.DefaultThreadFactory$DefaultRunnableDecorator.run(DefaultThreadFactory.java:144)
    E   	at java.lang.Thread.run(Thread.java:919)
    



    Device sessions

    3. test_community_navigate_to_channel_when_relaunch, id: 702846

    ## Signed in successfully!
    Device 1: Looking for a message by text: some_text

    critical/chats/test_public_chat_browsing.py:83: in test_community_navigate_to_channel_when_relaunch
        self.drivers[0].fail("Not navigated to channel view after reopening app")
    base_test_case.py:179: in fail
        pytest.fail('Device %s: %s' % (self.number, text))
     Device 1: Not navigated to channel view after reopening app
    



    Device sessions

    Expected to fail tests (4)

    Click to expand

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_pin_messages, id: 702731

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Pin feature is in development]]

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_pin_messages, id: 702732

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Pin feature is in development]]

    2. test_group_chat_offline_pn, id: 702808

    Device 3: Looking for a message by text: message from old member
    Device 3: Looking for a message by text: message from new member

    critical/chats/test_group_chat.py:323: in test_group_chat_offline_pn
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Messages PN was not fetched from offline 
    

    [[Data delivery issue]]

    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_community_discovery, id: 703503

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Curated communities not loading, https://github.com//issues/17852]]

    Passed tests (30)

    Click to expand

    Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:

    1. test_1_1_chat_delete_via_long_press_relogin, id: 702784
    Device sessions

    2. test_1_1_chat_is_shown_message_sent_delivered_from_offline, id: 702783
    Device sessions

    3. test_1_1_chat_mute_chat, id: 703496
    Device sessions

    Class TestActivityMultipleDevicePRTwo:

    1. test_activity_center_mentions, id: 702957
    Device sessions

    2. test_activity_center_admin_notification_accept_swipe, id: 702958
    Device sessions

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_mute_chat, id: 703495
    Device sessions

    2. test_group_chat_send_image_save_and_share, id: 703297
    Device sessions

    3. test_group_chat_join_send_text_messages_push, id: 702807
    Device sessions

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_markdown_support, id: 702809
    Device sessions

    2. test_community_hashtag_links_to_community_channels, id: 702948
    Device sessions

    3. test_community_mentions_push_notification, id: 702786
    Device sessions

    4. test_community_leave, id: 702845
    Device sessions

    5. test_community_join_when_node_owner_offline, id: 703629
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_emoji_send_reply_and_open_link, id: 702782
    Device sessions

    2. test_1_1_chat_text_message_delete_push_disappear, id: 702733
    Device sessions

    3. test_1_1_chat_push_emoji, id: 702813
    Device sessions

    4. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    5. test_1_1_chat_edit_message, id: 702855
    Device sessions

    6. test_1_1_chat_send_image_save_and_share, id: 703391
    Device sessions

    7. test_1_1_chat_message_reaction, id: 702730
    Device sessions

    Class TestDeepLinksOneDevice:

    1. test_links_open_universal_links_from_chat, id: 704613
    Device sessions

    2. test_links_open_universal_links_from_other_apps, id: 704614
    Device sessions

    3. test_links_deep_links, id: 702775
    Device sessions

    Class TestActivityCenterContactRequestMultipleDevicePR:

    1. test_add_contact_field_validation, id: 702777
    Device sessions

    2. test_activity_center_contact_request_accept_swipe_mark_all_as_read, id: 702851
    Device sessions

    3. test_activity_center_contact_request_decline, id: 702850
    Device sessions

    Class TestActivityMultipleDevicePR:

    1. test_navigation_jump_to, id: 702936
    Device sessions

    2. test_activity_center_reply_read_unread_delete_filter_swipe, id: 702947
    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    2. test_community_mute_community_and_channel, id: 703382
    Device sessions

    @ulisesmac
    Copy link
    Contributor Author

    @ulisesmac I have 667 SNT tokens and 794 RARE in my account https://etherscan.io/address/0xcf2272205cc0cf96Cfbb9Dd740BD681D1E86901E On the account card the balance is loading correctly, on PR it is 0 everywhere.

    Nightly:
    FILE.2023-12-06.17.49.05.mp4

    PR:
    IMG_1884.MP4

    Thanks @churik Will check it and fix it 👍

    @ulisesmac ulisesmac force-pushed the 17896-raw-balances-big-number branch from 2fb8a5c to 866f5d1 Compare December 7, 2023 23:54
    @ulisesmac ulisesmac force-pushed the 17896-raw-balances-big-number branch from 556036f to 8b0d40b Compare December 8, 2023 02:51
    @ulisesmac
    Copy link
    Contributor Author

    @churik Sorry for the delay.

    We had a problem showing the balances, but now it's fixed!

    About what I said related to balances:

    1. It only affects to accounts card (the row of cards in wallet home screen), if you press the card, another screen will appear, that's not covered in this PR.
    2. It was wrong that 100 token units show the error, they should be at least 1000 units, so if you have more than 1000 of a token, it'll be calculated wrongly and will affect the total balance in develop. In this branch the total balance will be correct.

    To test it, we have two options:

    1. An account with a single token that has more than 1000 units, the total balance will be wrong in develop, in this branch it'll be the correct amout.
    2. An account with many tokens and more than 1000 units of certain tokens. The balance in develop will be less than the balance in this branch since in develop, those 1000 units will be taken as zero or one sometimes.

    A random address I found in etherscan:
    https://etherscan.io/address/0x0802dd2edd3f9fad39a9173b4595be819f201d61
    the total balance in develop:
    image

    is less than the total balance in this branch:
    image

    since, as I said, the tokens being more than 1000 are not calculated correctly. This is just a small example to show the difference in calculations.

    @churik
    Copy link
    Member

    churik commented Dec 8, 2023

    Another account to test: https://etherscan.io/address/0x7bdf634f898ad124a9adb7a1aff95a95aa864cbb

    Just keeping here for the history, that only total fiat amount on wallet card on Home > Wallet is fixed, inside the account the values for tokens are still wrong.
    photo_2023-12-08 13 17 45 jpeg 2023-12-08 13-18-04

    @status-im-auto
    Copy link
    Member

    78% of end-end tests have passed

    Total executed tests: 49
    Failed tests: 3
    Expected to fail tests: 8
    Passed tests: 38
    
    IDs of failed tests: 702733,703629,703133 
    
    IDs of expected to fail tests: 702894,702731,702808,702948,702846,702783,702732,703503 
    

    Failed tests (3)

    Click to expand
  • Rerun failed tests

  • Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_text_message_delete_push_disappear, id: 702733

    Device 1: Getting PN by 'DELETE ME'
    Device 2: Could not reach home view by pressing system back button

    critical/chats/test_1_1_public_chats.py:516: in test_1_1_chat_text_message_delete_push_disappear
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Deleted message is shown in chat view for 1-1 chat
    E    Deleted message is shown in chat view for 1-1 chat
    



    Device sessions

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_join_when_node_owner_offline, id: 703629

    Device 2: Tap on found: Button
    Device 2: Looking for community: 'open community'

    critical/chats/test_public_chat_browsing.py:1146: in test_community_join_when_node_owner_offline
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Joined status is not displayed
    E    open community is not listed inside Joined communities tab
    



    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_restore_multiaccount_with_waku_backup_remove_switch, id: 703133

    Device 1: Find Button by accessibility id: show-profiles
    Device 1: Tap on found: Button

    critical/chats/test_public_chat_browsing.py:275: in test_restore_multiaccount_with_waku_backup_remove_switch
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     zQ3...pJN5P was not restored as a contact from waku backup!
    



    Device sessions

    Expected to fail tests (8)

    Click to expand

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_hashtag_links_to_community_channels, id: 702948

    Device 2: Find Text by xpath: //android.view.ViewGroup[@content-desc='chat-item']//android.widget.TextView[contains(@text,'#cats')]
    Device 2: Looking for a message by text: it is just a message text

    critical/chats/test_public_chat_browsing.py:1079: in test_community_hashtag_links_to_community_channels
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Receiver was not navigated to the cats channel
    E    Sender was not navigated to the cats channel 
    

    [[Can't navigate to a channel by hashtag link, https://github.com//issues/18095]]

    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_pin_messages, id: 702731

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Pin feature is in development]]

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_contact_block_unblock_offline, id: 702894

    Device 1: Find ProfileSendMessageButton by accessibility id: Chat-item-button
    Device 1: Sending message 'piy'

    critical/chats/test_public_chat_browsing.py:742: in test_community_contact_block_unblock_offline
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Chat with unblocked user was not enabled after 1 minute 
    

    [[Message can be missed after unblock: https://github.com//issues/16873]]

    Device sessions

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_offline_pn, id: 702808

    Device 3: Looking for a message by text: message from old member
    Device 3: Looking for a message by text: message from new member

    critical/chats/test_group_chat.py:323: in test_group_chat_offline_pn
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Messages PN was not fetched from offline 
    

    [[Data delivery issue]]

    Device sessions

    2. test_group_chat_pin_messages, id: 702732

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Pin feature is in development]]

    Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:

    1. test_1_1_chat_is_shown_message_sent_delivered_from_offline, id: 702783

    Device 2: Find Text by xpath: //*[starts-with(@text,'test message')]/ancestor::android.view.ViewGroup[@content-desc='chat-item']//*[@content-desc='message-status']/android.widget.TextView
    Device 2: Text is Sent

    critical/chats/test_1_1_public_chats.py:620: in test_1_1_chat_is_shown_message_sent_delivered_from_offline
        self.errors.verify_no_errors()
    base_test_case.py:191: in verify_no_errors
        pytest.fail('\n '.join([self.errors.pop(0) for _ in range(len(self.errors))]))
     Message status was not changed to Delivered, it's Sent after back up online! 
    

    [[Data delivery issue]]

    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_community_navigate_to_channel_when_relaunch, id: 702846

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Issue #18075]]

    2. test_community_discovery, id: 703503

    Test is not run, e2e blocker  
    

    [[reason: [NOTRUN] Curated communities not loading, https://github.com//issues/17852]]

    Passed tests (38)

    Click to expand

    Class TestCommunityMultipleDeviceMergedTwo:

    1. test_community_leave, id: 702845
    Device sessions

    2. test_community_mentions_push_notification, id: 702786
    Device sessions

    3. test_community_markdown_support, id: 702809
    Device sessions

    Class TestDeepLinksOneDevice:

    1. test_links_deep_links, id: 702775
    Device sessions

    2. test_links_open_universal_links_from_chat, id: 704613
    Device sessions

    3. test_links_open_universal_links_from_other_apps, id: 704614
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUi:

    1. test_1_1_chat_edit_message, id: 702855
    Device sessions

    2. test_1_1_chat_message_reaction, id: 702730
    Device sessions

    3. test_1_1_chat_non_latin_messages_stack_update_profile_photo, id: 702745
    Device sessions

    4. test_1_1_chat_push_emoji, id: 702813
    Device sessions

    5. test_1_1_chat_emoji_send_reply_and_open_link, id: 702782
    Device sessions

    6. test_1_1_chat_send_image_save_and_share, id: 703391
    Device sessions

    Class TestCommunityMultipleDeviceMerged:

    1. test_community_emoji_send_copy_paste_reply, id: 702840
    Device sessions

    2. test_community_mark_all_messages_as_read, id: 703086
    Device sessions

    3. test_community_links_with_previews_github_youtube_twitter_gif_send_enable, id: 702844
    Device sessions

    4. test_community_unread_messages_badge, id: 702841
    Device sessions

    5. test_community_message_delete, id: 702839
    Device sessions

    6. test_community_message_send_check_timestamps_sender_username, id: 702838
    Device sessions

    7. test_community_edit_delete_message_when_offline, id: 704615
    Device sessions

    8. test_community_one_image_send_reply, id: 702859
    Device sessions

    9. test_community_message_edit, id: 702843
    Device sessions

    10. test_community_several_images_send_reply, id: 703194
    Device sessions

    Class TestActivityMultipleDevicePR:

    1. test_activity_center_reply_read_unread_delete_filter_swipe, id: 702947
    Device sessions

    2. test_navigation_jump_to, id: 702936
    Device sessions

    Class TestGroupChatMultipleDeviceMergedNewUI:

    1. test_group_chat_reactions, id: 703202
    Device sessions

    2. test_group_chat_join_send_text_messages_push, id: 702807
    Device sessions

    3. test_group_chat_send_image_save_and_share, id: 703297
    Device sessions

    4. test_group_chat_mute_chat, id: 703495
    Device sessions

    Class TestActivityMultipleDevicePRTwo:

    1. test_activity_center_admin_notification_accept_swipe, id: 702958
    Device sessions

    2. test_activity_center_mentions, id: 702957
    Device sessions

    Class TestOneToOneChatMultipleSharedDevicesNewUiTwo:

    1. test_1_1_chat_mute_chat, id: 703496
    Device sessions

    2. test_1_1_chat_delete_via_long_press_relogin, id: 702784
    Device sessions

    Class TestActivityCenterContactRequestMultipleDevicePR:

    1. test_activity_center_contact_request_accept_swipe_mark_all_as_read, id: 702851
    Device sessions

    2. test_activity_center_contact_request_decline, id: 702850
    Device sessions

    3. test_add_contact_field_validation, id: 702777
    Device sessions

    Class TestCommunityOneDeviceMerged:

    1. test_community_copy_and_paste_message_in_chat_input, id: 702742
    Device sessions

    2. test_community_undo_delete_message, id: 702869
    Device sessions

    3. test_community_mute_community_and_channel, id: 703382
    Device sessions

    @ulisesmac ulisesmac merged commit 8b919f4 into develop Dec 8, 2023
    6 checks passed
    @ulisesmac ulisesmac deleted the 17896-raw-balances-big-number branch December 8, 2023 19:40
    yevh-berdnyk pushed a commit that referenced this pull request Dec 8, 2023
    * Add `utils.money/add` version able to work with `nil`s
    
    * Store token raw-balance as big-number
    
    * Improve account balance calculations using `utils.money` existing functions
    
    * Update `:wallet/tokens-filtered` sub
    
    * Make `prettify-balance` able to work with bignumbers
    @ulisesmac
    Copy link
    Contributor Author

    Another account to test: https://etherscan.io/address/0x7bdf634f898ad124a9adb7a1aff95a95aa864cbb

    Just keeping here for the history, that only total fiat amount on wallet card on Home > Wallet is fixed, inside the account the values for tokens are still wrong. photo_2023-12-08 13 17 45 jpeg 2023-12-08 13-18-04

    @OmarBasem Since you are going to modify that code again, this might interest you.

    I think it's due to two reasons:

    • (as discussed yesterday) not taking into account all chains
    • Not using bignumbers

    In this PR I'm using bignumbers for the total balance calculation -it may give you a hint-, also testing with more than 1000 units per token can help.

    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.

    Error while storing wallet raw-balances
    6 participants