Skip to content

Commit

Permalink
fix cosmos delegation flaky e2e test due to rounding error
Browse files Browse the repository at this point in the history
  • Loading branch information
Wozacosta committed Sep 5, 2024
1 parent c28eb51 commit 9bed32c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion apps/ledger-live-mobile/e2e/specs/delegate/cosmos.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
} from "../../models/currencies";
import { Application } from "../../page";
import DeviceAction from "../../models/DeviceAction";
import BigNumber from "bignumber.js";

let app: Application;
let deviceAction: DeviceAction;
Expand Down Expand Up @@ -37,7 +38,12 @@ describe("Cosmos delegate flow", () => {
const unit = getAccountUnit(testAccount);

const usableAmount = testAccount.spendableBalance.minus(COSMOS_MIN_SAFE).minus(COSMOS_MIN_FEES);
const delegatedAmount = usableAmount.div(100 / delegatedPercent).integerValue();
// rounding to avoid floating point errors
// NOTE: we could allow for some precision error here to avoid rounding issues
const delegatedAmount = usableAmount
.multipliedBy(delegatedPercent)
.div(100)
.integerValue(BigNumber.ROUND_CEIL);
const remainingAmount = usableAmount.minus(delegatedAmount);

await app.stake.selectCurrency(testedCurrency);
Expand Down

1 comment on commit 9bed32c

@github-actions
Copy link

Choose a reason for hiding this comment

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

[Bot] Testing with 'Nitrogen' ✅ 3 txs ($24.07) ⏲ 6min 32s

✅ 1 specs are successful: Elrond

What is the bot and how does it work? Everything is documented here!

⚠️ 1 spec hints
  • Spec Elrond:
    • mutations should define a testDestination(): move some ESDT
Details of the 3 mutations

Spec Elrond (8)

Spec Elrond found 8 MultiversX accounts (preload: 285ms). Will use MultiversX 1.0.20 on nanoS 2.1.0
undefined: 0 EGLD (422ops) (erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp on 44'/508'/0'/0/0) #0 js:2:elrond:erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp:
undefined: 0 EGLD (450ops) (erd172muqtk2ka5ath64284fm0av4tarkg6l040c595uswwz3tgngh9s9dtgp6 on 44'/508'/1'/0/0) #1 js:2:elrond:erd172muqtk2ka5ath64284fm0av4tarkg6l040c595uswwz3tgngh9s9dtgp6:
undefined: 0.0342846 EGLD (419ops) (erd1ql9pxrhe29cjr8qgxx3rtmh9lyax5x9dkvu3mfzrgt4e8hwk536ssl4sea on 44'/508'/2'/0/0) #2 js:2:elrond:erd1ql9pxrhe29cjr8qgxx3rtmh9lyax5x9dkvu3mfzrgt4e8hwk536ssl4sea:
undefined: 0 EGLD (406ops) (erd1sjvd5mh946cty4wq0ya0d82509tc8eulxjujrad5ztfwjlhkqz0qy5yzmn on 44'/508'/3'/0/0) #3 js:2:elrond:erd1sjvd5mh946cty4wq0ya0d82509tc8eulxjujrad5ztfwjlhkqz0qy5yzmn:
undefined: 0.382901 EGLD (385ops) (erd149kzxgtymzzaddanlj02zhyhwves9wspvk8p69u325tjln5en9aqf8x8el on 44'/508'/4'/0/0) #4 js:2:elrond:erd149kzxgtymzzaddanlj02zhyhwves9wspvk8p69u325tjln5en9aqf8x8el:
undefined: 0.033701 EGLD (346ops) (erd143yn6uvrfzjptq5g7wvzntl3fcthsxtxrp9f3dgasluj6q5n0pxq2td67n on 44'/508'/5'/0/0) #5 js:2:elrond:erd143yn6uvrfzjptq5g7wvzntl3fcthsxtxrp9f3dgasluj6q5n0pxq2td67n:
undefined: 0.481758 EGLD (264ops) (erd1nhe920dlsx8u0lg46grd82dc8vqj8wejh8u7xcdjzfr8yy8ncdtsgtgjz7 on 44'/508'/6'/0/0) #6 js:2:elrond:erd1nhe920dlsx8u0lg46grd82dc8vqj8wejh8u7xcdjzfr8yy8ncdtsgtgjz7:
undefined: 0 EGLD (0ops) (erd1w4jjugkk5rp8hn8erefltjn0xek4x60t4hzsmnkfty7930sxujtqgryqgw on 44'/508'/7'/0/0) #7 js:2:elrond:erd1w4jjugkk5rp8hn8erefltjn0xek4x60t4hzsmnkfty7930sxujtqgryqgw:
necessary accounts resynced in 0.11ms
▬ MultiversX 1.0.20 on nanoS 2.1.0
→ FROM undefined: 0.0342846 EGLD (419ops) (erd1ql9pxrhe29cjr8qgxx3rtmh9lyax5x9dkvu3mfzrgt4e8hwk536ssl4sea on 44'/508'/2'/0/0) #2 js:2:elrond:erd1ql9pxrhe29cjr8qgxx3rtmh9lyax5x9dkvu3mfzrgt4e8hwk536ssl4sea: 0.034284668146490572 EGLD spendable. 
  nonce : 218
  TokenAccount MEX: 4.753993606015131105 MEX (123 ops)
  TokenAccount RARE: 1.241083001290913839 RARE (23 ops) (! sum of ops -0.758916998709086161 RARE)
max spendable ~0.0342346
★ using mutation 'send 50%~'
→ TO undefined: 0 EGLD (422ops) (erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp on 44'/508'/0'/0/0) #0 js:2:elrond:erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp:
✔️ transaction 
SEND  0.017350376248099602 EGLD
TO erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp
STATUS (2.92ms)
  amount: 0.017350376248099602 EGLD
  estimated fees: 0.00005 EGLD
  total spent: 0.017400376248099602 EGLD
errors: 
warnings: 
✔️ has been signed! (3.2s) 
✔️ broadcasted! (311ms) optimistic operation: 
  -0.017400376248099602 EGLD OUT        5764149d13c92cf8ccdbf9e347294595abbf4834e1b6bf450e6692d76d2b9048 2024-09-05T10:31
✔️ operation confirmed (12.5s): 
  -0.017400376248099602 EGLD OUT        5764149d13c92cf8ccdbf9e347294595abbf4834e1b6bf450e6692d76d2b9048 2024-09-05T10:31
✔️ undefined: 0.0168842 EGLD (420ops) (erd1ql9pxrhe29cjr8qgxx3rtmh9lyax5x9dkvu3mfzrgt4e8hwk536ssl4sea on 44'/508'/2'/0/0) #2 js:2:elrond:erd1ql9pxrhe29cjr8qgxx3rtmh9lyax5x9dkvu3mfzrgt4e8hwk536ssl4sea: 0.01688429189839097 EGLD spendable. 
  nonce : 219
  TokenAccount MEX: 4.753993606015131105 MEX (123 ops)
  TokenAccount RARE: 1.241083001290913839 RARE (23 ops) (! sum of ops -0.758916998709086161 RARE)(in 12.5s)
✔️ destination operation 
  +0.017350376248099602 EGLD IN         5764149d13c92cf8ccdbf9e347294595abbf4834e1b6bf450e6692d76d2b9048 2024-09-05T10:32
(in 22.4s)

necessary accounts resynced in 0.16ms
▬ MultiversX 1.0.20 on nanoS 2.1.0
→ FROM undefined: 0.382901 EGLD (385ops) (erd149kzxgtymzzaddanlj02zhyhwves9wspvk8p69u325tjln5en9aqf8x8el on 44'/508'/4'/0/0) #4 js:2:elrond:erd149kzxgtymzzaddanlj02zhyhwves9wspvk8p69u325tjln5en9aqf8x8el: 0.382901368845825618 EGLD spendable. 
  nonce : 203
  TokenAccount MEX: 0.308860072115781549 MEX (119 ops)
  TokenAccount RARE: 0.54444033692695976 RARE (12 ops)
max spendable ~0.382851
★ using mutation 'send max'
→ TO undefined: 0.0173503 EGLD (423ops) (erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp on 44'/508'/0'/0/0) #0 js:2:elrond:erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp:
✔️ transaction 
SEND MAX
TO erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp
STATUS (1.80ms)
  amount: 0.382851368845825618 EGLD
  estimated fees: 0.00005 EGLD
  total spent: 0.382901368845825618 EGLD
errors: 
warnings: 
✔️ has been signed! (3s) 
✔️ broadcasted! (234ms) optimistic operation: 
  -0.382901368845825618 EGLD OUT        4d2113cd606199171dcb144b0a2551301c47414197076551db0484e8553be873 2024-09-05T10:32
✔️ operation confirmed (12.3s): 
  -0.382901368845825618 EGLD OUT        4d2113cd606199171dcb144b0a2551301c47414197076551db0484e8553be873 2024-09-05T10:32
✔️ undefined: 0 EGLD (386ops) (erd149kzxgtymzzaddanlj02zhyhwves9wspvk8p69u325tjln5en9aqf8x8el on 44'/508'/4'/0/0) #4 js:2:elrond:erd149kzxgtymzzaddanlj02zhyhwves9wspvk8p69u325tjln5en9aqf8x8el: 0 EGLD spendable. 
  nonce : 204
  TokenAccount MEX: 0.308860072115781549 MEX (119 ops)
  TokenAccount RARE: 0.54444033692695976 RARE (12 ops)(in 12.3s)
✔️ destination operation 
  +0.382851368845825618 EGLD IN         4d2113cd606199171dcb144b0a2551301c47414197076551db0484e8553be873 2024-09-05T10:32
(in 22.4s)

necessary accounts resynced in 0.20ms
▬ MultiversX 1.0.20 on nanoS 2.1.0
→ FROM undefined: 0.033701 EGLD (346ops) (erd143yn6uvrfzjptq5g7wvzntl3fcthsxtxrp9f3dgasluj6q5n0pxq2td67n on 44'/508'/5'/0/0) #5 js:2:elrond:erd143yn6uvrfzjptq5g7wvzntl3fcthsxtxrp9f3dgasluj6q5n0pxq2td67n: 0.033701081918500419 EGLD spendable. 
  nonce : 144
  TokenAccount MEX: 6.268799644559485771 MEX (91 ops)
  TokenAccount RARE: 0.000162556367485977 RARE (11 ops)
max spendable ~0.033651
★ using mutation 'move some ESDT'
→ TO undefined: 0 EGLD (386ops) (erd149kzxgtymzzaddanlj02zhyhwves9wspvk8p69u325tjln5en9aqf8x8el on 44'/508'/4'/0/0) #4 js:2:elrond:erd149kzxgtymzzaddanlj02zhyhwves9wspvk8p69u325tjln5en9aqf8x8el:
✔️ transaction 
SEND  0.00006811901122639 RARE
TO erd149kzxgtymzzaddanlj02zhyhwves9wspvk8p69u325tjln5en9aqf8x8el
STATUS (1.98ms)
  amount: 0.00006811901122639 RARE
  estimated fees: 0.00012578 EGLD
  total spent: 0.00006811901122639 RARE
errors: 
warnings: 
✔️ has been signed! (3.3s) 
✔️ broadcasted! (238ms) optimistic operation: 
  -0.00012578 EGLD   OUT        84f74000583a094eb292429759344a8a5615ecf055847ee14d2f215a8a8fff6f 2024-09-05T10:32
    -0.00006811901122639 RARE OUT        
✔️ operation confirmed (12.4s): 
  -0.000124 EGLD     OUT        84f74000583a094eb292429759344a8a5615ecf055847ee14d2f215a8a8fff6f 2024-09-05T10:33
    -0.00006811901122639 RARE OUT        
✔️ undefined: 0.033577 EGLD (347ops) (erd143yn6uvrfzjptq5g7wvzntl3fcthsxtxrp9f3dgasluj6q5n0pxq2td67n on 44'/508'/5'/0/0) #5 js:2:elrond:erd143yn6uvrfzjptq5g7wvzntl3fcthsxtxrp9f3dgasluj6q5n0pxq2td67n: 0.033577081918500419 EGLD spendable. 
  nonce : 145
  TokenAccount MEX: 6.268799644559485771 MEX (91 ops)
  TokenAccount RARE: 0.000094437356259587 RARE (12 ops)(in 12.4s)


Details of the 3 uncovered mutations

Spec Elrond (3)

  • delegate 1 EGLD: balance is too low (4), spendable balance is less than minimum delegation amount (1)
  • unDelegate 1 EGLD: balance is too low (4), account doesn't have any delegations (1)
  • withdraw all EGLD: balance is too low (4), account doesn't have any delegations (1)
Portfolio ($24.07) – Details of the 1 currencies
Spec (accounts) State Remaining Runs (est) funds?
Elrond (8) 2698 ops (+6), 0.932645 EGLD ($24.07) 💪 999+ erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp
undefined: 0.400201 EGLD (424ops) (erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp on 44'/508'/0'/0/0) #0 js:2:elrond:erd18n5sk95fq9dtgdsa9m9q5ddp66ch9cq5lpjflwn5j9z8x2e9h0qqrvk5qp:
undefined: 0 EGLD (450ops) (erd172muqtk2ka5ath64284fm0av4tarkg6l040c595uswwz3tgngh9s9dtgp6 on 44'/508'/1'/0/0) #1 js:2:elrond:erd172muqtk2ka5ath64284fm0av4tarkg6l040c595uswwz3tgngh9s9dtgp6:
undefined: 0.0168842 EGLD (420ops) (erd1ql9pxrhe29cjr8qgxx3rtmh9lyax5x9dkvu3mfzrgt4e8hwk536ssl4sea on 44'/508'/2'/0/0) #2 js:2:elrond:erd1ql9pxrhe29cjr8qgxx3rtmh9lyax5x9dkvu3mfzrgt4e8hwk536ssl4sea:
undefined: 0 EGLD (406ops) (erd1sjvd5mh946cty4wq0ya0d82509tc8eulxjujrad5ztfwjlhkqz0qy5yzmn on 44'/508'/3'/0/0) #3 js:2:elrond:erd1sjvd5mh946cty4wq0ya0d82509tc8eulxjujrad5ztfwjlhkqz0qy5yzmn:
undefined: 0 EGLD (387ops) (erd149kzxgtymzzaddanlj02zhyhwves9wspvk8p69u325tjln5en9aqf8x8el on 44'/508'/4'/0/0) #4 js:2:elrond:erd149kzxgtymzzaddanlj02zhyhwves9wspvk8p69u325tjln5en9aqf8x8el:
undefined: 0.033577 EGLD (347ops) (erd143yn6uvrfzjptq5g7wvzntl3fcthsxtxrp9f3dgasluj6q5n0pxq2td67n on 44'/508'/5'/0/0) #5 js:2:elrond:erd143yn6uvrfzjptq5g7wvzntl3fcthsxtxrp9f3dgasluj6q5n0pxq2td67n:
undefined: 0.481758 EGLD (264ops) (erd1nhe920dlsx8u0lg46grd82dc8vqj8wejh8u7xcdjzfr8yy8ncdtsgtgjz7 on 44'/508'/6'/0/0) #6 js:2:elrond:erd1nhe920dlsx8u0lg46grd82dc8vqj8wejh8u7xcdjzfr8yy8ncdtsgtgjz7:
undefined: 0 EGLD (0ops) (erd1w4jjugkk5rp8hn8erefltjn0xek4x60t4hzsmnkfty7930sxujtqgryqgw on 44'/508'/7'/0/0) #7 js:2:elrond:erd1w4jjugkk5rp8hn8erefltjn0xek4x60t4hzsmnkfty7930sxujtqgryqgw:
Performance ⏲ 6min 32s

Time spent for each spec: (total across mutations)

Spec (accounts) preload scan re-sync tx status sign op broadcast test destination test
TOTAL 285ms 4min 55s 2386ms 7ms 9.5s 782ms 37.1s 44.8s
Elrond (7) 285ms 4min 55s 2386ms 7ms 9.5s 782ms 37.1s 44.8s

What is the bot and how does it work? Everything is documented here!

Please sign in to comment.