# Testing the dapp · Verify events across chains with ICCF · Learn Chromia

> To test the dapp by hand, start both blockchains, create a subscription, and then use that subscription to get into the warehouse.

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

Verify events across chains with ICCFLesson 6 of 6

1. [01Confirm Events Across Blockchains](https://chromia.com/learn/iccf-course/introduction/)
2. [02Set up your project](https://chromia.com/learn/iccf-course/setup/)
3. [03System overview](https://chromia.com/learn/iccf-course/system-overview/)
4. [04Subscription chain](https://chromia.com/learn/iccf-course/subscription-chain/)
5. [05Digital warehouse chain](https://chromia.com/learn/iccf-course/digital-warehouse-chain/)
6. [06Testing the dapp](https://chromia.com/learn/iccf-course/manual-testing/)

[Learn](https://chromia.com/learn/)[Verify events across chains with ICCF](https://chromia.com/learn/iccf-course/)

06 / 06Intermediate

# Testing the dapp

To test the dapp by hand, start both blockchains, create a subscription, and then use that subscription to get into the warehouse.

The internal chain IDs used throughout this course depend on the order of the blockchain definitions. Make sure yours are listed in this order:

chromia.yml

```
blockchains:
  subscription_chain: # Chain id 1
  ...
  digital-warehouse-chain: # Chain id 2
  ...
```

Open a separate terminal window and run the node from the project folder to start the blockchains:

shell

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

The logs should look similar to this:

shell

```
...
Starting blockchain directory-chain with brid B39406781EE6CA71391B519AA1D3B009DA77A0A63B12DCB2BD4DD59C679E2703 on id 0
Starting blockchain subscription_chain with brid EB0A24835FC5B49CFCB6A9C3DC688FBC7D457455E69B9B2956E7689BC830CA49 on id 1
Starting blockchain digital_warehouse_chain with brid 42C95A7CCDAE9B78524A32428E7B313F60AEB31BA66FF41A0ECE2FCB576D5FF4 on id 2
...
```

Your brid values may differ from the ones shown.

Store the brids in environment variables so you can reuse them in later steps:

bash

```nolines
SUBSCRIPTION_CHAIN_BRID=$(curl -s localhost:7740/brid/iid_1) && echo $SUBSCRIPTION_CHAIN_BRID
```

bash

```nolines
DIGITAL_WAREHOUSE_BRID=$(curl -s localhost:7740/brid/iid_2) && echo $DIGITAL_WAREHOUSE_BRID
```

Next, generate a new keypair and save it in `.chromia/config`, which is where Chromia CLI looks by default:



shell

```nolines
chr keygen --file .chromia/config
```

Copy the `pubkey` shown in the console. It serves as the account ID for the operations that follow.

Try registering a new product category. Because you have no subscription yet, the transaction to the digital warehouse fails:

shell

```nolines
chr tx -brid $DIGITAL_WAREHOUSE_BRID register_product_category 555 0 --await -cfg .chromia/config
```

Result

```nolines
... Operation 'digital_warehouse_chain:register_product_category' failed: No account found
```

Before retrying, you need a subscription on the Subscription chain.

Create one now, substituting your generated key for `<pubkey>`:

shell

```nolines
chr tx -brid $SUBSCRIPTION_CHAIN_BRID subscribe 'x"<digital_warehouse_brid>" '[x"<pubkey>", 0]' --await -cfg .chromia/config
```

Here is the same command using environment variable substitution:

bash

```nolines
chr tx -brid $SUBSCRIPTION_CHAIN_BRID subscribe  'x"'"$DIGITAL_WAREHOUSE_BRID"'"' '[x"021E6EE49D997C6DF7721F87027BB56D7436A9CC78F344AE6FF2E8A08789D37F5A", 0]' --await -cfg .chromia/config
```

You should see output like this:

bash

```nolines
transaction with rid F300CBD62F22917145F8594DB63F1780803CD123CA7F89DBE952431409EE2629 was posted CONFIRMED
```

Keep the transaction rid from that output. Use it in the next command, in place of `<tx-rid>`, to authenticate with the digital warehouse.

The command targets chain ID 2 and attaches an `iccf-transaction` that must be verified against chain 1:

shell

```nolines
chr tx -brid $DIGITAL_WAREHOUSE_BRID --iccf-source $SUBSCRIPTION_CHAIN_BRID --iccf-tx <tx-rid> authorize  --await -cfg .chromia/config
```

You now have access to the system. Register a product category and update the inventory once more:

shell

```nolines
chr tx -brid $DIGITAL_WAREHOUSE_BRID register_product_category 555 0 --await -cfg .chromia/config
```

shell

```nolines
chr tx -brid $DIGITAL_WAREHOUSE_BRID update_inventory '[555, 1500, "Got some stuff"]' --await -cfg .chromia/config
```

Finally, generate a warehouse report and inspect the receipts on the subscription chain:

shell

```nolines
chr query -brid $DIGITAL_WAREHOUSE_BRID create_report 'from=0' 'to=null' -cfg .chromia/config
```

Result

```
[
    "history": [
        [555, [
            ["amount": 1500, "comment": "Got some stuff", "product_category": 555, "transaction": 5]]
            ]
        ],
    "inventory": [
        ["UNIT": "LITRE", "product_category": 555, "stock": 1500]
        ],
    "warehouse_id": 1
]
```

shell

```nolines
chr query -brid $SUBSCRIPTION_CHAIN_BRID get_receipts 'account_id=null' 'blockchain_rid=null' 'from=null'
```

Result

```
[
    [
        "account_id": x"02EEB43C7400CA3CEBDECF1C8AC049EAC05EB361FE4C003EF6D298DEA792F58526",
        "blockchain_rid": x"237B0EE3C60CBB1884E63F883F8230FED5C804A9C6933B28FD9214D65FD033B5",
        "payment_amount": 30,
        "period": "WEEK",
        "receipt_id": x"6006EFC423E9032EA4C9584CDE791623A015749FD8BA4831457CCE0769BCA20A",
        "timestamp": 1705504892289
    ]
]
```

You have built a dapp that authenticates users by verifying transactions made on a different chain.

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

[← Previous**Digital warehouse chain**](https://chromia.com/learn/iccf-course/digital-warehouse-chain/)[Course done →**Start building**](https://chromia.com/developers/#start)
