From 584cb9b392e152f30161688388b975f0d94cd8e1 Mon Sep 17 00:00:00 2001 From: John Mitsch Date: Tue, 17 Dec 2024 15:34:34 -0500 Subject: [PATCH] Update SOL tests --- .../recording.har | 140 ++++++++++ .../libs/sdk/spec/solana/solanaClient.test.ts | 240 ++++-------------- 2 files changed, 192 insertions(+), 188 deletions(-) create mode 100644 packages/libs/sdk/spec/recordings/solana-client-fetchEstimatePriorityFees_4175891121/recording.har diff --git a/packages/libs/sdk/spec/recordings/solana-client-fetchEstimatePriorityFees_4175891121/recording.har b/packages/libs/sdk/spec/recordings/solana-client-fetchEstimatePriorityFees_4175891121/recording.har new file mode 100644 index 00000000..44460027 --- /dev/null +++ b/packages/libs/sdk/spec/recordings/solana-client-fetchEstimatePriorityFees_4175891121/recording.har @@ -0,0 +1,140 @@ +{ + "log": { + "_recordingName": "solana-client-fetchEstimatePriorityFees", + "creator": { + "comment": "persister:fs", + "name": "Polly.JS", + "version": "6.0.5" + }, + "entries": [ + { + "_id": "6d1b2f9f9aa8ef71ed9bc079f109a640", + "_order": 0, + "cache": {}, + "request": { + "bodySize": 86, + "cookies": [], + "headers": [ + { + "_fromType": "array", + "name": "content-type", + "value": "application/json" + }, + { + "_fromType": "array", + "name": "accept", + "value": "*/*" + }, + { + "_fromType": "array", + "name": "content-length", + "value": "86" + }, + { + "_fromType": "array", + "name": "user-agent", + "value": "node-fetch/1.0 (+https://github.com/bitinn/node-fetch)" + }, + { + "_fromType": "array", + "name": "accept-encoding", + "value": "gzip,deflate" + }, + { + "_fromType": "array", + "name": "connection", + "value": "close" + }, + { + "name": "host", + "value": "alien-lingering-fire.solana-mainnet.quiknode.pro" + } + ], + "headersSize": 355, + "httpVersion": "HTTP/1.1", + "method": "POST", + "postData": { + "mimeType": "application/json", + "params": [], + "text": "{\"method\":\"qn_estimatePriorityFees\",\"params\":{\"api_version\":2},\"id\":1,\"jsonrpc\":\"2.0\"}" + }, + "queryString": [], + "url": "https://alien-lingering-fire.solana-mainnet.quiknode.pro" + }, + "response": { + "bodySize": 881, + "content": { + "mimeType": "application/json", + "size": 881, + "text": "{\"jsonrpc\":\"2.0\",\"result\":{\"context\":{\"slot\":308116293},\"per_compute_unit\":{\"extreme\":16000000,\"high\":1803944,\"low\":10000,\"medium\":200000,\"percentiles\":{\"0\":0,\"10\":1,\"100\":2000000000,\"15\":3,\"20\":1000,\"25\":10000,\"30\":22124,\"35\":62500,\"40\":100000,\"45\":100000,\"5\":1,\"50\":200000,\"55\":419487,\"60\":742357,\"65\":1000000,\"70\":1200000,\"75\":1803944,\"80\":3152278,\"85\":6706233,\"90\":16000000,\"95\":20000000}},\"per_transaction\":{\"extreme\":1000000000000,\"high\":199999950000,\"low\":300000000,\"medium\":17635743000,\"percentiles\":{\"0\":1000,\"10\":600000,\"100\":200000000000000,\"15\":10000000,\"20\":200000000,\"25\":300000000,\"30\":1375000000,\"35\":2940140000,\"40\":7000000000,\"45\":10000000000,\"5\":130000,\"50\":17635743000,\"55\":24882600000,\"60\":40793750000,\"65\":57852000000,\"70\":99999992448,\"75\":199999950000,\"80\":341941698000,\"85\":500000038616,\"90\":1000000000000,\"95\":3000000000000}},\"recommended\":6706233},\"id\":1}" + }, + "cookies": [], + "headers": [ + { + "name": "access-control-allow-credentials", + "value": "true" + }, + { + "name": "access-control-allow-headers", + "value": "Content-Type,Authorization,User-Agent,solana-client" + }, + { + "name": "access-control-allow-methods", + "value": "GET, POST, OPTIONS" + }, + { + "name": "access-control-allow-origin", + "value": "" + }, + { + "name": "content-type", + "value": "application/json" + }, + { + "name": "vary", + "value": "Accept-Encoding" + }, + { + "name": "x-host-id", + "value": "b4fa617008efc9c5-bdc3c6b0fcc2f18f" + }, + { + "name": "x-node-id", + "value": "solana_solana-mainnet_ewr" + }, + { + "name": "date", + "value": "Tue, 17 Dec 2024 20:18:33 GMT" + }, + { + "name": "content-length", + "value": "881" + }, + { + "name": "connection", + "value": "close" + } + ], + "headersSize": 422, + "httpVersion": "HTTP/1.1", + "redirectURL": "", + "status": 200, + "statusText": "OK" + }, + "startedDateTime": "2024-12-17T20:18:33.468Z", + "time": 165, + "timings": { + "blocked": -1, + "connect": -1, + "dns": -1, + "receive": 0, + "send": 0, + "ssl": -1, + "wait": 165 + } + } + ], + "pages": [], + "version": "1.2" + } +} diff --git a/packages/libs/sdk/spec/solana/solanaClient.test.ts b/packages/libs/sdk/spec/solana/solanaClient.test.ts index b433d830..d38c5493 100644 --- a/packages/libs/sdk/spec/solana/solanaClient.test.ts +++ b/packages/libs/sdk/spec/solana/solanaClient.test.ts @@ -1,27 +1,7 @@ import { solana } from './client'; -import { - Transaction, - Keypair, - SystemProgram, - PublicKey, -} from '@solana/web3.js'; import withPolly from '../testSetup/pollyTestSetup'; describe('solana client', () => { - let keyPair: Keypair; - - beforeAll(() => { - keyPair = Keypair.fromSecretKey( - new Uint8Array([ - 130, 116, 86, 249, 242, 108, 166, 19, 25, 227, 239, 208, 22, 150, 37, - 135, 84, 53, 70, 45, 157, 16, 240, 233, 200, 163, 11, 93, 165, 225, 199, - 93, 132, 17, 199, 50, 81, 22, 117, 194, 161, 238, 140, 6, 87, 103, 78, - 85, 31, 214, 174, 121, 253, 229, 38, 9, 14, 5, 241, 29, 190, 218, 99, - 40, - ]) - ); - }); - it('should call basic solana functions', async () => { await withPolly( { @@ -35,130 +15,11 @@ describe('solana client', () => { ); }); - it('should call solana sendSmartTransaction', async () => { - await withPolly( - { - recordingName: 'solana-client-sendSmartTransaction', - recordIfMissing: true - }, - async () => { - const transaction = new Transaction(); - transaction.add( - SystemProgram.transfer({ - fromPubkey: keyPair.publicKey, - toPubkey: new PublicKey( - '7nkMt6a2VQE86LFp5uPKfjvboNtTFbGe755fkrTUA2Nv' - ), - lamports: 100, - }) - ); - const feeLevel = 'medium'; - await expect( - solana.sendSmartTransaction({ transaction, keyPair, feeLevel }) - ).resolves.toMatchInlineSnapshot( - `"Y4bnQNsHzWshsquWZcQ88Lq7hKpYFkfd27GvTgizmZpEbtEQdgPs4TNhZ4qvMSUYsTLFBJckjqXg7aLg3GFHcQf"` - ); - } - ); - }); - it('should call solana prepareSmartTransaction', async () => { - await withPolly( - { - recordingName: 'solana-client-prepareSmartTransaction', - recordIfMissing: true - }, - async () => { - const transaction = new Transaction(); - transaction.add( - SystemProgram.transfer({ - fromPubkey: keyPair.publicKey, - toPubkey: new PublicKey( - '7nkMt6a2VQE86LFp5uPKfjvboNtTFbGe755fkrTUA2Nv' - ), - lamports: 100, - }) - ); - const feeLevel = 'medium'; - await expect( - solana.prepareSmartTransaction({ - transaction, - payerPublicKey: keyPair.publicKey, - feeLevel, - }) - ).resolves.toMatchInlineSnapshot(` - Object { - "feePayer": null, - "instructions": Array [ - Object { - "data": Array [ - 2, - 0, - 0, - 0, - 100, - 0, - 0, - 0, - 0, - 0, - 0, - 0, - ], - "keys": Array [ - Object { - "isSigner": true, - "isWritable": true, - "pubkey": "9tYYGith1uMmFgWeUD7mouq7JaUhzvDSBYd9aZ25JEFZ", - }, - Object { - "isSigner": false, - "isWritable": true, - "pubkey": "7nkMt6a2VQE86LFp5uPKfjvboNtTFbGe755fkrTUA2Nv", - }, - ], - "programId": "11111111111111111111111111111111", - }, - Object { - "data": Array [ - 3, - 23, - 151, - 0, - 0, - 0, - 0, - 0, - 0, - ], - "keys": Array [], - "programId": "ComputeBudget111111111111111111111111111111", - }, - Object { - "data": Array [ - 2, - 217, - 1, - 0, - 0, - ], - "keys": Array [], - "programId": "ComputeBudget111111111111111111111111111111", - }, - ], - "nonceInfo": null, - "recentBlockhash": "2acCVCzy5dPndawWVvTYDoHWqoe4dXo1srhWQ4W5btnb", - "signers": Array [], - } - `); - } - ); - }); - it('should call fetchEstimatePriorityFees', async () => { await withPolly( { recordingName: 'solana-client-fetchEstimatePriorityFees', - recordIfMissing: true + recordIfMissing: true, }, async () => { await expect(solana.fetchEstimatePriorityFees()).resolves @@ -168,64 +29,67 @@ describe('solana client', () => { "jsonrpc": "2.0", "result": Object { "context": Object { - "slot": 255150582, + "slot": 308116293, }, "per_compute_unit": Object { - "extreme": 630734, - "high": 119250, - "low": 10714, - "medium": 35714, + "extreme": 16000000, + "high": 1803944, + "low": 10000, + "medium": 200000, "percentiles": Object { - "10": 714, + "0": 0, + "10": 1, "100": 2000000000, - "15": 1048, - "20": 2000, - "25": 2718, - "30": 4895, - "35": 6948, - "40": 10714, - "45": 13133, - "5": 100, - "50": 19667, - "55": 25541, - "60": 35714, - "65": 50000, - "70": 66918, - "75": 90000, - "80": 119250, - "85": 183005, - "90": 265586, - "95": 630734, + "15": 3, + "20": 1000, + "25": 10000, + "30": 22124, + "35": 62500, + "40": 100000, + "45": 100000, + "5": 1, + "50": 200000, + "55": 419487, + "60": 742357, + "65": 1000000, + "70": 1200000, + "75": 1803944, + "80": 3152278, + "85": 6706233, + "90": 16000000, + "95": 20000000, }, }, "per_transaction": Object { - "extreme": 886796, - "high": 245714, - "low": 28242, - "medium": 95010, + "extreme": 1000000000000, + "high": 199999950000, + "low": 300000000, + "medium": 17635743000, "percentiles": Object { - "10": 700, - "100": 2000000000, - "15": 1303, - "20": 3126, - "25": 8571, - "30": 12000, - "35": 20000, - "40": 28242, - "45": 40225, - "5": 0, - "50": 50000, - "55": 75019, - "60": 95010, - "65": 110000, - "70": 140214, - "75": 180511, - "80": 245714, - "85": 265450, - "90": 296041, - "95": 886796, + "0": 1000, + "10": 600000, + "100": 200000000000000, + "15": 10000000, + "20": 200000000, + "25": 300000000, + "30": 1375000000, + "35": 2940140000, + "40": 7000000000, + "45": 10000000000, + "5": 130000, + "50": 17635743000, + "55": 24882600000, + "60": 40793750000, + "65": 57852000000, + "70": 99999992448, + "75": 199999950000, + "80": 341941698000, + "85": 500000038616, + "90": 1000000000000, + "95": 3000000000000, }, }, + "recommended": 6706233, }, } `);