Skip to content

Commit b46cc82

Browse files
committed
chore: fmt
1 parent 181933e commit b46cc82

File tree

2 files changed

+30
-19
lines changed

2 files changed

+30
-19
lines changed

packages/core/src/lib/lit-core.spec.ts

Lines changed: 26 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ describe('LitCore', () => {
88
describe('getLatestBlockhash', () => {
99
let originalFetch: typeof fetch;
1010
let originalDateNow: typeof Date.now;
11-
const mockBlockhashUrl = 'https://block-indexer-url.com/get_most_recent_valid_block';
11+
const mockBlockhashUrl =
12+
'https://block-indexer-url.com/get_most_recent_valid_block';
1213

1314
beforeEach(() => {
1415
core = new LitCore({
@@ -51,7 +52,12 @@ describe('LitCore', () => {
5152
const blockNumber = 12345;
5253
global.fetch = jest.fn().mockResolvedValue({
5354
ok: true,
54-
json: () => Promise.resolve({ blockhash: mockBlockhash, timestamp: currentTime, blockNumber }),
55+
json: () =>
56+
Promise.resolve({
57+
blockhash: mockBlockhash,
58+
timestamp: currentTime,
59+
blockNumber,
60+
}),
5561
});
5662
Date.now = jest.fn().mockReturnValue(currentTime);
5763

@@ -73,7 +79,9 @@ describe('LitCore', () => {
7379
core['_getProviderWithFallback'] = jest.fn(() => Promise.resolve(null));
7480

7581
// Execute & Assert
76-
await expect(core.getLatestBlockhash()).rejects.toThrow(InvalidEthBlockhash);
82+
await expect(core.getLatestBlockhash()).rejects.toThrow(
83+
InvalidEthBlockhash
84+
);
7785
});
7886

7987
it('should handle fetch failure and use fallback RPC', async () => {
@@ -87,7 +95,7 @@ describe('LitCore', () => {
8795
getBlock: jest.fn().mockResolvedValue({
8896
hash: mockBlockhash,
8997
number: 12345,
90-
timestamp: currentTime
98+
timestamp: currentTime,
9199
}),
92100
};
93101
jest.spyOn(core as any, '_getProviderWithFallback').mockResolvedValue({
@@ -110,17 +118,18 @@ describe('LitCore', () => {
110118
Date.now = jest.fn().mockReturnValue(currentTime);
111119
global.fetch = jest.fn().mockResolvedValue({
112120
ok: true,
113-
json: () => Promise.resolve({
114-
blockhash: null,
115-
blockNumber: null
116-
}),
121+
json: () =>
122+
Promise.resolve({
123+
blockhash: null,
124+
blockNumber: null,
125+
}),
117126
});
118127
const mockProvider = {
119128
getBlockNumber: jest.fn().mockResolvedValue(12345),
120129
getBlock: jest.fn().mockResolvedValue({
121130
hash: mockBlockhash,
122131
number: 12345,
123-
timestamp: currentTime
132+
timestamp: currentTime,
124133
}),
125134
};
126135
jest.spyOn(core as any, '_getProviderWithFallback').mockResolvedValue({
@@ -141,11 +150,14 @@ describe('LitCore', () => {
141150
const currentTime = 1000000;
142151
Date.now = jest.fn().mockReturnValue(currentTime);
143152

144-
global.fetch = jest.fn().mockImplementation(() =>
145-
new Promise((_, reject) =>
146-
setTimeout(() => reject(new Error('Network timeout')), 1000)
147-
)
148-
);
153+
global.fetch = jest
154+
.fn()
155+
.mockImplementation(
156+
() =>
157+
new Promise((_, reject) =>
158+
setTimeout(() => reject(new Error('Network timeout')), 1000)
159+
)
160+
);
149161

150162
const mockProvider = {
151163
getBlockNumber: jest.fn().mockResolvedValue(12345),
@@ -162,5 +174,4 @@ describe('LitCore', () => {
162174
);
163175
});
164176
});
165-
166177
});

packages/core/src/lib/lit-core.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -857,15 +857,15 @@ export class LitCore {
857857
const provider = await this._getProviderWithFallback();
858858

859859
if (!provider) {
860-
logError(
861-
'All fallback RPC URLs failed. Unable to retrieve blockhash.'
862-
);
860+
logError('All fallback RPC URLs failed. Unable to retrieve blockhash.');
863861
return;
864862
}
865863

866864
try {
867865
// We use a previous block to avoid nodes not having received the latest block yet
868-
const priorBlock = await provider.getBlock(BLOCKHASH_COUNT_PROVIDER_DELAY);
866+
const priorBlock = await provider.getBlock(
867+
BLOCKHASH_COUNT_PROVIDER_DELAY
868+
);
869869
this.latestBlockhash = priorBlock.hash;
870870
this.lastBlockHashRetrieved = priorBlock.timestamp;
871871
log(

0 commit comments

Comments
 (0)