@@ -4,7 +4,10 @@ import { DeviceModelId } from "@ledgerhq/devices";
4
4
import BigNumber from "bignumber.js" ;
5
5
import type { Transaction } from "../types" ;
6
6
import { getCryptoCurrencyById } from "@ledgerhq/cryptoassets/currencies" ;
7
- import { genericTestDestination , pickSiblings , botTest } from "@ledgerhq/coin-framework/bot/specs" ;
7
+ import {
8
+ /* genericTestDestination, */ pickSiblings ,
9
+ botTest ,
10
+ } from "@ledgerhq/coin-framework/bot/specs" ;
8
11
import type { AppSpec , TransactionTestInput } from "@ledgerhq/coin-framework/bot/types" ;
9
12
import { acceptTokenTransaction , acceptTransaction } from "./speculos-deviceActions" ;
10
13
import { Account , TokenAccount } from "@ledgerhq/types-live" ;
@@ -22,71 +25,71 @@ const aptosSpecs: AppSpec<Transaction> = {
22
25
firmware : "1.3.2" ,
23
26
} ,
24
27
genericDeviceAction : acceptTransaction ,
25
- testTimeout : 6 * 60 * 1000 ,
28
+ testTimeout : 2 * 60 * 1000 ,
26
29
minViableAmount : MIN_SAFE ,
27
30
transactionCheck : ( { maxSpendable } ) => {
28
31
invariant ( maxSpendable . gt ( MIN_SAFE ) , "balance is too low" ) ;
29
32
} ,
30
33
mutations : [
31
- {
32
- name : "Send ~50%" ,
33
- feature : "send" ,
34
- maxRun : 1 ,
35
- testDestination : genericTestDestination ,
36
- transaction : ( { account, siblings, bridge, maxSpendable } ) => {
37
- invariant ( maxSpendable . gt ( MIN_SAFE ) , "balance is too low" ) ;
38
- const sibling = pickSiblings ( siblings , maxAccount ) ;
39
- const recipient = sibling . freshAddress ;
40
- const amount = maxSpendable . div ( 2 ) . integerValue ( ) ;
41
-
42
- const transaction = bridge . createTransaction ( account ) ;
43
- const updates : Array < Partial < Transaction > > = [
44
- {
45
- recipient,
46
- } ,
47
- { amount } ,
48
- ] ;
49
-
50
- return {
51
- transaction,
52
- updates,
53
- } ;
54
- } ,
55
-
56
- test : ( { accountBeforeTransaction, operation, account } ) => {
57
- botTest ( "account spendable balance decreased with operation" , ( ) =>
58
- expect ( account . spendableBalance ) . toEqual (
59
- accountBeforeTransaction . spendableBalance . minus ( operation . value ) ,
60
- ) ,
61
- ) ;
62
- } ,
63
- } ,
64
- {
65
- name : "Transfer Max" ,
66
- feature : "sendMax" ,
67
- maxRun : 1 ,
68
- transaction : ( { account, siblings, bridge } ) => {
69
- const updates : Array < Partial < Transaction > > = [
70
- {
71
- recipient : pickSiblings ( siblings , maxAccount ) . freshAddress ,
72
- } ,
73
- {
74
- useAllAmount : true ,
75
- } ,
76
- ] ;
77
-
78
- return {
79
- transaction : bridge . createTransaction ( account ) ,
80
- updates,
81
- } ;
82
- } ,
83
- testDestination : genericTestDestination ,
84
- test : ( { account } ) => {
85
- botTest ( "account spendable balance is zero" , ( ) =>
86
- expect ( account . spendableBalance . toString ( ) ) . toBe ( "0" ) ,
87
- ) ;
88
- } ,
89
- } ,
34
+ // {
35
+ // name: "Send ~50%",
36
+ // feature: "send",
37
+ // maxRun: 1,
38
+ // testDestination: genericTestDestination,
39
+ // transaction: ({ account, siblings, bridge, maxSpendable }) => {
40
+ // invariant(maxSpendable.gt(MIN_SAFE), "balance is too low");
41
+ // const sibling = pickSiblings(siblings, maxAccount);
42
+ // const recipient = sibling.freshAddress;
43
+ // const amount = maxSpendable.div(2).integerValue();
44
+
45
+ // const transaction = bridge.createTransaction(account);
46
+ // const updates: Array<Partial<Transaction>> = [
47
+ // {
48
+ // recipient,
49
+ // },
50
+ // { amount },
51
+ // ];
52
+
53
+ // return {
54
+ // transaction,
55
+ // updates,
56
+ // };
57
+ // },
58
+
59
+ // test: ({ accountBeforeTransaction, operation, account }) => {
60
+ // botTest("account spendable balance decreased with operation", () =>
61
+ // expect(account.spendableBalance).toEqual(
62
+ // accountBeforeTransaction.spendableBalance.minus(operation.value),
63
+ // ),
64
+ // );
65
+ // },
66
+ // },
67
+ // {
68
+ // name: "Transfer Max",
69
+ // feature: "sendMax",
70
+ // maxRun: 1,
71
+ // transaction: ({ account, siblings, bridge }) => {
72
+ // const updates: Array<Partial<Transaction>> = [
73
+ // {
74
+ // recipient: pickSiblings(siblings, maxAccount).freshAddress,
75
+ // },
76
+ // {
77
+ // useAllAmount: true,
78
+ // },
79
+ // ];
80
+
81
+ // return {
82
+ // transaction: bridge.createTransaction(account),
83
+ // updates,
84
+ // };
85
+ // },
86
+ // testDestination: genericTestDestination,
87
+ // test: ({ account }) => {
88
+ // botTest("account spendable balance is zero", () =>
89
+ // expect(account.spendableBalance.toString()).toBe("0"),
90
+ // );
91
+ // },
92
+ // },
90
93
{
91
94
name : "Send ~50% of token amount" ,
92
95
feature : "tokens" ,
@@ -98,11 +101,13 @@ const aptosSpecs: AppSpec<Transaction> = {
98
101
const senderTokenAcc = findTokenSubAccountWithBalance ( account ) ;
99
102
invariant ( senderTokenAcc , "Sender token account with available balance not found" ) ;
100
103
101
- const receiverTokenAcc = siblings . find ( acc => findTokenSubAccountWithBalance ( acc ) ) ;
102
- invariant ( receiverTokenAcc , "Recipient not found" ) ;
104
+ const sibling = pickSiblings ( siblings , maxAccount ) ;
105
+
106
+ const recipientTokenAcc = findTokenSubAccountWithBalance ( sibling ) ;
107
+ invariant ( recipientTokenAcc , "Receiver token account with available balance not found" ) ;
103
108
104
109
const amount = senderTokenAcc . spendableBalance . div ( 2 ) . integerValue ( ) ;
105
- const recipient = receiverTokenAcc . freshAddress ;
110
+ const recipient = sibling . freshAddress ;
106
111
const transaction = bridge . createTransaction ( account ) ;
107
112
const subAccountId = senderTokenAcc . id ;
108
113
@@ -134,7 +139,6 @@ function expectTokenAccountCorrectBalanceChange({
134
139
if ( ! tokenAccId ) throw new Error ( "Wrong subAccountId" ) ;
135
140
136
141
const tokenAccAfterTx = account . subAccounts ?. find ( acc => acc . id === tokenAccId ) ;
137
-
138
142
const tokenAccBeforeTx = accountBeforeTransaction . subAccounts ?. find ( acc => acc . id === tokenAccId ) ;
139
143
140
144
if ( ! tokenAccAfterTx || ! tokenAccBeforeTx ) {
0 commit comments