MockHyperlaneEnvironment
for you to unit test your cross-chain app while avoiding the need to fork multiple networks.
Most multichain apps will be built on top of our Mailbox contract. So, we’ve abstracted away the details of a deployed mailbox with a MockMailbox
and our environment contains an originMailbox
and a destinationMailbox
on the same chain. Internally, we store the messages arriving to the destination in the inboundMessages
mapping on the destination mailbox. We simulate message delivery by enqueuing messages and increment the inboundProcessedNonce
with MockMailbox.processNextInboundMessage()
.
The setup for the simple messaging forge test is as following:
TestCrosschainApp
which inherits from Router
:
processNextPendingMessage()
and processNextPendingMessageFromDestination()
to process inbound messages for destination and origin mailboxes respectively. Now, you can make your cross-chain calls from origin to destination and vice-versa:
defaultIsm
mailbox provides by passing it to the Router’s initialize
method like following: