-
Notifications
You must be signed in to change notification settings - Fork 62
/
Copy pathcreateMockKeyAgent.ts
32 lines (30 loc) · 1.19 KB
/
createMockKeyAgent.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Bip32PublicKeyHex, SodiumBip32Ed25519 } from '@cardano-sdk/crypto';
import { Cardano } from '@cardano-sdk/core';
import { GroupedAddress, KeyAgent, KeyAgentType, KeyPurpose } from '@cardano-sdk/key-management';
const accountIndex = 0;
const chainId = Cardano.ChainIds.Preview;
const extendedAccountPublicKey = Bip32PublicKeyHex(
'00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000'
);
export const createMockKeyAgent = (deriveAddressesReturn: GroupedAddress[] = []): jest.Mocked<KeyAgent> => {
const remainingDeriveAddressesReturn = [...deriveAddressesReturn];
return {
accountIndex,
bip32Ed25519: new SodiumBip32Ed25519(),
chainId,
deriveAddress: jest.fn().mockImplementation(async () => remainingDeriveAddressesReturn.shift()),
derivePublicKey: jest.fn(),
exportRootPrivateKey: jest.fn(),
extendedAccountPublicKey,
serializableData: {
__typename: KeyAgentType.InMemory,
accountIndex,
chainId,
encryptedRootPrivateKeyBytes: [],
extendedAccountPublicKey,
purpose: KeyPurpose.STANDARD
},
signBlob: jest.fn(),
signTransaction: jest.fn()
};
};