Skip to content

Commit eaf322a

Browse files
committed
test: fix more failing tests
1 parent 8e238da commit eaf322a

File tree

9 files changed

+53
-25
lines changed

9 files changed

+53
-25
lines changed

packages/e2e/test/load-test-custom/wallet-init/wallet-init.test.ts

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
11
/* eslint-disable import/imports-first */
22
import * as dotenv from 'dotenv';
3-
import path from 'path';
4-
5-
// This line must come before loading the env, to configure the location of the .env file
6-
dotenv.config({ path: path.join(__dirname, '../../../.env') });
7-
83
import { BaseWallet, createPersonalWallet } from '@cardano-sdk/wallet';
4+
import { Bip32Account, KeyPurpose, util } from '@cardano-sdk/key-management';
95
import { Logger } from 'ts-log';
10-
import { bufferCount, bufferTime, from, mergeAll, tap } from 'rxjs';
11-
import { logger } from '@cardano-sdk/util-dev';
12-
13-
import { Bip32Account, util } from '@cardano-sdk/key-management';
146
import {
157
MeasurementUtil,
168
assetProviderFactory,
@@ -27,6 +19,12 @@ import {
2719
waitForWalletStateSettle,
2820
walletVariables
2921
} from '../../../src';
22+
import { bufferCount, bufferTime, from, mergeAll, tap } from 'rxjs';
23+
import { logger } from '@cardano-sdk/util-dev';
24+
import path from 'path';
25+
26+
// This line must come before loading the env, to configure the location of the .env file
27+
dotenv.config({ path: path.join(__dirname, '../../../.env') });
3028

3129
// Example call that creates 5000 wallets in 10 minutes:
3230
// VIRTUAL_USERS_GENERATE_DURATION=600 VIRTUAL_USERS_COUNT=5000 yarn load-test-custom:wallet-init
@@ -85,7 +83,7 @@ const createWallet = async (accountIndex: number): Promise<BaseWallet> => {
8583

8684
measurementUtil.addStartMarker(MeasureTarget.wallet, accountIndex);
8785
return createPersonalWallet(
88-
{ name: `Wallet ${accountIndex}` },
86+
{ name: `Wallet ${accountIndex}`, purpose: KeyPurpose.STANDARD },
8987
{
9088
...providers,
9189
bip32Account: await Bip32Account.fromAsyncKeyAgent(keyAgent),

packages/e2e/test/long-running/cache-invalidation.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Crypto from '@cardano-sdk/crypto';
2-
import { AddressType, KeyRole } from '@cardano-sdk/key-management';
2+
import { AddressType, KeyPurpose, KeyRole } from '@cardano-sdk/key-management';
33
import { Cardano } from '@cardano-sdk/core';
44
import {
55
KeyAgentFactoryProps,
@@ -89,7 +89,8 @@ describe('cache invalidation', () => {
8989
idx: 0,
9090
logger,
9191
name: 'Pool Wallet 1',
92-
polling: { interval: 500 }
92+
polling: { interval: 500 },
93+
purpose: KeyPurpose.STANDARD
9394
});
9495

9596
await waitForWalletStateSettle(wallet1.wallet);

packages/e2e/test/long-running/multisig-wallet/MultiSigWallet.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ export class MultiSigWallet {
217217
body: multiSigTx.getTransaction().body,
218218
hash: multiSigTx.getTransaction().id
219219
},
220-
{ knownAddresses: [this.#address], txInKeyPathMap: {} },
220+
{ knownAddresses: [this.#address], purpose: KeyPurpose.MULTI_SIG, txInKeyPathMap: {} },
221221
{ additionalKeyPaths: [DERIVATION_PATH] }
222222
);
223223

@@ -413,6 +413,7 @@ export class MultiSigWallet {
413413
address: baseAddress.toAddress().toBech32() as Cardano.PaymentAddress,
414414
index: 0,
415415
networkId,
416+
purpose: KeyPurpose.MULTI_SIG,
416417
rewardAccount: Cardano.RewardAddress.fromCredentials(networkId, scriptCredential)
417418
.toAddress()
418419
.toBech32() as Cardano.RewardAccount,

packages/e2e/test/wallet_epoch_0/PersonalWallet/plutusTest.test.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { BaseWallet } from '@cardano-sdk/wallet';
22
import { Cardano, Serialization, UtxoProvider } from '@cardano-sdk/core';
33
import { HexBlob, isNotNil } from '@cardano-sdk/util';
4+
import { KeyPurpose } from '@cardano-sdk/key-management';
45
import { Observable, filter, firstValueFrom, interval, map, switchMap, take } from 'rxjs';
56
import { createLogger } from '@cardano-sdk/util-dev';
67
import { getEnv, getWallet, utxoProviderFactory, walletReady, walletVariables } from '../../../src';
@@ -191,7 +192,9 @@ describe('PersonalWallet/plutus', () => {
191192
});
192193

193194
it('can spend balance from a plutus script', async () => {
194-
wallet = (await getWallet({ env, logger, name: 'Spending Wallet', polling: { interval: 50 } })).wallet;
195+
wallet = (
196+
await getWallet({ env, logger, name: 'Spending Wallet', polling: { interval: 50 }, purpose: KeyPurpose.STANDARD })
197+
).wallet;
195198
// UTXO provider can be use to fetch the UTXO set from the script address.
196199
const utxoProvider = await utxoProviderFactory.create(env.UTXO_PROVIDER, env.UTXO_PROVIDER_PARAMS, logger);
197200

@@ -265,7 +268,9 @@ describe('PersonalWallet/plutus', () => {
265268
});
266269

267270
it('can spend balance from a plutus script using a reference script', async () => {
268-
wallet = (await getWallet({ env, logger, name: 'Spending Wallet', polling: { interval: 50 } })).wallet;
271+
wallet = (
272+
await getWallet({ env, logger, name: 'Spending Wallet', polling: { interval: 50 }, purpose: KeyPurpose.STANDARD })
273+
).wallet;
269274
// UTXO provider can be use to fetch the UTXO set from the script address.
270275
const utxoProvider = await utxoProviderFactory.create(env.UTXO_PROVIDER, env.UTXO_PROVIDER_PARAMS, logger);
271276

packages/e2e/test/wallet_epoch_0/SharedWallet/utils.ts

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import * as Crypto from '@cardano-sdk/crypto';
22
import {
33
AccountKeyDerivationPath,
44
KeyAgent,
5+
KeyPurpose,
56
KeyRole,
67
SignBlobResult,
78
SignDataContext,
@@ -22,6 +23,7 @@ const randomPublicKey = () => Crypto.Ed25519PublicKeyHex(Array.from({ length: 64
2223

2324
const DERIVATION_PATH = {
2425
index: 0,
26+
purpose: KeyPurpose.STANDARD,
2527
role: KeyRole.External
2628
};
2729

@@ -30,7 +32,12 @@ const getKeyAgent = async (
3032
genesisParameters: Cardano.CompactGenesis,
3133
bip32Ed25519: Crypto.Bip32Ed25519
3234
) => {
33-
const keyAgent = await createStandaloneKeyAgent(mnemonics.split(' '), genesisParameters, bip32Ed25519);
35+
const keyAgent = await createStandaloneKeyAgent(
36+
mnemonics.split(' '),
37+
genesisParameters,
38+
bip32Ed25519,
39+
KeyPurpose.STANDARD
40+
);
3441

3542
const pubKey = await keyAgent.derivePublicKey(DERIVATION_PATH);
3643

@@ -294,6 +301,7 @@ export const buildSharedWallets = async (env: any, genesisParameters: Cardano.Co
294301
name: 'Alice shared Wallet',
295302
paymentScript,
296303
polling: { interval: 50 },
304+
purpose: KeyPurpose.STANDARD,
297305
stakingScript,
298306
witnesser: new SharedWalletWitnesser(alice.keyAgent, paymentScript, stakingScript)
299307
})
@@ -306,6 +314,7 @@ export const buildSharedWallets = async (env: any, genesisParameters: Cardano.Co
306314
name: 'Bob shared Wallet',
307315
paymentScript,
308316
polling: { interval: 50 },
317+
purpose: KeyPurpose.STANDARD,
309318
stakingScript,
310319
witnesser: new SharedWalletWitnesser(bob.keyAgent, paymentScript, stakingScript)
311320
})
@@ -318,6 +327,7 @@ export const buildSharedWallets = async (env: any, genesisParameters: Cardano.Co
318327
name: 'Charlotte shared Wallet',
319328
paymentScript,
320329
polling: { interval: 50 },
330+
purpose: KeyPurpose.STANDARD,
321331
stakingScript,
322332
witnesser: new SharedWalletWitnesser(charlotte.keyAgent, paymentScript, stakingScript)
323333
})

packages/wallet/test/hardware/ledger/LedgerKeyAgent.integration.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import * as Crypto from '@cardano-sdk/crypto';
2-
3-
import { Bip32Account, CommunicationType, KeyAgent, util } from '@cardano-sdk/key-management';
2+
import { Bip32Account, CommunicationType, KeyAgent, KeyPurpose, util } from '@cardano-sdk/key-management';
43
import { Cardano } from '@cardano-sdk/core';
54
import { LedgerKeyAgent } from '@cardano-sdk/hardware-ledger';
65
import { ObservableWallet, createPersonalWallet, restoreKeyAgent } from '../../../src';
@@ -27,7 +26,7 @@ const createWallet = async (keyAgent: KeyAgent) => {
2726
const asyncKeyAgent = util.createAsyncKeyAgent(keyAgent);
2827
const chainHistoryProvider = mockChainHistoryProvider();
2928
return createPersonalWallet(
30-
{ name: 'Wallet1' },
29+
{ name: 'Wallet1', purpose: KeyPurpose.STANDARD },
3130
{
3231
assetProvider,
3332
bip32Account: await Bip32Account.fromAsyncKeyAgent(asyncKeyAgent),
@@ -52,7 +51,8 @@ describe('LedgerKeyAgent+BaseWallet', () => {
5251
const freshKeyAgent = await LedgerKeyAgent.createWithDevice(
5352
{
5453
chainId: Cardano.ChainIds.Preprod,
55-
communicationType: CommunicationType.Node
54+
communicationType: CommunicationType.Node,
55+
purpose: KeyPurpose.STANDARD
5656
},
5757
keyAgentDependencies
5858
);

packages/wallet/test/hardware/trezor/TrezorKeyAgent.integration.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as Crypto from '@cardano-sdk/crypto';
2-
import { Bip32Account, CommunicationType, KeyAgent, util } from '@cardano-sdk/key-management';
2+
import { Bip32Account, CommunicationType, KeyAgent, KeyPurpose, util } from '@cardano-sdk/key-management';
33
import { Cardano } from '@cardano-sdk/core';
44
import { ObservableWallet, createPersonalWallet, restoreKeyAgent } from '../../../src';
55
import { TrezorKeyAgent } from '@cardano-sdk/hardware-trezor';
@@ -28,7 +28,7 @@ const createWallet = async (keyAgent: KeyAgent) => {
2828
const asyncKeyAgent = util.createAsyncKeyAgent(keyAgent);
2929
const chainHistoryProvider = mockChainHistoryProvider();
3030
return createPersonalWallet(
31-
{ name: 'Wallet1' },
31+
{ name: 'Wallet1', purpose: KeyPurpose.STANDARD },
3232
{
3333
assetProvider,
3434
bip32Account: await Bip32Account.fromAsyncKeyAgent(asyncKeyAgent),
@@ -51,6 +51,7 @@ describe('TrezorKeyAgent+BaseWallet', () => {
5151
const freshKeyAgent = await TrezorKeyAgent.createWithDevice(
5252
{
5353
chainId: Cardano.ChainIds.Preprod,
54+
purpose: KeyPurpose.STANDARD,
5455
trezorConfig: {
5556
communicationType: CommunicationType.Node,
5657
manifest: {

packages/web-extension/test/walletManager/SigningCoordinator.test.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import {
22
AccountKeyDerivationPath,
33
CommunicationType,
44
InMemoryKeyAgent,
5+
KeyPurpose,
56
KeyRole,
67
SignBlobResult,
78
SignDataContext,
@@ -33,6 +34,7 @@ describe('SigningCoordinator', () => {
3334
const requestContext = {
3435
accountIndex: 0,
3536
chainId: Cardano.ChainIds.Preprod,
37+
purpose: KeyPurpose.STANDARD,
3638
wallet
3739
};
3840
let passphrase: Uint8Array;
@@ -69,7 +71,11 @@ describe('SigningCoordinator', () => {
6971
// eslint-disable-next-line max-len
7072
'84a60081825820260aed6e7a24044b1254a87a509468a649f522a4e54e830ac10f27ea7b5ec61f01018383581d70b429738bd6cc58b5c7932d001aa2bd05cfea47020a556c8c753d44361a004c4b40582007845f8f3841996e3d8157954e2f5e2fb90465f27112fc5fe9056d916fae245b82583900b1814238b0d287a8a46ce7348c6ad79ab8995b0e6d46010e2d9e1c68042f1946335c498d2e7556c5c647c4649c6a69d2b645cd1428a339ba1a0463676982583900b1814238b0d287a8a46ce7348c6ad79ab8995b0e6d46010e2d9e1c68042f1946335c498d2e7556c5c647c4649c6a69d2b645cd1428a339ba821a00177a6ea2581c648823ffdad1610b4162f4dbc87bd47f6f9cf45d772ddef661eff198a5447742544319271044774554481a0031f9194577444f47451a0056898d4577555344431a000fc589467753484942411a000103c2581c659ab0b5658687c2e74cd10dba8244015b713bf503b90557769d77a7a14a57696e675269646572731a02269552021a0002e665031a01353f84081a013531740b58204107eada931c72a600a6e3305bd22c7aeb9ada7c3f6823b155f4db85de36a69aa20081825820e686ade5bc97372f271fd2abc06cfd96c24b3d9170f9459de1d8e3dd8fd385575840653324a9dddad004f05a8ac99fa2d1811af5f00543591407fb5206cfe9ac91bb1412404323fa517e0e189684cd3592e7f74862e3f16afbc262519abec958180c0481d8799fd8799fd8799fd8799f581cb1814238b0d287a8a46ce7348c6ad79ab8995b0e6d46010e2d9e1c68ffd8799fd8799fd8799f581c042f1946335c498d2e7556c5c647c4649c6a69d2b645cd1428a339baffffffff581cb1814238b0d287a8a46ce7348c6ad79ab8995b0e6d46010e2d9e1c681b000001863784a12ed8799fd8799f4040ffd8799f581c648823ffdad1610b4162f4dbc87bd47f6f9cf45d772ddef661eff1984577444f4745ffffffd8799fd87980190c8efffff5f6'
7173
);
72-
const signContext: SignTransactionContext = { knownAddresses: [], txInKeyPathMap: {} };
74+
const signContext: SignTransactionContext = {
75+
knownAddresses: [],
76+
purpose: KeyPurpose.STANDARD,
77+
txInKeyPathMap: {}
78+
};
7379

7480
it('rejects given invalid tx cbor', async () => {
7581
await expect(
@@ -155,7 +161,7 @@ describe('SigningCoordinator', () => {
155161
signature: '123' as Ed25519SignatureHex
156162
};
157163
const signContext: SignDataContext = {};
158-
const derivationPath: AccountKeyDerivationPath = { index: 0, role: KeyRole.DRep };
164+
const derivationPath: AccountKeyDerivationPath = { index: 0, purpose: KeyPurpose.STANDARD, role: KeyRole.DRep };
159165

160166
it('rejects with AuthenticationError when there is no subscriber', async () => {
161167
keyAgent.signBlob.mockResolvedValueOnce(signResult);

packages/web-extension/test/walletManager/WalletRepository.test.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
} from '../../src';
1414
import { Cardano, Serialization } from '@cardano-sdk/core';
1515
import { Hash28ByteBase16 } from '@cardano-sdk/crypto';
16-
import { KeyRole } from '@cardano-sdk/key-management';
16+
import { KeyPurpose, KeyRole } from '@cardano-sdk/key-management';
1717
import { firstValueFrom, of } from 'rxjs';
1818
import { logger } from '@cardano-sdk/util-dev';
1919
import pick from 'lodash/pick';
@@ -39,10 +39,12 @@ const createScriptWalletProps = {
3939
accountIndex: storedLedgerWallet.accounts[0].accountIndex,
4040
paymentScriptKeyPath: {
4141
index: 0,
42+
purpose: KeyPurpose.STANDARD,
4243
role: KeyRole.External
4344
},
4445
stakingScriptKeyPath: {
4546
index: 0,
47+
purpose: KeyPurpose.STANDARD,
4648
role: KeyRole.External
4749
},
4850
walletId: storedLedgerWallet.walletId
@@ -134,10 +136,12 @@ describe('WalletRepository', () => {
134136
accountIndex: createScriptWalletProps.ownSigners[0].accountIndex,
135137
paymentScriptKeyPath: {
136138
index: 0,
139+
purpose: KeyPurpose.STANDARD,
137140
role: KeyRole.External
138141
},
139142
stakingScriptKeyPath: {
140143
index: 0,
144+
purpose: KeyPurpose.STANDARD,
141145
role: KeyRole.External
142146
},
143147
walletId: 'does not exist' as WalletId
@@ -156,10 +160,12 @@ describe('WalletRepository', () => {
156160
accountIndex: 999_999_999,
157161
paymentScriptKeyPath: {
158162
index: 0,
163+
purpose: KeyPurpose.STANDARD,
159164
role: KeyRole.External
160165
},
161166
stakingScriptKeyPath: {
162167
index: 0,
168+
purpose: KeyPurpose.STANDARD,
163169
role: KeyRole.External
164170
},
165171
walletId: createScriptWalletProps.ownSigners[0].walletId

0 commit comments

Comments
 (0)