# Testing

### Instance Testing

To ensure reliable deployment, it's essential to thoroughly test your handler code. This involves setting up sample data in your databases, which helps verify that your indexing and data transformation logic work as expected.

To test your instance resources, start by configuring your testing environment correctly and setting the YAML Type to “instance”.

```yaml
Version: 2.0.0
Type: instance
Environment:
  testing:
    startBlock: 21036729
    network: Ethereum
    execution: parallel
    rpc: <RPC_ENDPOINT>
    range: 10
  deployment:
    startBlock: latest
    network: Ethereum
    execution: parallel
```

To test your instance, you'll need an RPC endpoint for the network your instance is built on. You can use any RPC provider, but we recommend [this](https://www.ankr.com/rpc/) provider.

Once everything is configured, run the `blockflow test` command.&#x20;

The Blockflow CLI will initiate within a **Dockerised** environment, triggering your instance. If your setup includes a database, sample data will populate automatically. You can monitor this process directly from the terminal.

***

### API Testing

After populating the databases, the next step is to test the APIs built on top of them. To do this, simply change the YAML type to “api”

```yaml
Version: 2.0.0
Type: api
Resources:
  - name: graphql-api
    type: api/graphql
    slug: graphql
    handler: src/apis/graphql.ts
```

Then, run the `blockflow test` command. If any resources of type “api/rest” or “api/graphql” are defined, Blockflow will start the APIs on a local server at port 4000 with the respective slugs.&#x20;

For resources of type “api/graphql”, Blockflow uses an Apollo Server instance, allowing you to easily browse and test GraphQL endpoints.

Blockflow provides a default GraphQL API handler based on your schema located at `src/apis/graphql.ts`. You can use this handler to inspect and interact with your database locally.

### Type in YAML

1. Instance Type:

When the YAML type is instance, the system reads configurations from the YAML file.

It fetches blocks and triggers specified instances according to the configurations.

2. API Type:

When the YAML type is api and an API resource is defined, a server is spun up locally on localhost:4000.

A default GraphQL API handler is generated automatically, allowing monitoring and interaction with databases.

<br>
