Skip to content

Commit

Permalink
tests(e2e): use @trezor/connect package
Browse files Browse the repository at this point in the history
  • Loading branch information
szymonlesisz committed Apr 6, 2022
1 parent e576de8 commit 23e491a
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 20 deletions.
4 changes: 2 additions & 2 deletions packages/integration-tests/projects/connect/README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# trezor-connect tests
# @trezor/connect tests

## jest test

Testing `trezor-connect` npm package in nodejs environment.
Testing `@trezor/connect` npm package in nodejs environment.

```
./docker/docker-connect-test.sh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NETWORK_IDS, PROTOCOL_MAGICS } from 'trezor-connect/lib/constants/cardano';
import { NETWORK_IDS, PROTOCOL_MAGICS } from '@trezor/connect/lib/constants/cardano';
import { CardanoAddressType } from '@trezor/transport/lib/types/messages';

const legacyResults = [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { NETWORK_IDS, PROTOCOL_MAGICS } from 'trezor-connect/lib/constants/cardano';
import { NETWORK_IDS, PROTOCOL_MAGICS } from '@trezor/connect/lib/constants/cardano';
import {
CardanoAddressType,
CardanoCertificateType,
Expand Down Expand Up @@ -328,7 +328,7 @@ const SAMPLE_MINTS = {
const FEE = '42';
const TTL = '10';
const VALIDITY_INTERVAL_START = '47';
const SCRIPT_DATA_HASH = 'd593fd793c377ac50a3169bb8378ffc257c944da31aa8f355dfa5a4f6ff89e02';
// const SCRIPT_DATA_HASH = 'd593fd793c377ac50a3169bb8378ffc257c944da31aa8f355dfa5a4f6ff89e02';

const legacyResults = {
beforeSignTx: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
/* eslint-disable camelcase, no-underscore-dangle */

import commonFixtures from '../../../../../submodules/trezor-common/tests/fixtures/stellar/sign_tx.json';
import {
StellarMemoType,
StellarAssetType,
StellarSignerType,
} from 'trezor-connect/lib/typescript/trezor/protobuf';
import { Messages } from '@trezor/transport';

// operations are in protobuf format (snake_case)

const transformAsset = asset => ({
type: StellarAssetType[asset.type],
type: Messages.StellarAssetType[asset.type],
code: asset.code,
issuer: asset.issuer,
});
Expand Down Expand Up @@ -126,7 +122,7 @@ const transformOperation = op => {
homeDomain: op.home_domain,
inflationDest: op.inflation_destination_account,
signer: {
type: StellarSignerType[op.signer_type],
type: Messages.StellarSignerType[op.signer_type],
key: op.signer_key,
weight: op.signer_weight,
},
Expand Down Expand Up @@ -185,7 +181,7 @@ export default {
maxTime: parameters.tx.timebounds_end,
},
memo: {
type: StellarMemoType[parameters.tx.memo_type],
type: Messages.StellarMemoType[parameters.tx.memo_type],
text: parameters.tx.memo_text,
id: parameters.tx.memo_id,
hash: parameters.tx.memo_hash,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ const cacheFiles = (dir, cache = {}) => {
const content = JSON.parse(rawJson);
cache[key] = {
...content,
hash: file.split('.')[0], // add hash into object, required by trezor-connect params
hash: file.split('.')[0], // add hash into object, required by @trezor/connect params
};
} catch (error) {
console.error(`TX_CACHE parsing error: ${file}`);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable camelcase, no-bitwise */

import TrezorConnect from 'trezor-connect';
import TrezorConnect from '@trezor/connect';
import * as versionUtils from '@trezor/utils/src/versionUtils'; // NOTE: only this module is required
import { UI } from '@trezor/connect/src/events'; // NOTE: import UI constants directly from source
import { toHardened, getHDPath } from '@trezor/connect/src/utils/pathUtils'; // NOTE: import utils directly from source
Expand Down
4 changes: 2 additions & 2 deletions packages/integration-tests/projects/connect/karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ module.exports = config => {
}),
// replace TrezorConnect module used in ./tests/common.setup.js
new webpack.NormalModuleReplacementPlugin(
/^trezor-connect$/,
path.join(__dirname, '../../../connect-web/build/trezor-connect'),
/^@trezor\/connect$/,
path.join(__dirname, '../../../connect-web/build/trezor-connect.js'),
),
// replace ws module used in ./tests/websocket-client.js
new webpack.NormalModuleReplacementPlugin(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ function CustomReporter(rootConfig, logger) {

return {
onRunStart: () => {
log.info('Running trezor-connect tests...');
log.info('Running @trezor/connect tests...');
log.info('FW:', process.env.TESTS_FIRMWARE);
log.info('Methods:', process.env.TESTS_INCLUDED_METHODS || 'All');
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TrezorConnect from 'trezor-connect';
import TrezorConnect from '@trezor/connect';

// error thrown by .init()
const INIT_ERROR = { code: 'Init_ManifestMissing' };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import TrezorConnect from 'trezor-connect';
import TrezorConnect from '@trezor/connect';
import fixtures from '../../__fixtures__';

const { getController, setup, skipTest, conditionalTest, initTrezorConnect } = global.Trezor;
Expand Down

0 comments on commit 23e491a

Please sign in to comment.