How to Test Your DApp

This guide provides instructions on testing your deployed DApp using command-line tools. It covers retrieving message status, inspecting arguments of emitted events by the Endpoint, and more. If you have not deployed your custom protocol yet, refer to the Getting Started guide before proceeding.

Retrieving Account Balance

To get the balance of any account on an EVM-compatible network, execute the command below. It will print the specified account balance.

npx hardhat balance --acc <address>

Fetching Block Data

To retrieve block details from an EVM-compatible network, execute the command below. It will output the block number, block hash, and creation timestamp.

npx hardhat getBlock --num <block_number>

Extracting Transaction Details

To obtain details of a specific transaction, execute the command below. It will output the sender address, the receiver address, msg.value, payload, and block number.

npx hardhat getTxData --tx <tx_hash>

Printing Proposal Data

If a proposal was sent to the Endpoint, parse the emitted event by executing the below command. It will output the destination chain ID, msg.value, selector slot, agent parameters, sender address, destination address, encoded payload.

npx hardhat proposal --tx <tx_hash>

Parsing Destination Data

To retrieve the payload of a message for execution on the destination chain, execute the command below. It will output the encoded payload.

npx hardhat getDestData --hash <source_chain_tx_hash>

Retrieving Proposal and Message Hash

To find the message hash associated with a transaction hash from the source network, execute the command below. If a proposal is found in the transaction receipt, it will be reconstructed, and the corresponding message hashes will be displayed.

npx hardhat getMsgHash --hash <source_tx_hash>

Checking Message Status by Hash

To determine the current status of a sent message, execute the below command. If the transaction is found, the output will display its current status along with information from the initial proposal.

cast call <MessageData_CA> "getMsgStatusByHash(bytes)" <msg_hash>

Status Codes

0  = NOT_INITIALIZED
1  = INVALID
2  = SAVED
3  = TRANSMITTED
4  = QUEUED
5  = PENDING
6  = PROTOCOL_FAILED
7  = EXTENSION_NOT_REGISTERED
8  = EXTENSION_NOT_REACHABLE
9  = EXTENSION_PANICKED
10 = UNDERESTIMATED
11 = SUCCESS
12 = FAILED
13 = OUT_OF_GAS

Advanced Interaction Using cast

For advanced debugging, you can interact directly with the MessageData contract.

  • Retrieve the full message, including status, nonce, and initial proposal:

cast call <MessageData_CA> "getMsg(bytes32)" -r <rpc_provider>
  • Retrieve only the initial proposal and source chain data:

cast call <MessageData_CA> "getMsgData(bytes32)" -r <rpc_provider>
  • Retrieve message status:

cast call <MessageData_CA> "getMsgStatusByHash(bytes32)" -r <rpc_provider>
  • Retrieve source/destination chain ID:

cast call <MessageData_CA> "getDestChainId/getSrcChainId(bytes32)" -r <rpc_provider>
  • Retrieve initial msg.value:

cast call <MessageData_CA> "getReward(bytes32)" -r <rpc_provider>

UIP Specific Commands

Checking Message Execution on Endpoint

cast call <Endpoint_CA> "messagesExecuted(bytes32)(uint256)" -r <network_name>

Status Codes

0 - Does not exist
1 - Executed
2 - Protocol failed

Last updated

Was this helpful?