-
Notifications
You must be signed in to change notification settings - Fork 324
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
Bridge with mocks testing #5803
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎ 5 Ignored Deployments
|
There as been no activity on this PR for the last 14 days. Please consider closing this PR. |
libs/ledger-live-common/src/__tests__/test-helpers/bridgeSetupUpdateMocks.ts
Show resolved
Hide resolved
976679c
to
19bf70c
Compare
3f9869f
to
b81ce81
Compare
Deployment failed with the following error:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some linters errors :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
libs/ledger-live-common/src/__tests__/test-helpers/bridgeTeardownUpdateMocks.ts
Outdated
Show resolved
Hide resolved
08cdaae
@@ -18,6 +18,15 @@ if (process.env.ONLY_INTEGRATION_TESTS) { | |||
testRegex = "(/__tests__/.*|(\\.|/)integration\\.(test|spec))\\.[jt]sx?$"; | |||
} | |||
|
|||
if (process.env.USE_BACKEND_MOCKS) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the name is a little confusing here.
should we use kind of "process.env.ONLY_BRIDGE_TESTS" to filter the bridge integration tests?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indeed, we could update the name as now it's "bridge tests"
@@ -0,0 +1,3 @@ | |||
DISABLE_MOCKED_WARNING=true | |||
API_STELLAR_HORIZON_STATIC_FEE=true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not directly related to the PR.
but it seems that the
if (getEnv("API_STELLAR_HORIZON_STATIC_FEE")) {
in "src/families/stellar/api/horizon.ts"
could be replaced by something like
if (process.env.TESTING)
It could save the env var "API_STELLAR_HORIZON_STATIC_FEE"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok thanks i'm going to check :)
@@ -70,6 +70,8 @@ | |||
"test": "pnpm ci-test-unit", | |||
"ci-test-unit": "env-cmd -f .ci.unit.env pnpm jest --ci --updateSnapshot && git diff --exit-code src", | |||
"ci-test-integration": "env-cmd -f .ci.integration.env pnpm jest --ci --updateSnapshot --passWithNoTests", | |||
"test-bridge": "env-cmd -f .ci.bridge.env pnpm jest --ci --updateSnapshot --passWithNoTests --runInBand", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just a question, should we still need "updateSnapshot" for "test-bridge" and "test-bridge-update" as we've mocked the http responses now ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 Indeed we could restrict to standard integration bridge test
import { createHash } from "crypto"; | ||
|
||
function sha256(str: string) { | ||
return createHash("sha256").update(str).digest("hex"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think base64 is enough. I we don't really need sha256 to encode it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ok, will try :)
url: nodeRequest.url, | ||
headers: nodeRequest.headers, | ||
body: nodeRequest.body != null ? nodeRequest.body : {}, | ||
fileName: sha256(`${nodeRequest.method}${nodeRequest.url}`), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe we can exclude the hostname of nodeRequest.url because we may change the RPC node from time to time but we want to keep the filename I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I add something related to this in improvements, this is to think about as a lot of parameters could impact responses (client version, feature support, min blockheight for history, ...)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
||
/* Loop through each mock and apply them to nock */ | ||
export async function initBackendMocks() { | ||
const root = `${__dirname}/bridgeMocks`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we categorise files into different sub folders by family or coin instead of putting all mock files in a single folder?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried but since we are "sniffing" globally we either have to :
- Find the impacted family using url (not clean)
- Doing mock updates by chain only
It is a choice but indeed that way it would be cleaner and easier to deal with
Do you think of a better solution ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, I see.
Maybe keep it like this at the moment and think about improvements later.
Bridge with mocks testing
Bridge with mocks testing
📝 Description
To run bridge test using mocks :
pnpm run test-bridge
To update mocks :
pnpm run test-bridge-update
Supported : algorand
Cosmos should already be supported but there is an issue on develop
Families that require specific work :
❓ Context
✅ Checklist
Pull Requests must pass the CI and be code reviewed. Set as Draft if the PR is not ready.
npx changeset
was attached.[ ] Impact of the changes:
🧐 Checklist for the PR Reviewers