-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Remove steps from onboarding * add origin path * remove 12 toggle * clearing wallet height on chain id change * Add better checks for remove in storage * Review updates
- Loading branch information
Showing
27 changed files
with
271 additions
and
496 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
import { Code, ConnectError, createRouterTransport } from '@connectrpc/connect'; | ||
import { TendermintProxyService } from '@penumbra-zone/protobuf/penumbra/util/tendermint_proxy/v1/tendermint_proxy_connect'; | ||
import { fetchBlockHeightWithFallback } from './latest-block-height'; | ||
import { GetStatusResponse } from '@penumbra-zone/protobuf/penumbra/util/tendermint_proxy/v1/tendermint_proxy_pb'; | ||
|
||
const endpoints = ['rpc1.example.com', 'rpc2.example.com', 'rpc3.example.com']; | ||
|
||
const getMock = (fn: () => GetStatusResponse) => { | ||
return createRouterTransport(router => { | ||
router.service(TendermintProxyService, { | ||
getStatus() { | ||
return fn(); | ||
}, | ||
}); | ||
}); | ||
}; | ||
|
||
describe('fetchBlockHeightWithFallback', () => { | ||
it('should fetch block height successfully from the first endpoint', async () => { | ||
const mockTransport = getMock( | ||
() => new GetStatusResponse({ syncInfo: { latestBlockHeight: 800n } }), | ||
); | ||
const result = await fetchBlockHeightWithFallback(endpoints, mockTransport); | ||
expect(result.blockHeight).toEqual(800); | ||
expect(endpoints.includes(result.rpc)).toBeTruthy(); | ||
}); | ||
|
||
it('should fallback to the second endpoint if the first fails', async () => { | ||
let called = false; | ||
const mockTransport = getMock(() => { | ||
if (!called) { | ||
called = true; | ||
throw new ConnectError('Error calling service', Code.Unknown); | ||
} | ||
return new GetStatusResponse({ syncInfo: { latestBlockHeight: 800n } }); | ||
}); | ||
const result = await fetchBlockHeightWithFallback(endpoints, mockTransport); | ||
expect(result.blockHeight).toEqual(800); | ||
expect(endpoints.includes(result.rpc)).toBeTruthy(); | ||
expect(called).toBeTruthy(); | ||
}); | ||
|
||
it('should fallback through all endpoints and throw an error if all fail', async () => { | ||
let timesCalled = 0; | ||
const mockTransport = getMock(() => { | ||
timesCalled++; | ||
throw new ConnectError('Error calling service', Code.Unknown); | ||
}); | ||
await expect(() => fetchBlockHeightWithFallback(endpoints, mockTransport)).rejects.toThrow( | ||
new Error('All RPC endpoints failed to fetch the block height.'), | ||
); | ||
expect(timesCalled).toEqual(3); | ||
}); | ||
|
||
it('should throw an error immediately if the endpoints array is empty', async () => { | ||
let timesCalled = 0; | ||
const mockTransport = getMock(() => { | ||
timesCalled++; | ||
throw new ConnectError('Error calling service', Code.Unknown); | ||
}); | ||
await expect(() => fetchBlockHeightWithFallback([], mockTransport)).rejects.toThrow( | ||
new Error('All RPC endpoints failed to fetch the block height.'), | ||
); | ||
expect(timesCalled).toEqual(0); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 0 additions & 46 deletions
46
apps/extension/src/routes/page/onboarding/correct-wallet-birthday.test.ts
This file was deleted.
Oops, something went wrong.
33 changes: 0 additions & 33 deletions
33
apps/extension/src/routes/page/onboarding/default-frontend.tsx
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.