fixing solana mapper test

This commit is contained in:
matias martinez 2023-11-21 12:45:28 -03:00
parent 427c62c2e1
commit c80b6a82ec
6 changed files with 138 additions and 98 deletions

View File

@ -5,7 +5,8 @@ import { solana, LogFoundEvent, LogMessagePublished } from "../../domain/entitie
import { CompiledInstruction, MessageCompiledInstruction } from "../../domain/entities/solana"; import { CompiledInstruction, MessageCompiledInstruction } from "../../domain/entities/solana";
import { configuration } from "../config"; import { configuration } from "../config";
const connection = new Connection(configuration.platforms.solana.rpcs[0]); const connection = new Connection(configuration.platforms.solana.rpcs[0]); // TODO: should be better to inject this to improve testability
export const solanaLogMessagePublishedMapper = async ( export const solanaLogMessagePublishedMapper = async (
tx: solana.Transaction, tx: solana.Transaction,
{ programId, commitment }: { programId: string; commitment?: Commitment } { programId, commitment }: { programId: string; commitment?: Commitment }

View File

@ -82,7 +82,7 @@ export class Web3SolanaSlotRepository implements SolanaSlotRepository {
message: { message: {
...tx?.transaction.message, ...tx?.transaction.message,
accountKeys, accountKeys,
compiledInstructions: message?.compiledInstructions, compiledInstructions: message?.compiledInstructions ?? [],
}, },
}, },
} as solana.Transaction; } as solana.Transaction;

View File

@ -4,7 +4,11 @@ import {
PollSolanaTransactionsConfig, PollSolanaTransactionsConfig,
PollSolanaTransactionsMetadata, PollSolanaTransactionsMetadata,
} from "../../../../src/domain/actions"; } from "../../../../src/domain/actions";
import { MetadataRepository, SolanaSlotRepository } from "../../../../src/domain/repositories"; import {
MetadataRepository,
SolanaSlotRepository,
StatRepository,
} from "../../../../src/domain/repositories";
import { thenWaitForAssertion } from "../../../wait-assertion"; import { thenWaitForAssertion } from "../../../wait-assertion";
import { Fallible, solana } from "../../../../src/domain/entities"; import { Fallible, solana } from "../../../../src/domain/entities";
@ -22,6 +26,7 @@ let handlers = {
working: (logs: any[]) => Promise.resolve(), working: (logs: any[]) => Promise.resolve(),
}; };
let handlerSpy: jest.SpiedFunction<(transactions: any[]) => Promise<void>>; let handlerSpy: jest.SpiedFunction<(transactions: any[]) => Promise<void>>;
let statsRepo: StatRepository;
describe("PollSolanaTransactions", () => { describe("PollSolanaTransactions", () => {
afterEach(async () => { afterEach(async () => {
@ -34,6 +39,7 @@ describe("PollSolanaTransactions", () => {
const expectedTxs = givenTxs(); const expectedTxs = givenTxs();
givenCfg(); givenCfg();
givenStatsRepository();
givenMetadataRepository(); givenMetadataRepository();
givenSolanaSlotRepository(currentSlot, givenBlock(1), expectedSigs, expectedTxs); givenSolanaSlotRepository(currentSlot, givenBlock(1), expectedSigs, expectedTxs);
givenPollSolanaTransactions(); givenPollSolanaTransactions();
@ -66,6 +72,7 @@ describe("PollSolanaTransactions", () => {
const expectedTxs = givenTxs(); const expectedTxs = givenTxs();
givenCfg(); givenCfg();
givenStatsRepository();
givenMetadataRepository({ lastSlot }); givenMetadataRepository({ lastSlot });
givenSolanaSlotRepository(latestSlot, givenBlock(1), expectedSigs, expectedTxs); givenSolanaSlotRepository(latestSlot, givenBlock(1), expectedSigs, expectedTxs);
givenPollSolanaTransactions(); givenPollSolanaTransactions();
@ -110,6 +117,14 @@ const givenBlock = (blockTime: number) => {
{ {
transaction: { transaction: {
message: { message: {
accountKeys: [],
compiledInstructions: [
{
programIdIndex: 0,
accounts: [],
data: "",
},
],
instructions: [ instructions: [
{ {
programIdIndex: 0, programIdIndex: 0,
@ -123,7 +138,7 @@ const givenBlock = (blockTime: number) => {
}, },
], ],
blockTime, blockTime,
}; } as any as solana.Block;
}; };
const givenSigs = () => { const givenSigs = () => {
@ -150,7 +165,7 @@ const givenTxs = () => {
], ],
}, },
}, },
]; ] as any as solana.Transaction[];
}; };
const givenSolanaSlotRepository = ( const givenSolanaSlotRepository = (
@ -172,5 +187,13 @@ const givenSolanaSlotRepository = (
const givenPollSolanaTransactions = () => { const givenPollSolanaTransactions = () => {
handlerSpy = jest.spyOn(handlers, "working"); handlerSpy = jest.spyOn(handlers, "working");
pollSolanaTransactions = new PollSolanaTransactions(metadataRepo, solanaSlotRepo, cfg); pollSolanaTransactions = new PollSolanaTransactions(metadataRepo, solanaSlotRepo, statsRepo, cfg);
};
const givenStatsRepository = () => {
statsRepo = {
count: () => {},
measure: () => {},
report: () => Promise.resolve(""),
};
}; };

View File

@ -1,146 +1,157 @@
import { expect, describe, it } from "@jest/globals"; import { expect, describe, it, jest } from "@jest/globals";
import { solana } from "../../../src/domain/entities"; import { solana } from "../../../src/domain/entities";
import { solanaLogMessagePublishedMapper } from "../../../src/infrastructure/mappers/solanaLogMessagePublishedMapper"; import { solanaLogMessagePublishedMapper } from "../../../src/infrastructure/mappers/solanaLogMessagePublishedMapper";
import { getPostedMessage } from "@certusone/wormhole-sdk/lib/cjs/solana/wormhole";
jest.mock("@certusone/wormhole-sdk/lib/cjs/solana/wormhole");
describe("solanaLogMessagePublishedMapper", () => { describe("solanaLogMessagePublishedMapper", () => {
it("should map a solana transaction to a log-message-published event", async () => { it("should map a solana transaction to a log-message-published event", async () => {
const mockGetPostedMessage = getPostedMessage as jest.MockedFunction<typeof getPostedMessage>;
mockGetPostedMessage.mockResolvedValueOnce({
message: {
emitterChain: 1,
sequence: 1n,
emitterAddress: Buffer.from("7dm9am6Qx7cH64RB99Mzf7ZsLbEfmXM7ihXXCvMiT2X1", "hex"),
submissionTime: 1700571923,
nonce: 1,
consistencyLevel: 1,
payload: Buffer.from("41QVZTrdrRxb", "base64"),
} as any,
});
const programId = "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth"; const programId = "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth";
const tx = { const tx = {
blockTime: 1700571926, blockTime: 1700571923,
meta: { meta: {
computeUnitsConsumed: 38108, computeUnitsConsumed: 114965,
err: null, err: null,
fee: 45000, fee: 10000,
innerInstructions: [ innerInstructions: [
{ {
index: 1, index: 0,
instructions: [ instructions: [
{ accounts: [0, 1], data: "3Bxs43gDisiYM5ts", programIdIndex: 2, stackHeight: 2 }, { accounts: [8, 12, 11], data: "41QVZTrdrRxb", programIdIndex: 19, stackHeight: 2 },
{ accounts: [1], data: "9krTDAJ1gisg2T8j", programIdIndex: 2, stackHeight: 2 }, {
accounts: [0, 14, 8, 11, 5, 16, 12, 2, 1, 15, 6, 3, 17, 0, 18, 10, 20, 19],
data: "A3ktuLMbmSRxRSrkzhPwxk77nFqnyxKr5uiQ83okUWL4V6Lv6FFoqn5uSFxSzyGCvJb9TdY29txdrxJMbFCH7jBsU5Pvq7WAAYHoHe43ZmFd7fARFJsQNWknoTNRAbmmUHezG4rVo5H",
programIdIndex: 21,
stackHeight: 2,
},
{ accounts: [8, 5, 12], data: "6xgaMiT8w5vF", programIdIndex: 19, stackHeight: 3 },
{ accounts: [0, 3], data: "3Bxs4HanWsHUZCbH", programIdIndex: 10, stackHeight: 3 },
{
accounts: [2, 1, 15, 6, 0, 3, 17, 10, 18],
data: "5WRA5BK5zWbhP4hcFCuyykwdemimeRAzp1cmpuNA8xAiatnD1R65GWoYK5cZjrKJYacibisYizNq2Yu1NuBjJBqqB4bt6FjtMu7dXbEnm4o2KJrQGBC5rFiRxMiJsqED4kYz3zzuPvWuiyjC5gjhKp1CCNYEZxcCByC42UrkMmKwfT1HacaRNcesnyrchKE1vHrvoFPmPfAb4rzHNnqnq4R63wXd9e4YjyNBkEz935Y1a4L2zEiep7opJVFGMD55NTYmmVi",
programIdIndex: 20,
stackHeight: 3,
},
{ accounts: [0, 1], data: "3Bxs46EF5kSf8Vhh", programIdIndex: 10, stackHeight: 4 },
{ accounts: [1], data: "9krTD476zgsrbsPV", programIdIndex: 10, stackHeight: 4 },
{ {
accounts: [1], accounts: [1],
data: "SYXsBvR59WTsF4KEVN8LCQ1X9MekXCGPPNo3Af36taxCQBED", data: "SYXsBvR59WTsF4KEVN8LCQ1X9MekXCGPPNo3Af36taxCQBED",
programIdIndex: 2, programIdIndex: 10,
stackHeight: 2, stackHeight: 4,
}, },
{ accounts: [9, 4, 11], data: "3j3xf5aqFS8P", programIdIndex: 19, stackHeight: 2 },
], ],
}, },
], ],
loadedAddresses: { readonly: [], writable: [] },
logMessages: [ logMessages: [
"Program worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth invoke [1]", "Program 8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E invoke [1]",
"Program 11111111111111111111111111111111 invoke [2]", "Program log: mayan-swap v0.2 (build at 1693428062)",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: Approve",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 2904 of 176787 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb invoke [2]",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [3]",
"Program log: Instruction: Burn",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4790 of 135281 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program 11111111111111111111111111111111 invoke [3]",
"Program 11111111111111111111111111111111 success", "Program 11111111111111111111111111111111 success",
"Program 11111111111111111111111111111111 invoke [2]", "Program worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth invoke [3]",
"Program log: Sequence: 328338",
"Program 11111111111111111111111111111111 invoke [4]",
"Program 11111111111111111111111111111111 success", "Program 11111111111111111111111111111111 success",
"Program 11111111111111111111111111111111 invoke [2]", "Program 11111111111111111111111111111111 invoke [4]",
"Program 11111111111111111111111111111111 success", "Program 11111111111111111111111111111111 success",
"Program worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth consumed 38108 of 400000 compute units", "Program 11111111111111111111111111111111 invoke [4]",
"Program 11111111111111111111111111111111 success",
"Program worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth consumed 27438 of 119637 compute units",
"Program worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth success", "Program worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth success",
"Program wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb consumed 81223 of 172075 compute units",
"Program wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb success",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA invoke [2]",
"Program log: Instruction: Transfer",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA consumed 4736 of 89780 compute units",
"Program TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA success",
"Program 8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E consumed 114965 of 200000 compute units",
"Program 8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E success",
], ],
postBalances: [548150063, 1301520, 1, 3647040, 1, 0, 1009200, 1141440],
postTokenBalances: [],
preBalances: [549496583, 0, 1, 3647040, 1, 0, 1009200, 1141440],
preTokenBalances: [],
rewards: [],
status: { Ok: null }, status: { Ok: null },
}, },
slot: 231368528, slot: 231368523,
transaction: { transaction: {
message: { message: {
header: { header: {
numReadonlySignedAccounts: 0, numReadonlySignedAccounts: 0,
numReadonlyUnsignedAccounts: 6, numReadonlyUnsignedAccounts: 12,
numRequiredSignatures: 2, numRequiredSignatures: 2,
}, },
accountKeys: [ accountKeys: [
"DPpi7Sv1BgH8rgNLfcF5hQXccjfHzDWCutH6HyVJXo2c", "7dm9am6Qx7cH64RB99Mzf7ZsLbEfmXM7ihXXCvMiT2X1",
"6YWeHdUSFyciT7EwDcT2XnBHQykJv4EiH8j63jS3gKSL", "DBQF5sQK9VWh7oSGcygNEBnHkkBqnEjaswJQ1fzkQmKm",
"2yVjuQwpsvdsrywzsJJVs9Ueh4zayyo5DYJbBNc3DDpn",
"9bFNrXNb2WTx8fMHXCheaZqkLZ3YCCaiqTftHxeintHy",
"BKJnouHX2xuqZLpDjXYbdjdjdSZ8QAtjdwyH43Eiu6uD",
"CSD6JQMvLi46psjHdpfFdr826mF336pEVMJgjwcoS1m4",
"GF2ghkjwsR9CHkGk1RvuZrApPZGBZynxMm817VNi51Nf",
"GoCsLpg3sWWAmQDBUpE9pPiyqsuXFzZNJnCXvCXiD5P2",
"GYTw6AtTSQjWJsBqdTsMxtKd1797zsfSpDawG64Ryo1y",
"HjFhpdX7VyAW8Kq4fhughu6MHFRVwdCwVjZLVrVaag3k",
"11111111111111111111111111111111", "11111111111111111111111111111111",
"6d3w8mGjJauf6gCAg7WfLezbaPmUHYGuoNutnfYF1RYM", "5yZiE74sGLCT4uRoyeqz4iTYiUwX5uykiPRggCVih9PN",
"KeccakSecp256k11111111111111111111111111111", "7oPa2PHQdZmjSPqvpZN7MQxnC7Dcf3uL4oLqknGLk2S3",
"Sysvar1nstructions1111111111111111111111111", "8LPjGDbxhW4G2Q8S6FvdvUdfGWssgtqmvsc63bwNFA7E",
"DapiQYH3BGonhN8cngWcXQ6SrqSm3cwysoznoHr6Sbsx",
"Gv1KWf8DT1jKv5pKBmGaTmVszqa56Xn8YGx2Pg7i7qAk",
"HZ3rxK31XBHQGyBG95RAix1JeFyF2YMSaYjm2th9LxsB",
"SysvarC1ock11111111111111111111111111111111",
"SysvarRent111111111111111111111111111111111", "SysvarRent111111111111111111111111111111111",
"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth", "worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth",
"wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb",
], ],
recentBlockhash: "BFHcrzxbqH93hinicAiJ4qFUDn3teurRnVSAV3zgyiSt", recentBlockhash: "D8ZWuRAhdPg2cvdy13W3nZFtPtYpkhq8S88yMMrALTcU",
instructions: [ instructions: [
{ {
accounts: [], accounts: [0, 7, 11, 4, 9, 14, 12, 15, 2, 6, 3, 5, 16, 8, 1, 18, 17, 10, 20, 19, 21],
data: "hm62hycs7UDQNrAfDW2YdfVAnH86Ezqr5FRGQQc5VbBR84unD6iT4dneGMkbvseGehcBCs36x7cb1aGui81EvGWnwgAkYRmo4RE4ccABa5hZHwTJY9sEfzTTirfKHCxRpohqAVj2fd13CnJot9hnqRfVTyFS25nFMwnWpTay16BcFcgFBmwWAoSv5EVfcuquRkVh9XMLyTXX1LqwY2ubFrViXSf7vctQroqvVaBf8KF8AiQ1NfkyQqXpiac1Fdz7NdfmdNxabaurJi8Q4Li2s6x6Yhd5qjpRWFsvpThs3HXjm3qRfN2biY5HTy5abmdyz8NR3jxybgzsehUTtwTDRQTdvdszUDWKYmjViqLuEtesTg68bkGk2Sw8vWzFpw8wHueEG4RW3XVPvmyLYsuKE2UXiyntUczc14FHUuTRuMpFDcoajhHk9kPFSqFYMEBiK5MQj9xK1dEn32J5WMQwbvUfxgBpLW6pCymWTPCecHDsCWYxG3DpSmrsbBCuzxdVN1ZFWF2WbG53gVCYNCksaHZmzCkXjo985bgZ9yByaYhtkNc5mWMffYdnynUWTwcB7iW8qN9YbVK44QMqgsK8s6V2GHw6S2v78pUw2a6HtVFyoNThN77yyn7YhHEKroXKWiNXgMnGxLjNTUB8DHUYFg7Ak9wB2C6whkPowkDreUovSXoncC6ovrgT97g7tWmj8PcwAD7iPgDc2AFYFqV6fbj5gJwDxT38sheRYUHoCGREmpmDyJveCsgo74HpimwyZhnauK4pZi4M4aWNLTvdrEdHZ4AVvnzbst6WBkg62nNAiz2dkqUgVLBh1oAnk5rFTuqowBuoMa3gVVKo758wT9qksVgYbZDJKrcqr89g6huQ7VNDjwxaueYbtjmRKxvwb9v6mdbDtGApmtSYNroWznQ18KF1SW422VHdAbfY1NXbd9PM5u2c4mv7MYdFxKsGiN", data: "4Qxwod2ZmVmMFkX2cD8Uw",
programIdIndex: 4, programIdIndex: 13,
stackHeight: null,
},
{
accounts: [0, 3, 1, 5, 6, 2],
data: "6f4i6QEQuN9Xu1k2omxzJbdsSVL",
programIdIndex: 7,
stackHeight: null, stackHeight: null,
}, },
], ],
indexToProgramIds: {}, indexToProgramIds: {},
compiledInstructions: [ compiledInstructions: [
{ {
programIdIndex: 4, programIdIndex: 13,
accountKeyIndexes: [], accountKeyIndexes: [
0, 7, 11, 4, 9, 14, 12, 15, 2, 6, 3, 5, 16, 8, 1, 18, 17, 10, 20, 19, 21,
],
data: { data: {
type: "Buffer", type: "Buffer",
data: [ data: [121, 255, 255, 243, 31, 0, 0, 100, 0, 0, 0, 0, 0, 0, 0],
7, 78, 0, 0, 143, 0, 0, 161, 2, 32, 0, 0, 163, 0, 0, 228, 0, 0, 161, 2, 32, 0, 0,
248, 0, 0, 57, 1, 0, 161, 2, 32, 0, 0, 77, 1, 0, 142, 1, 0, 161, 2, 32, 0, 0, 162,
1, 0, 227, 1, 0, 161, 2, 32, 0, 0, 247, 1, 0, 56, 2, 0, 161, 2, 32, 0, 0, 76, 2,
0, 141, 2, 0, 161, 2, 32, 0, 0, 59, 51, 204, 135, 248, 215, 99, 74, 107, 66, 65,
74, 160, 39, 31, 10, 158, 178, 19, 247, 139, 113, 78, 152, 216, 104, 158, 173,
117, 242, 60, 47, 111, 11, 39, 15, 162, 101, 151, 167, 65, 70, 40, 10, 189, 243,
205, 153, 220, 47, 188, 222, 232, 11, 218, 184, 255, 231, 127, 221, 37, 61, 206,
230, 0, 88, 204, 58, 229, 192, 151, 178, 19, 206, 60, 129, 151, 158, 27, 159, 149,
112, 116, 106, 165, 3, 210, 147, 221, 8, 171, 179, 168, 188, 218, 112, 226, 92,
49, 49, 27, 124, 46, 134, 151, 125, 137, 207, 247, 242, 138, 32, 193, 210, 41,
171, 208, 67, 188, 141, 100, 185, 141, 64, 53, 165, 10, 209, 137, 107, 18, 181,
66, 93, 26, 81, 67, 162, 46, 193, 145, 96, 135, 120, 216, 22, 191, 65, 123, 1,
255, 108, 185, 82, 88, 155, 222, 134, 44, 37, 239, 67, 146, 19, 47, 185, 212, 164,
33, 87, 156, 94, 21, 252, 196, 69, 191, 21, 115, 155, 193, 198, 202, 177, 243, 53,
80, 54, 244, 147, 184, 30, 84, 210, 14, 117, 87, 25, 29, 59, 26, 213, 61, 160,
214, 67, 51, 168, 83, 98, 116, 109, 214, 78, 101, 113, 149, 63, 88, 8, 254, 217,
15, 201, 154, 197, 127, 33, 176, 22, 72, 196, 210, 245, 0, 17, 77, 232, 70, 1,
147, 189, 243, 162, 252, 248, 31, 134, 160, 151, 101, 244, 118, 47, 209, 4, 63,
253, 158, 86, 175, 163, 112, 215, 156, 208, 139, 218, 88, 193, 237, 42, 85, 42,
173, 196, 121, 102, 233, 227, 133, 147, 146, 60, 101, 80, 239, 64, 241, 154, 63,
198, 250, 78, 190, 167, 90, 86, 181, 207, 125, 34, 79, 14, 127, 156, 245, 84, 246,
183, 164, 176, 57, 5, 146, 83, 195, 128, 93, 0, 16, 122, 0, 134, 179, 45, 122, 9,
119, 146, 106, 32, 81, 49, 216, 115, 29, 57, 203, 235, 153, 210, 200, 156, 182,
223, 166, 149, 149, 170, 47, 151, 192, 41, 129, 137, 93, 215, 178, 181, 225, 104,
186, 127, 119, 236, 109, 99, 178, 176, 72, 114, 96, 227, 217, 155, 138, 221, 154,
70, 143, 112, 32, 185, 30, 197, 4, 158, 50, 149, 239, 237, 42, 169, 127, 253, 164,
207, 76, 40, 145, 125, 108, 252, 0, 140, 130, 178, 253, 130, 250, 237, 39, 17,
213, 154, 240, 242, 73, 157, 22, 231, 38, 246, 178, 13, 25, 229, 42, 53, 107, 116,
76, 12, 67, 37, 29, 182, 248, 226, 60, 3, 119, 195, 199, 147, 102, 74, 41, 57,
110, 123, 60, 184, 30, 119, 252, 104, 157, 39, 179, 190, 11, 134, 145, 209, 198,
123, 98, 62, 94, 159, 195, 14, 25, 115, 56, 229, 58, 140, 237, 185, 145, 202, 243,
155, 117, 248, 181, 1, 84, 206, 91, 77, 52, 143, 183, 75, 149, 142, 137, 102, 226,
236, 61, 189, 73, 88, 167, 205, 210, 49, 221, 81, 99, 210, 175, 81, 22, 34, 101,
20, 219, 184, 39, 130, 193, 30, 173, 193, 14, 220, 163, 55, 219, 125, 17, 160,
206, 143, 46, 224, 124, 192, 116, 60, 223, 75, 34, 151, 183, 117, 193, 233, 202,
147, 252, 71, 146, 15, 70, 232, 4, 137, 128, 7, 186, 220, 206, 235, 238, 107, 212,
98, 1, 116, 163, 191, 145, 57, 83, 214, 149, 38, 13, 136, 188, 26, 162, 90, 78,
238, 54, 62, 240, 145, 62, 159, 160, 23, 234, 98, 198, 39, 201, 106, 33, 183, 112,
38, 215, 224, 190, 86, 146, 31, 102, 155, 202, 73, 138, 117, 235, 0, 141, 115, 75,
],
},
},
{
programIdIndex: 7,
accountKeyIndexes: [0, 3, 1, 5, 6, 2],
data: {
type: "Buffer",
data: [
7, 0, 1, 2, 3, 4, 255, 5, 255, 6, 255, 255, 255, 255, 255, 255, 255, 255, 255,
255,
],
}, },
}, },
], ],
}, },
signatures: [
"1NP3vjTMDQnu94JrBKtQqyZLrg9Ep6bgmHbsGQJjUmdLAkfnrkTgRWPM5nLBLYhbGPNJQMv3gMhtwWrW6QHk6iv",
"Sxz3ipEz8SU5tkEGTp97q9weZfgaBVz6bZNUBDNDGLhRUnrVAYDJ2vFHognsGyZ9YsA1YrcMxxYpmWjzNfyX4E2",
],
}, },
version: "legacy", version: "legacy",
} as any as solana.Transaction; } as any as solana.Transaction;
@ -152,7 +163,7 @@ describe("solanaLogMessagePublishedMapper", () => {
expect(events[0].address).toBe(programId); expect(events[0].address).toBe(programId);
expect(events[0].chainId).toBe(1); expect(events[0].chainId).toBe(1);
expect(events[0].txHash).toBe(tx.transaction.signatures[0]); expect(events[0].txHash).toBe(tx.transaction.signatures[0]);
expect(events[0].blockHeight).toBe(tx.slot.toString()); expect(events[0].blockHeight).toBe(BigInt(tx.slot));
expect(events[0].blockTime).toBe(tx.blockTime); expect(events[0].blockTime).toBe(tx.blockTime);
}); });
}); });

View File

@ -4,6 +4,7 @@ import { SnsEventRepository, StaticJobRepository } from "../../../src/infrastruc
import { import {
EvmBlockRepository, EvmBlockRepository,
MetadataRepository, MetadataRepository,
SolanaSlotRepository,
StatRepository, StatRepository,
} from "../../../src/domain/repositories"; } from "../../../src/domain/repositories";
@ -12,6 +13,7 @@ const blockRepo: EvmBlockRepository = {} as any as EvmBlockRepository;
const metadataRepo = {} as MetadataRepository<any>; const metadataRepo = {} as MetadataRepository<any>;
const statsRepo = {} as any as StatRepository; const statsRepo = {} as any as StatRepository;
const snsRepo = {} as any as SnsEventRepository; const snsRepo = {} as any as SnsEventRepository;
const solanaSlotRepo = {} as any as SolanaSlotRepository;
let repo: StaticJobRepository; let repo: StaticJobRepository;
@ -24,6 +26,7 @@ describe("StaticJobRepository", () => {
metadataRepo, metadataRepo,
statsRepo, statsRepo,
snsRepo, snsRepo,
solanaSlotRepo,
}); });
}); });

View File

@ -70,8 +70,10 @@ describe("Web3SolanaSlotRepository", () => {
slot: 100, slot: 100,
transaction: { transaction: {
message: { message: {
version: "legacy",
accountKeys: [], accountKeys: [],
instructions: [], instructions: [],
compiledInstructions: [],
}, },
}, },
}, },