Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DRAFT] feat: new e2e test covering SPL list #29959

Draft
wants to merge 5 commits into
base: main
Choose a base branch
from
Draft
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
1 change: 0 additions & 1 deletion privacy-snapshot.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@
"signature-insights.api.cx.metamask.io",
"snaps.metamask.io",
"solana-mainnet.infura.io",
"solana.rpc.grove.city",
"sourcify.dev",
"start.metamask.io",
"static.cx.metamask.io",
Expand Down
116 changes: 104 additions & 12 deletions test/e2e/flask/solana/common-solana.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Mockttp } from 'mockttp';
import { Suite } from 'mocha';

Check failure on line 2 in test/e2e/flask/solana/common-solana.ts

View workflow job for this annotation

GitHub Actions / Test lint / Test lint

'Suite' is defined but never used
import { withFixtures } from '../../helpers';
import { Driver } from '../../webdriver/driver';
import HeaderNavbar from '../../page-objects/pages/header-navbar';
Expand All @@ -19,6 +20,8 @@
RECIPIENT = 'Enter receiving address',
LOADING = 'Preparing transaction',
}
export const commonSolanaAddress =
'GYP1hGem9HBkYKEWNUQUxEwfmu4hhjuujRgGnj5LrHna';

export const SIMPLEHASH_URL = 'https://api.simplehash.com';

Expand Down Expand Up @@ -88,7 +91,7 @@
image_large_url: '',
image_opengraph_url: '',
blurhash: 'U=Io~ufQ9_jtJTfQsTfQ0*fQ$$fQ#nfQX7fQ',
predominant_color: '#fb9f18',

Check warning on line 94 in test/e2e/flask/solana/common-solana.ts

View workflow job for this annotation

GitHub Actions / Test lint / Test lint

'#fb9f18' Hex color values are not allowed. Consider using design tokens instead. For support reach out to the design system team #metamask-design-system on Slack
},
image_url: '',
image_properties: {
Expand Down Expand Up @@ -125,28 +128,33 @@
}

export async function simulateSolanaTransaction(mockServer: Mockttp) {
console.log('AQUI ENTRA EN SIMULATE');
const response = {
statusCode: 200,
json: {
result: {
context: {
slot: 218,
apiVersion: '2.0.21',
slot: 317166063,
},
value: {
// eslint-disable-next-line id-denylist
err: null,
accounts: null,
err: null,
innerInstructions: null,
logs: [
'Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri invoke [1]',
'Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri consumed 2366 of 1400000 compute units',
'Program return: 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri KgAAAAAAAAA=',
'Program 83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri success',
'Program ComputeBudget111111111111111111111111111111 invoke [1]',
'Program ComputeBudget111111111111111111111111111111 success',
'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [1]',
'Program log: Instruction: TransferChecked',
'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 6228 of 1399850 compute units',
'Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success',
],
returnData: {
data: ['Kg==', 'base64'],
programId: '83astBRguLMdt2h5U1Tpdq5tjFoJ6noeGwaY3mDLVcri',
replacementBlockhash: {
blockhash: '7D3DdWuTUE1DN7xp16wgirt3fXApvdVFqPtfnJYrWKjw',
lastValidBlockHeight: 295455309,
},
unitsConsumed: 2366,
returnData: null,
unitsConsumed: 6378,
},
id: 1337,
},
Expand Down Expand Up @@ -411,18 +419,101 @@
},
pubkey: 'Exo9AH6fNchE43GaJB85FT7ToYiuKnKzYDyW5mFeTXRR',
},
{
account: {
data: {
parsed: {
info: {
isNative: false,
mint: 'BQcdHdAQW1hczDbBi9hiegXAR7A98Q9jx3X3iBBBDiq4',
owner: 'J27ma1MPBRvmPJxLqBqQGNECMXDm9L6abFa4duKiPosa',
state: 'initialized',
tokenAmount: {
amount: '2500000',
decimals: 1,
uiAmount: 2.5,
uiAmountString: '2.5',
},
},
type: 'account',
},
program: 'spl-token',
space: 165,
},
executable: false,
lamports: 2039280,
owner: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
rentEpoch: 318,
},
pubkey: 'Exo9AH6fNchE43GaJB85FT7ToYiuKnKzYDyW5mFeTXRR',
},
{
account: {
data: {
parsed: {
info: {
isNative: false,
mint: 'HqB7uswoVg4suaQiDP3wjxob1G5WdZ144zhdStwMCq7e',
owner: 'J27ma1MPBRvmPJxLqBqQGNECMXDm9L6abFa4duKiPosa',
state: 'initialized',
tokenAmount: {
amount: '250000000',
decimals: 6,
uiAmount: 250,
uiAmountString: '250',
},
},
type: 'account',
},
program: 'spl-token',
space: 165,
},
executable: false,
lamports: 2039280,
owner: 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA',
rentEpoch: 318,
},
pubkey: 'Exo9AH6fNchE43GaJB85FT7ToYiuKnKzYDyW5mFeTXRR',
},
],
},
},
};
});
}

export async function mockGetAccountInfo(mockServer: Mockttp) {
console.log('AQUI ENTRA EN GET ACCOUNT INFO');
const response = {
statusCode: 200,
json: {
result: {
context: {
apiVersion: '2.0.21',
slot: 317161313,
},
value: null,
},
},
};
return await mockServer
.forPost(SOLANA_URL_REGEX)
.withJsonBodyIncluding({
method: 'getAccountInfo',
})
.thenCallback(() => {
return response;
});
}

export async function mockGetFeeForMessage(mockServer: Mockttp) {
const response = {
statusCode: 200,
json: {
result: { context: { slot: 5068 }, value: 5000 },
result: {
context: { apiVersion: '2.0.18', slot: 317144874 },
value: 10,
},
id: 1337,
},
};
Expand Down Expand Up @@ -488,6 +579,7 @@
}
if (mockSendTransaction) {
mockList.push(await mockSendSolanaTransaction(mockServer));
mockList.push(await mockGetAccountInfo(mockServer));
}
return mockList;
},
Expand Down
Loading
Loading