Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { assertIsConfirmationDialog, installSnap } from '@metamask/snaps-jest';

import { AccountCapability } from '../src/entities';
import { Caip19Asset } from '../src/handlers/caip';
import type { FillPsbtResponse } from '../src/handlers/KeyringRequestHandler';
import type { SignPsbtResponse } from '../src/handlers/KeyringRequestHandler';
import { BlockchainTestUtils } from './blockchain-utils';
import { MNEMONIC, ORIGIN } from './constants';

Expand Down Expand Up @@ -132,24 +132,20 @@ describe('KeyringRequestHandler', () => {
} as KeyringRequest,
});

expect(response).toRespondWith({
pending: false,
result: [
{
address: 'bcrt1qs2fj7czz0amfm74j73yujx6dn6223md56gkkuy',
derivationIndex: 0,
outpoint: expect.any(String),
scriptPubkey:
'OP_0 OP_PUSHBYTES_20 82932f60427f769dfab2f449c91b4d9e94a8edb4',
scriptPubkeyHex: '001482932f60427f769dfab2f449c91b4d9e94a8edb4',
value: '1000000000',
},
],
});
expect(response).toRespondWith([
{
address: 'bcrt1qs2fj7czz0amfm74j73yujx6dn6223md56gkkuy',
derivationIndex: 0,
outpoint: expect.any(String),
scriptPubkey:
'OP_0 OP_PUSHBYTES_20 82932f60427f769dfab2f449c91b4d9e94a8edb4',
scriptPubkeyHex: '001482932f60427f769dfab2f449c91b4d9e94a8edb4',
value: '1000000000',
},
]);

const utxos = (
response.response as { result: { result: { outpoint: string }[] } }
).result.result;
const utxos = (response.response as { result: { outpoint: string }[] })
.result;

response = await snap.onKeyringRequest({
origin: ORIGIN,
Expand All @@ -169,10 +165,7 @@ describe('KeyringRequestHandler', () => {
} as KeyringRequest,
});

expect(response).toRespondWith({
pending: false,
result: utxos[0],
});
expect(response).toRespondWith(utxos[0]);
});

it('publicDescriptor', async () => {
Expand All @@ -190,11 +183,9 @@ describe('KeyringRequestHandler', () => {
} as KeyringRequest,
});

expect(response).toRespondWith({
pending: false,
result:
"wpkh([27f9035f/84'/1'/0']tpubDCkv2fHDfPg5ok9EPv6CDozH72rvY2jgEPm79szMeBwCBwUf2T6n5nLrWFfhuuD48SgzrELezoiyDM9KbZaVen4wuuGwrqQANDhzB7E8yDh/0/*)#sx899xk6",
});
expect(response).toRespondWith(
"wpkh([27f9035f/84'/1'/0']tpubDCkv2fHDfPg5ok9EPv6CDozH72rvY2jgEPm79szMeBwCBwUf2T6n5nLrWFfhuuD48SgzrELezoiyDM9KbZaVen4wuuGwrqQANDhzB7E8yDh/0/*)#sx899xk6",
);
});
});

Expand Down Expand Up @@ -236,11 +227,8 @@ describe('KeyringRequestHandler', () => {
const result = await response;

expect(result).toRespondWith({
pending: false,
result: {
psbt: SIGNED_PSBT,
txid: null,
},
psbt: SIGNED_PSBT,
txid: null,
});
});

Expand Down Expand Up @@ -275,11 +263,8 @@ describe('KeyringRequestHandler', () => {
const result = await response;

expect(result).toRespondWith({
pending: false,
result: {
psbt: expect.any(String), // non deterministic
txid: null,
},
psbt: expect.any(String), // non deterministic
txid: null,
});
});

Expand Down Expand Up @@ -314,12 +299,9 @@ describe('KeyringRequestHandler', () => {
const result = await response;

expect(result).toRespondWith({
pending: false,
result: {
psbt: expect.any(String), // non deterministic
txid: expect.any(String),
canBeMalleable: false,
},
psbt: expect.any(String), // non deterministic
txid: expect.any(String),
canBeMalleable: false,
});

// Regression for issue #597: after broadcasting a partial-spend tx
Expand Down Expand Up @@ -466,10 +448,7 @@ describe('KeyringRequestHandler', () => {
});

expect(response).toRespondWith({
pending: false,
result: {
psbt: expect.any(String), // non deterministic
},
psbt: expect.any(String), // non deterministic
});
});

Expand Down Expand Up @@ -526,10 +505,7 @@ describe('KeyringRequestHandler', () => {
});

expect(response).toRespondWith({
pending: false,
result: {
fee: '632',
},
fee: '632',
});
});

Expand Down Expand Up @@ -596,9 +572,7 @@ describe('KeyringRequestHandler', () => {

const signResult = await signResponse;

const { result } = (
signResult.response as { result: { result: FillPsbtResponse } }
).result;
const { result } = signResult.response as { result: SignPsbtResponse };

const response = await snap.onKeyringRequest({
origin: ORIGIN,
Expand All @@ -619,11 +593,8 @@ describe('KeyringRequestHandler', () => {
});

expect(response).toRespondWith({
pending: false,
result: {
txid: expect.any(String),
canBeMalleable: false,
},
txid: expect.any(String),
canBeMalleable: false,
});
});

Expand Down Expand Up @@ -687,11 +658,8 @@ describe('KeyringRequestHandler', () => {
const result = await response;

expect(result).toRespondWith({
pending: false,
result: {
txid: expect.any(String),
canBeMalleable: false,
},
txid: expect.any(String),
canBeMalleable: false,
});
});

Expand Down Expand Up @@ -749,11 +717,8 @@ describe('KeyringRequestHandler', () => {
const result = await response;

expect(result).toRespondWith({
pending: false,
result: {
signature:
'AkcwRAIgZxodJQ60t9Rr/hABEHZ1zPUJ4m5hdM5QLpysH8fDSzgCIENOEuZtYf9/Nn/ZW15PcImkknol403dmZrgoOQ+6K+TASECwDKypXm/ElmVTxTLJ7nao6X5mB/iGbU2Q2qtot0QRL4=',
},
signature:
'AkcwRAIgZxodJQ60t9Rr/hABEHZ1zPUJ4m5hdM5QLpysH8fDSzgCIENOEuZtYf9/Nn/ZW15PcImkknol403dmZrgoOQ+6K+TASECwDKypXm/ElmVTxTLJ7nao6X5mB/iGbU2Q2qtot0QRL4=',
});
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ docker exec esplora bash /init-esplora.sh

echo "Running integration tests..."
set +e
jest --config jest.integration.config.js
jest --config jest.integration.config.mjs
TEST_EXIT_CODE=$?
set -e
exit $TEST_EXIT_CODE
3 changes: 3 additions & 0 deletions packages/bitcoin-wallet-snap/jest.integration.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
*/
const config = {
preset: '@metamask/snaps-jest',
transform: {
'^.+\\.(t|j)sx?$': 'ts-jest',
},
testMatch: ['**/integration-test/**/*.test.ts'],
};

Expand Down
Loading