Skip to content
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

Adding DI to HttpBackend #69

Closed
progital opened this issue Sep 13, 2019 · 2 comments
Closed

Adding DI to HttpBackend #69

progital opened this issue Sep 13, 2019 · 2 comments
Assignees
Labels
Projects

Comments

@progital
Copy link
Contributor

progital commented Sep 13, 2019

We want to mock HttpRequest for our tests. So lets add an optional constructor argument - "creator" function. If it's defined then createXHR method returns its result.

@progital progital added the rpc label Sep 13, 2019
@progital progital self-assigned this Sep 13, 2019
@jevonearth jevonearth added this to Needs triage in Triage via automation Mar 6, 2020
@jevonearth jevonearth moved this from Needs triage to For Triage in Triage Nov 9, 2020
@jevonearth
Copy link
Collaborator

I think we made the HTTP client injectable since this Issue was opened, but I'm not 100% sure. Needs verification.

The cost of mocking requests for testing purposes may be higher than doing integration tests against a real node.

@Innkst Innkst moved this from For Triage to Low priority in Triage Nov 9, 2020
@michaelkernaghan
Copy link
Collaborator

yes the http cient is now injectable:

is the HTTP client in Taquito injectable ?

Yes, the HTTP client in Taquito is injectable. Taquito is a TypeScript library for building ÐApps on the Tezos blockchain, and it allows you to customize and inject your own HTTP client. This feature is useful for developers who want to use a specific HTTP client or implement custom logic for handling network requests.

To inject your own HTTP client, you need to implement the RpcClient interface provided by Taquito. This interface defines the methods that your custom HTTP client should have. Once you have implemented the RpcClient interface, you can pass your custom HTTP client instance to the RpcProvider or TezosToolkit constructor.

Here's an example of how to inject a custom HTTP client:

import { TezosToolkit, RpcClient, RpcProvider } from '@taquito/taquito';

class MyCustomHttpClient implements RpcClient {
  // Implement required methods from RpcClient interface
  // ...
}

const customHttpClient = new MyCustomHttpClient();
const rpcProvider = new RpcProvider(customHttpClient);
const tezos = new TezosToolkit(rpcProvider);

By injecting your custom HTTP client, you can control how Taquito interacts with the Tezos RPC and customize the behavior as per your requirements.

Triage automation moved this from Low priority to Closed Apr 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Closed
Triage
  
Closed
Development

No branches or pull requests

3 participants