# Test the dapp · Event-driven multi-chain dapps with ICMF · Learn Chromia

> To test the dapp by hand, you run three blockchains locally, submit a customer order, and follow that order as it moves across the chains.

Source: https://chromia.com/learn/icmf-course/manual-testing/

Event-driven multi-chain dapps with ICMFLesson 7 of 7

1. [01Event-driven multi-chain dapps with ICMF](https://chromia.com/learn/icmf-course/introduction/)
2. [02Set up your project](https://chromia.com/learn/icmf-course/setup/)
3. [03Define messages](https://chromia.com/learn/icmf-course/defining-messages/)
4. [04Order chain (send message)](https://chromia.com/learn/icmf-course/order-chain/)
5. [05Delivery chain (receive message)](https://chromia.com/learn/icmf-course/delivery-chain/)
6. [06The factory chain: sending and receiving](https://chromia.com/learn/icmf-course/factory-chain/)
7. [07Test the dapp](https://chromia.com/learn/icmf-course/manual-testing/)

[Learn](https://chromia.com/learn/)[Event-driven multi-chain dapps with ICMF](https://chromia.com/learn/icmf-course/)

07 / 07Advanced

# Test the dapp

To test the dapp by hand, you run three blockchains locally, submit a customer order, and follow that order as it moves across the chains.

Before you begin, check that the chains in your `chromia.yml` file appear in this order:

chromia.yml

```
blockchains:
  order_chain: # internal id 1
    ...
  delivery_chain: # internal id 2
    ...
  factory-chain: # internal id 3
    ...
```

The Chromia CLI starts the chains one after another according to the internal IDs defined here. These IDs are easier to work with during testing than the referential ID (brid), so keep them in mind.

Open a separate terminal window and start the node:

bash

```nolines
chr node start --directory-chain-mock
```

Next, finish the setup by registering two products with the IDs 101 and 102:

shell

```nolines
chr tx --cid 1 register_product 101 --await
```

shell

```nolines
chr tx --cid 1 register_product 102 --await
```

You can now place the first order. `make_customer_order` takes one argument, a struct of type `order_details`. When you pass a struct through the CLI, encode it as an array. For example, an order of 1 product of type 101 and 10 products of type 102, shipped to customer 1104 at Homestreet 2, becomes `[1104, "Homestreet 2", [[101, 1], [102, 10]]]`. Send an order with these details to chain 0:

shell

```nolines
chr tx --cid 1 make_customer_order '[1104, "Homestreet 2", [[101, 1], [102, 10]]]' --await
```

The extra quotes around the order details make your terminal treat them as one program argument.

To confirm the order exists, query the order chain for all orders:

bash

```nolines
chr query --cid 1 list_orders
```

Result

```nolines
[{details=[{product_id=102, quantity=10}, {product_id=101, quantity=1}], order_id=3}]
```

Then check that the factory chain (ID 2) manufactured the products in the right quantities by running this query:

bash

```nolines
chr query --cid 3 get_total_manufactured_products
```

Result

```nolines
[{id=101, quantity=1}, {id=102, quantity=10}]
```

Last, confirm that the delivery chain (ID 1) created a delivery with a status:

bash

```nolines
chr query --cid 2 list_deliveries
```

Result

```nolines
[{customer_id=1104, order_id=3, shipping_address="Homestreet 2", shipping_state="DISPATCHED"}]
```

The `shipping_state` shows CREATED if the chain has not yet processed the second message, and DISPATCHED once it has. If you see CREATED, wait a few seconds and query again. To complete the flow, mark the delivery as DELIVERED with this command:

bash

```nolines
chr tx --cid 2 accept_delivery 3
```

You have now built your first multi-chain app.

Written for this site from Chromia’s public course. Code samples are the course’s own.

[← Previous**The factory chain: sending and receiving**](https://chromia.com/learn/icmf-course/factory-chain/)[Course done →**Start building**](https://chromia.com/developers/#start)
