From 1020f276322fe361585a56573091ec647fbd901e Mon Sep 17 00:00:00 2001 From: hzheng-ledger <71653044+hzheng-ledger@users.noreply.github.com> Date: Thu, 24 Aug 2023 17:55:06 +0200 Subject: [PATCH] LIVE-8495 Fix: evm integration test (#4452) --- .changeset/modern-brooms-appear.md | 5 +++++ .../integration/bridge.integration.test.ts | 1 + libs/coin-evm/src/datasets/ethereum1.ts | 2 +- .../src/__tests__/test-helpers/bridge.ts | 14 ++++++++++---- .../src/families/evm/bridge/mock.ts | 1 - libs/ledgerjs/packages/types-live/README.md | 3 ++- libs/ledgerjs/packages/types-live/src/bridge.ts | 1 + 7 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 .changeset/modern-brooms-appear.md diff --git a/.changeset/modern-brooms-appear.md b/.changeset/modern-brooms-appear.md new file mode 100644 index 000000000000..b3426ddcfc6c --- /dev/null +++ b/.changeset/modern-brooms-appear.md @@ -0,0 +1,5 @@ +--- +"@ledgerhq/coin-evm": patch +--- + +fix evm integration tests diff --git a/libs/coin-evm/src/__tests__/integration/bridge.integration.test.ts b/libs/coin-evm/src/__tests__/integration/bridge.integration.test.ts index 3ce5fcda1a61..cd1ee384c9a4 100644 --- a/libs/coin-evm/src/__tests__/integration/bridge.integration.test.ts +++ b/libs/coin-evm/src/__tests__/integration/bridge.integration.test.ts @@ -13,6 +13,7 @@ export const dataset: DatasetTest = { implementations: ["mock", "js"], currencies: { ethereum_as_evm_test_only: { + IgnorePrepareTransactionFields: ["maxFeePerGas", "maxPriorityFeePerGas"], accounts: [ { FIXME_tests: ["balance is sum of ops"], diff --git a/libs/coin-evm/src/datasets/ethereum1.ts b/libs/coin-evm/src/datasets/ethereum1.ts index f884f3015d4d..edec62a2edd5 100644 --- a/libs/coin-evm/src/datasets/ethereum1.ts +++ b/libs/coin-evm/src/datasets/ethereum1.ts @@ -5,7 +5,7 @@ import { AccountRaw } from "@ledgerhq/types-live"; export const ethereum1: AccountRaw = { id: "js:1:ethereum_as_evm_test_only:0x0E3F0bb9516F01f2C34c25E0957518b8aC9414c5:", seedIdentifier: "0x0E3F0bb9516F01f2C34c25E0957518b8aC9414c5", - name: "Ethereum legacy xpub6Bem...JyAdpYZy", + name: "Ethereum xpub6Bem...JyAdpYZy", derivationMode: "", index: 0, freshAddress: "0x0E3F0bb9516F01f2C34c25E0957518b8aC9414c5", diff --git a/libs/ledger-live-common/src/__tests__/test-helpers/bridge.ts b/libs/ledger-live-common/src/__tests__/test-helpers/bridge.ts index 0ea4c7d8ecc9..133273415ac3 100644 --- a/libs/ledger-live-common/src/__tests__/test-helpers/bridge.ts +++ b/libs/ledger-live-common/src/__tests__/test-helpers/bridge.ts @@ -515,9 +515,11 @@ export function testBridge(data: DatasetTest): v // stability: function called twice will return the same object reference // (=== convergence so we can stop looping, typically because transaction will be a hook effect dependency of prepareTransaction) async function expectStability(account, t) { - const t2 = await bridge.prepareTransaction(account, t); - const t3 = await bridge.prepareTransaction(account, t2); - expect(t2).toBe(t3); + let t2 = await bridge.prepareTransaction(account, t); + let t3 = await bridge.prepareTransaction(account, t2); + t2 = omit(t2, arg.currencyData.IgnorePrepareTransactionFields || []); + t3 = omit(t3, arg.currencyData.IgnorePrepareTransactionFields || []); + expect(t2).toStrictEqual(t3); } makeTest("ref stability on empty transaction", async () => { @@ -540,13 +542,17 @@ export function testBridge(data: DatasetTest): v recipient: account.freshAddress, }; const stable = await bridge.prepareTransaction(account, t); - const first = await bridge.prepareTransaction(account, stable); + const first = omit( + await bridge.prepareTransaction(account, stable), + arg.currencyData.IgnorePrepareTransactionFields || [], + ); const concur = await Promise.all( Array(3) .fill(null) .map(() => bridge.prepareTransaction(account, stable)), ); concur.forEach(r => { + r = omit(r, arg.currencyData.IgnorePrepareTransactionFields || []); expect(r).toEqual(first); }); }); diff --git a/libs/ledger-live-common/src/families/evm/bridge/mock.ts b/libs/ledger-live-common/src/families/evm/bridge/mock.ts index b753a2d43439..eb4904ce5700 100644 --- a/libs/ledger-live-common/src/families/evm/bridge/mock.ts +++ b/libs/ledger-live-common/src/families/evm/bridge/mock.ts @@ -14,7 +14,6 @@ import { defaultUpdateTransaction } from "@ledgerhq/coin-framework/bridge/jsHelp import { getGasLimit } from "@ledgerhq/coin-evm/logic"; import { getTypedTransaction } from "@ledgerhq/coin-evm/transaction"; const receive = makeAccountBridgeReceive(); - const defaultGetFees = (_a, t: any) => (t.gasPrice || new BigNumber(0)).times(getGasLimit(t)); const createTransaction = (): Transaction => ({ diff --git a/libs/ledgerjs/packages/types-live/README.md b/libs/ledgerjs/packages/types-live/README.md index 3c2e242a4f55..bb70e8dfafe3 100644 --- a/libs/ledgerjs/packages/types-live/README.md +++ b/libs/ledgerjs/packages/types-live/README.md @@ -495,13 +495,14 @@ Type: function (account: [Account](#account)): void ### CurrenciesData -Type: {FIXME_ignoreAccountFields: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?, FIXME_ignoreOperationFields: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?, FIXME_ignorePreloadFields: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?, mockDeviceOptions: any?, scanAccounts: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<{name: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), apdus: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), unstableAccounts: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, test: function (expect: ExpectFn, scanned: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Account](#account)>, bridge: [CurrencyBridge](#currencybridge)): any?}>?, accounts: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<{implementations: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?, raw: [AccountRaw](#accountraw), FIXME_tests: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp))>?, transactions: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\>?, test: function (arg0: ExpectFn, arg1: [Account](#account), arg2: [AccountBridge](#accountbridge)\): any?}>?, test: function (arg0: ExpectFn, arg1: [CurrencyBridge](#currencybridge)): any?} +Type: {FIXME_ignoreAccountFields: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?, FIXME_ignoreOperationFields: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?, FIXME_ignorePreloadFields: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?, IgnorePrepareTransactionFields: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?, mockDeviceOptions: any?, scanAccounts: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<{name: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), apdus: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), unstableAccounts: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, test: function (expect: ExpectFn, scanned: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Account](#account)>, bridge: [CurrencyBridge](#currencybridge)): any?}>?, accounts: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<{implementations: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?, raw: [AccountRaw](#accountraw), FIXME_tests: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp))>?, transactions: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\>?, test: function (arg0: ExpectFn, arg1: [Account](#account), arg2: [AccountBridge](#accountbridge)\): any?}>?, test: function (arg0: ExpectFn, arg1: [CurrencyBridge](#currencybridge)): any?} #### Properties * `FIXME_ignoreAccountFields` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?** * `FIXME_ignoreOperationFields` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?** * `FIXME_ignorePreloadFields` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?** +* `IgnorePrepareTransactionFields` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?** * `mockDeviceOptions` **any?** * `scanAccounts` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<{name: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), apdus: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), unstableAccounts: [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?, test: function (expect: ExpectFn, scanned: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Account](#account)>, bridge: [CurrencyBridge](#currencybridge)): any?}>?** * `accounts` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<{implementations: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)>?, raw: [AccountRaw](#accountraw), FIXME_tests: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<([string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | [RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp))>?, transactions: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\>?, test: function (arg0: ExpectFn, arg1: [Account](#account), arg2: [AccountBridge](#accountbridge)\): any?}>?** diff --git a/libs/ledgerjs/packages/types-live/src/bridge.ts b/libs/ledgerjs/packages/types-live/src/bridge.ts index a68c5a3d05ce..b9b4abad7485 100644 --- a/libs/ledgerjs/packages/types-live/src/bridge.ts +++ b/libs/ledgerjs/packages/types-live/src/bridge.ts @@ -229,6 +229,7 @@ export type CurrenciesData = { FIXME_ignoreAccountFields?: string[]; FIXME_ignoreOperationFields?: string[]; FIXME_ignorePreloadFields?: string[]; + IgnorePrepareTransactionFields?: string[]; mockDeviceOptions?: any; scanAccounts?: Array<{ name: string;