Skip to content

Commit

Permalink
check received event
Browse files Browse the repository at this point in the history
  • Loading branch information
cam-schultz committed Sep 26, 2023
1 parent 05185c9 commit 9fdbdf2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 12 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ require (

require (
github.com/Microsoft/go-winio v0.5.2 // indirect
github.com/ava-labs/teleporter v0.0.0-20230925203622-f24fe9bc9e34 // indirect
github.com/ava-labs/teleporter v0.0.0-20230926154828-4cab08966a53 // indirect
github.com/cockroachdb/errors v1.9.1 // indirect
github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b // indirect
github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ github.com/ava-labs/teleporter v0.0.0-20230925201328-8b8c9abc32cd h1:hyhu7x+0i+H
github.com/ava-labs/teleporter v0.0.0-20230925201328-8b8c9abc32cd/go.mod h1:hK/p4P7DckpwCc9AwvKId6EMGFTEevoF6BlpeZlCxY0=
github.com/ava-labs/teleporter v0.0.0-20230925203622-f24fe9bc9e34 h1:VLHIAEw9jakT+QXzMc/HIFdrx/Y9WwnqXjmB9+XaDFw=
github.com/ava-labs/teleporter v0.0.0-20230925203622-f24fe9bc9e34/go.mod h1:hK/p4P7DckpwCc9AwvKId6EMGFTEevoF6BlpeZlCxY0=
github.com/ava-labs/teleporter v0.0.0-20230926154828-4cab08966a53 h1:ar+mKvr5icijtLuckSJEsuqKsb2Bp92tF7zx+TZHTwE=
github.com/ava-labs/teleporter v0.0.0-20230926154828-4cab08966a53/go.mod h1:hK/p4P7DckpwCc9AwvKId6EMGFTEevoF6BlpeZlCxY0=
github.com/aymerick/raymond v2.0.3-0.20180322193309-b565731e1464+incompatible/go.mod h1:osfaiScAUVup+UC9Nfq76eWqDhXlp+4UYaA8uhTBO6g=
github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
Expand Down
4 changes: 2 additions & 2 deletions messages/teleporter/abi.go

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions tests/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,18 @@ func TestE2E(t *testing.T) {
ginkgo.RunSpecs(t, "Relayer e2e test")
}

// BeforeSuite starts the default network and adds 10 new nodes as validators with BLS keys
// registered on the P-Chain.
// Adds two disjoint sets of 5 of the new validator nodes to validate two new subnets with a
// a single Subnet-EVM blockchain.
var _ = ginkgo.BeforeSuite(func() {
// Define the Relayer before and after suite functions.
var _ = ginkgo.BeforeSuite(setupSuite)

var _ = ginkgo.AfterSuite(teleporterTestUtils.TearDownNetwork)

// Sets up the warp-enabled network and deploys the teleporter contract to each of the subnets
func setupSuite() {
teleporterTestUtils.SetupNetwork(warpGenesisFile)
teleporterContractAddress := common.HexToAddress(testUtils.ReadHexTextFile("./tests/utils/UniversalTeleporterMessengerContractAddress.txt"))
teleporterDeployerAddress := common.HexToAddress(testUtils.ReadHexTextFile("./tests/utils/UniversalTeleporterDeployerAddress.txt"))
teleporterDeployerTransactionStr := testUtils.ReadHexTextFile("./tests/utils/UniversalTeleporterDeployerTransaction.txt")
teleporterDeployerTransaction, err := hex.DecodeString(utils.SanitizeHexString(teleporterDeployerTransactionStr))
Expect(err).Should(BeNil())
teleporterTestUtils.DeployTeleporterContract(teleporterDeployerTransaction, teleporterDeployerAddress, teleporterContractAddress)
})

var _ = ginkgo.AfterSuite(teleporterTestUtils.TearDownNetwork)
}
17 changes: 16 additions & 1 deletion tests/test_basic_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ var _ = ginkgo.Describe("[Relayer E2E]", ginkgo.Ordered, func() {
Expect(err).Should(BeNil())
defer sub.Unsubscribe()

log.Info("Sending sendWarpMessage transaction", "destinationChainID", teleporterTestUtils.BlockchainIDB, "txHash", signedTx.Hash())
log.Info("Sending teleporter transaction", "destinationChainID", teleporterTestUtils.BlockchainIDB, "txHash", signedTx.Hash())
err = teleporterTestUtils.ChainARPCClient.SendTransaction(ctx, signedTx)
Expect(err).Should(BeNil())

Expand All @@ -190,6 +190,13 @@ var _ = ginkgo.Describe("[Relayer E2E]", ginkgo.Ordered, func() {
Expect(err).Should(BeNil())
Expect(receipt.Status).Should(Equal(types.ReceiptStatusSuccessful))

sendCrossChainMessageLog := receipt.Logs[0]
var sendEvent teleporterTestUtils.SendCrossChainMessageEvent
err = teleporter.EVMTeleporterContractABI.UnpackIntoInterface(&sendEvent, "SendCrossChainMessage", sendCrossChainMessageLog.Data)
Expect(err).Should(BeNil())
log.Info(fmt.Sprintf("Sent teleporter message: %#v", sendEvent))
teleporterMessageID := sendEvent.Message.MessageID

// Get the latest block from Subnet B
log.Info("Waiting for new block confirmation")
newHead := <-newHeadsB
Expand Down Expand Up @@ -223,6 +230,14 @@ var _ = ginkgo.Describe("[Relayer E2E]", ginkgo.Ordered, func() {
Expect(err).Should(BeNil())
Expect(receipt.Status).Should(Equal(types.ReceiptStatusSuccessful))

// Check that the transaction emits ReceiveCrossChainMessage
receiveCrossChainMessageLog := receipt.Logs[0]
var receiveEvent teleporterTestUtils.ReceiveCrossChainMessageEvent
err = teleporter.EVMTeleporterContractABI.UnpackIntoInterface(&receiveEvent, "ReceiveCrossChainMessage", receiveCrossChainMessageLog.Data)
Expect(err).Should(BeNil())
log.Info(fmt.Sprintf("Received teleporter message: %#v", receiveEvent))
Expect(receiveEvent.Message.MessageID.Uint64()).Should(Equal(teleporterMessageID.Uint64()))

log.Info("Finished sending warp message, closing down output channel")

// Cancel the command and stop the relayer
Expand Down

0 comments on commit 9fdbdf2

Please sign in to comment.