From 75ecd7cfff847da93a30207823069a16d991a583 Mon Sep 17 00:00:00 2001 From: cam-schultz Date: Mon, 14 Oct 2024 17:40:49 -0500 Subject: [PATCH] lint --- tests/flows/teleporter/add_fee_amount.go | 14 +++++- .../deliver_to_nonexistent_contract.go | 5 +- tests/flows/teleporter/insufficient_gas.go | 10 +++- .../teleporter/relayer_modifies_message.go | 5 +- .../teleporter/resubmit_altered_message.go | 5 +- .../teleporter/retry_successful_execution.go | 12 +++-- .../teleporter/send_specific_receipts.go | 36 +++++++++++++-- tests/flows/teleporter/validator_churn.go | 5 +- tests/local/network.go | 1 - tests/utils/teleporter.go | 46 ++++++++++++++----- 10 files changed, 112 insertions(+), 27 deletions(-) diff --git a/tests/flows/teleporter/add_fee_amount.go b/tests/flows/teleporter/add_fee_amount.go index 5f8c9e33c..abf6c7932 100644 --- a/tests/flows/teleporter/add_fee_amount.go +++ b/tests/flows/teleporter/add_fee_amount.go @@ -72,7 +72,14 @@ func AddFeeAmount(network interfaces.Network, teleporter utils.TeleporterTestInf ) // Relay message from Subnet A to Subnet B - deliveryReceipt := teleporter.RelayTeleporterMessage(ctx, sendCrossChainMsgReceipt, subnetAInfo, subnetBInfo, true, fundedKey) + deliveryReceipt := teleporter.RelayTeleporterMessage( + ctx, + sendCrossChainMsgReceipt, + subnetAInfo, + subnetBInfo, + true, + fundedKey, + ) receiveEvent, err := utils.GetEventFromLogs( deliveryReceipt.Logs, teleporter.TeleporterMessenger(subnetBInfo).ParseReceiveCrossChainMessage) @@ -108,7 +115,10 @@ func AddFeeAmount(network interfaces.Network, teleporter utils.TeleporterTestInf teleporter.RelayTeleporterMessage(ctx, sendSpecificReceiptsReceipt, subnetBInfo, subnetAInfo, true, fundedKey) // Check message delivered - delivered, err = teleporter.TeleporterMessenger(subnetAInfo).MessageReceived(&bind.CallOpts{}, sendSpecificReceiptsMessageID) + delivered, err = teleporter.TeleporterMessenger(subnetAInfo).MessageReceived( + &bind.CallOpts{}, + sendSpecificReceiptsMessageID, + ) Expect(err).Should(BeNil()) Expect(delivered).Should(BeTrue()) diff --git a/tests/flows/teleporter/deliver_to_nonexistent_contract.go b/tests/flows/teleporter/deliver_to_nonexistent_contract.go index abc7b483d..e5787f999 100644 --- a/tests/flows/teleporter/deliver_to_nonexistent_contract.go +++ b/tests/flows/teleporter/deliver_to_nonexistent_contract.go @@ -75,7 +75,10 @@ func DeliverToNonExistentContract(network interfaces.Network, teleporter utils.T // Wait for the transaction to be mined receipt := utils.WaitForTransactionSuccess(ctx, subnetAInfo, tx.Hash()) - sendEvent, err := utils.GetEventFromLogs(receipt.Logs, teleporter.TeleporterMessenger(subnetAInfo).ParseSendCrossChainMessage) + sendEvent, err := utils.GetEventFromLogs( + receipt.Logs, + teleporter.TeleporterMessenger(subnetAInfo).ParseSendCrossChainMessage, + ) Expect(err).Should(BeNil()) Expect(sendEvent.DestinationBlockchainID[:]).Should(Equal(subnetBInfo.BlockchainID[:])) diff --git a/tests/flows/teleporter/insufficient_gas.go b/tests/flows/teleporter/insufficient_gas.go index f2df271a2..5af9f4ddb 100644 --- a/tests/flows/teleporter/insufficient_gas.go +++ b/tests/flows/teleporter/insufficient_gas.go @@ -46,7 +46,10 @@ func InsufficientGas(network interfaces.Network, teleporter utils.TeleporterTest // Wait for the transaction to be mined receipt := utils.WaitForTransactionSuccess(ctx, subnetAInfo, tx.Hash()) - event, err := utils.GetEventFromLogs(receipt.Logs, teleporter.TeleporterMessenger(subnetAInfo).ParseSendCrossChainMessage) + event, err := utils.GetEventFromLogs( + receipt.Logs, + teleporter.TeleporterMessenger(subnetAInfo).ParseSendCrossChainMessage, + ) Expect(err).Should(BeNil()) Expect(event.DestinationBlockchainID[:]).Should(Equal(subnetBInfo.BlockchainID[:])) @@ -79,7 +82,10 @@ func InsufficientGas(network interfaces.Network, teleporter utils.TeleporterTest failedMessageExecutionEvent.Message, fundedKey, ) - executedEvent, err := utils.GetEventFromLogs(receipt.Logs, teleporter.TeleporterMessenger(subnetBInfo).ParseMessageExecuted) + executedEvent, err := utils.GetEventFromLogs( + receipt.Logs, + teleporter.TeleporterMessenger(subnetBInfo).ParseMessageExecuted, + ) Expect(err).Should(BeNil()) Expect(executedEvent.MessageID[:]).Should(Equal(messageID[:])) Expect(executedEvent.SourceBlockchainID[:]).Should(Equal(subnetAInfo.BlockchainID[:])) diff --git a/tests/flows/teleporter/relayer_modifies_message.go b/tests/flows/teleporter/relayer_modifies_message.go index cadafb5f7..32c1385d4 100644 --- a/tests/flows/teleporter/relayer_modifies_message.go +++ b/tests/flows/teleporter/relayer_modifies_message.go @@ -70,7 +70,10 @@ func relayAlteredMessage( network interfaces.LocalNetwork, ) { // Fetch the Teleporter message from the logs - sendEvent, err := utils.GetEventFromLogs(sourceReceipt.Logs, teleporter.TeleporterMessenger(source).ParseSendCrossChainMessage) + sendEvent, err := utils.GetEventFromLogs( + sourceReceipt.Logs, + teleporter.TeleporterMessenger(source).ParseSendCrossChainMessage, + ) Expect(err).Should(BeNil()) signedWarpMessage := utils.ConstructSignedWarpMessage(ctx, sourceReceipt, source, destination) diff --git a/tests/flows/teleporter/resubmit_altered_message.go b/tests/flows/teleporter/resubmit_altered_message.go index 591393b4c..dcc47c75f 100644 --- a/tests/flows/teleporter/resubmit_altered_message.go +++ b/tests/flows/teleporter/resubmit_altered_message.go @@ -45,7 +45,10 @@ func ResubmitAlteredMessage(network interfaces.Network, teleporter utils.Telepor Expect(delivered).Should(BeTrue()) // Get the Teleporter message from receive event - event, err := utils.GetEventFromLogs(receipt.Logs, teleporter.TeleporterMessenger(subnetBInfo).ParseReceiveCrossChainMessage) + event, err := utils.GetEventFromLogs( + receipt.Logs, + teleporter.TeleporterMessenger(subnetBInfo).ParseReceiveCrossChainMessage, + ) Expect(err).Should(BeNil()) Expect(event.MessageID[:]).Should(Equal(messageID[:])) teleporterMessage := event.Message diff --git a/tests/flows/teleporter/retry_successful_execution.go b/tests/flows/teleporter/retry_successful_execution.go index 1a3df6895..a90cb5305 100644 --- a/tests/flows/teleporter/retry_successful_execution.go +++ b/tests/flows/teleporter/retry_successful_execution.go @@ -56,7 +56,10 @@ func RetrySuccessfulExecution(network interfaces.Network, teleporter utils.Telep // Wait for the transaction to be mined receipt := utils.WaitForTransactionSuccess(ctx, subnetAInfo, tx.Hash()) - event, err := utils.GetEventFromLogs(receipt.Logs, teleporter.TeleporterMessenger(subnetAInfo).ParseSendCrossChainMessage) + event, err := utils.GetEventFromLogs( + receipt.Logs, + teleporter.TeleporterMessenger(subnetAInfo).ParseSendCrossChainMessage, + ) Expect(err).Should(BeNil()) Expect(event.DestinationBlockchainID[:]).Should(Equal(subnetBInfo.BlockchainID[:])) @@ -92,8 +95,11 @@ func RetrySuccessfulExecution(network interfaces.Network, teleporter utils.Telep // optsB, err := bind.NewKeyedTransactorWithChainID(fundedKey, subnetBInfo.EVMChainID) Expect(err).Should(BeNil()) - tx, err = - teleporter.TeleporterMessenger(subnetBInfo).RetryMessageExecution(optsB, subnetAInfo.BlockchainID, deliveredTeleporterMessage) + tx, err = teleporter.TeleporterMessenger(subnetBInfo).RetryMessageExecution( + optsB, + subnetAInfo.BlockchainID, + deliveredTeleporterMessage, + ) Expect(err).Should(Not(BeNil())) Expect(tx).Should(BeNil()) } diff --git a/tests/flows/teleporter/send_specific_receipts.go b/tests/flows/teleporter/send_specific_receipts.go index 5a75f3487..baf958f9c 100644 --- a/tests/flows/teleporter/send_specific_receipts.go +++ b/tests/flows/teleporter/send_specific_receipts.go @@ -64,7 +64,14 @@ func SendSpecificReceipts(network interfaces.Network, teleporter utils.Teleporte ctx, teleporter.TeleporterMessenger(subnetAInfo), subnetAInfo, subnetBInfo, sendCrossChainMessageInput, fundedKey) // Relay the message from SubnetA to SubnetB - deliveryReceipt1 := teleporter.RelayTeleporterMessage(ctx, sendCrossChainMsgReceipt, subnetAInfo, subnetBInfo, true, fundedKey) + deliveryReceipt1 := teleporter.RelayTeleporterMessage( + ctx, + sendCrossChainMsgReceipt, + subnetAInfo, + subnetBInfo, + true, + fundedKey, + ) receiveEvent1, err := utils.GetEventFromLogs( deliveryReceipt1.Logs, teleporter.TeleporterMessenger(subnetBInfo).ParseReceiveCrossChainMessage) @@ -81,7 +88,14 @@ func SendSpecificReceipts(network interfaces.Network, teleporter utils.Teleporte ctx, teleporter.TeleporterMessenger(subnetAInfo), subnetAInfo, subnetBInfo, sendCrossChainMessageInput, fundedKey) // Relay the message from SubnetA to SubnetB - deliveryReceipt2 := teleporter.RelayTeleporterMessage(ctx, sendCrossChainMsgReceipt, subnetAInfo, subnetBInfo, true, fundedKey) + deliveryReceipt2 := teleporter.RelayTeleporterMessage( + ctx, + sendCrossChainMsgReceipt, + subnetAInfo, + subnetBInfo, + true, + fundedKey, + ) receiveEvent2, err := utils.GetEventFromLogs( deliveryReceipt2.Logs, teleporter.TeleporterMessenger(subnetBInfo).ParseReceiveCrossChainMessage) @@ -123,7 +137,14 @@ func SendSpecificReceipts(network interfaces.Network, teleporter utils.Teleporte // Check the reward amounts. // Even on external networks, the relayer should only have the expected fee amount // for this asset because the asset contract was newly deployed by this test. - checkExpectedRewardAmounts(teleporter, subnetAInfo, receiveEvent1, receiveEvent2, mockTokenAddress, relayerFeePerMessage) + checkExpectedRewardAmounts( + teleporter, + subnetAInfo, + receiveEvent1, + receiveEvent2, + mockTokenAddress, + relayerFeePerMessage, + ) // If the network is internal to the test application, send a message from Subnet B to Subnet A to trigger // the "regular" method of delivering receipts. The next message from B->A will contain the same receipts @@ -181,7 +202,14 @@ func SendSpecificReceipts(network interfaces.Network, teleporter utils.Teleporte receiveEvent.Message.Receipts)).Should(BeTrue()) // Check the reward amount remains the same - checkExpectedRewardAmounts(teleporter, subnetAInfo, receiveEvent1, receiveEvent2, mockTokenAddress, relayerFeePerMessage) + checkExpectedRewardAmounts( + teleporter, + subnetAInfo, + receiveEvent1, + receiveEvent2, + mockTokenAddress, + relayerFeePerMessage, + ) } } diff --git a/tests/flows/teleporter/validator_churn.go b/tests/flows/teleporter/validator_churn.go index 8541feee7..da7ec7016 100644 --- a/tests/flows/teleporter/validator_churn.go +++ b/tests/flows/teleporter/validator_churn.go @@ -49,7 +49,10 @@ func ValidatorChurn(network interfaces.LocalNetwork, teleporter utils.Teleporter fundedKey, ) - sendEvent, err := utils.GetEventFromLogs(receipt.Logs, teleporter.TeleporterMessenger(subnetAInfo).ParseSendCrossChainMessage) + sendEvent, err := utils.GetEventFromLogs( + receipt.Logs, + teleporter.TeleporterMessenger(subnetAInfo).ParseSendCrossChainMessage, + ) Expect(err).Should(BeNil()) sentTeleporterMessage := sendEvent.Message diff --git a/tests/local/network.go b/tests/local/network.go index f1797f318..2839b082c 100644 --- a/tests/local/network.go +++ b/tests/local/network.go @@ -217,7 +217,6 @@ func (n *LocalNetwork) setPrimaryNetworkValues() { n.primaryNetworkInfo.WSClient = chainWSClient n.primaryNetworkInfo.RPCClient = chainRPCClient n.primaryNetworkInfo.EVMChainID = chainIDInt - } func (n *LocalNetwork) setSubnetValues(subnet *tmpnet.Subnet) { diff --git a/tests/utils/teleporter.go b/tests/utils/teleporter.go index 3bda07938..3c92413b7 100644 --- a/tests/utils/teleporter.go +++ b/tests/utils/teleporter.go @@ -52,7 +52,9 @@ func NewTeleporterTestInfo(subnets []interfaces.SubnetTestInfo) TeleporterTestIn return t } -func (t TeleporterTestInfo) TeleporterMessenger(subnet interfaces.SubnetTestInfo) *teleportermessenger.TeleporterMessenger { +func (t TeleporterTestInfo) TeleporterMessenger( + subnet interfaces.SubnetTestInfo, +) *teleportermessenger.TeleporterMessenger { return t[subnet.BlockchainID].TeleporterMessenger } @@ -60,7 +62,9 @@ func (t TeleporterTestInfo) TeleporterMessengerAddress(subnet interfaces.SubnetT return t[subnet.BlockchainID].TeleporterMessengerAddress } -func (t TeleporterTestInfo) TeleporterRegistry(subnet interfaces.SubnetTestInfo) *teleporterregistry.TeleporterRegistry { +func (t TeleporterTestInfo) TeleporterRegistry( + subnet interfaces.SubnetTestInfo, +) *teleporterregistry.TeleporterRegistry { return t[subnet.BlockchainID].TeleporterRegistry } @@ -428,12 +432,18 @@ func AddProtocolVersionAndWaitForAcceptance( // Wait for tx to be accepted, and verify events emitted receipt := SendTransactionAndWaitForSuccess(ctx, subnet, signedTx) - addProtocolVersionEvent, err := GetEventFromLogs(receipt.Logs, sourceTeleporterInfo.TeleporterRegistry.ParseAddProtocolVersion) + addProtocolVersionEvent, err := GetEventFromLogs( + receipt.Logs, + sourceTeleporterInfo.TeleporterRegistry.ParseAddProtocolVersion, + ) Expect(err).Should(BeNil()) Expect(addProtocolVersionEvent.Version.Cmp(expectedLatestVersion)).Should(Equal(0)) Expect(addProtocolVersionEvent.ProtocolAddress).Should(Equal(newTeleporterAddress)) - versionUpdatedEvent, err := GetEventFromLogs(receipt.Logs, sourceTeleporterInfo.TeleporterRegistry.ParseLatestVersionUpdated) + versionUpdatedEvent, err := GetEventFromLogs( + receipt.Logs, + sourceTeleporterInfo.TeleporterRegistry.ParseLatestVersionUpdated, + ) Expect(err).Should(BeNil()) Expect(versionUpdatedEvent.OldVersion.Cmp(curLatestVersion)).Should(Equal(0)) Expect(versionUpdatedEvent.NewVersion.Cmp(expectedLatestVersion)).Should(Equal(0)) @@ -519,12 +529,18 @@ func ClearReceiptQueue( // Relay message teleporterInfo.RelayTeleporterMessage(ctx, receipt, source, destination, true, fundedKey) - outstandReceiptCount = GetOutstandingReceiptCount(teleporterInfo.TeleporterMessenger(source), destination.BlockchainID) + outstandReceiptCount = GetOutstandingReceiptCount( + teleporterInfo.TeleporterMessenger(source), + destination.BlockchainID, + ) } log.Info("Receipt queue emptied") } -func GetOutstandingReceiptCount(teleporterMessenger *teleportermessenger.TeleporterMessenger, destinationBlockchainID ids.ID) *big.Int { +func GetOutstandingReceiptCount( + teleporterMessenger *teleportermessenger.TeleporterMessenger, + destinationBlockchainID ids.ID, +) *big.Int { size, err := teleporterMessenger.GetReceiptQueueSize(&bind.CallOpts{}, destinationBlockchainID) Expect(err).Should(BeNil()) return size @@ -581,7 +597,10 @@ func SendExampleCrossChainMessageAndVerify( if expectSuccess { // Check that message execution was successful - messageExecutedEvent, err := GetEventFromLogs(receipt.Logs, teleporterInfo.TeleporterMessenger(destination).ParseMessageExecuted) + messageExecutedEvent, err := GetEventFromLogs( + receipt.Logs, + teleporterInfo.TeleporterMessenger(destination).ParseMessageExecuted, + ) Expect(err).Should(BeNil()) Expect(messageExecutedEvent.MessageID[:]).Should(Equal(teleporterMessageID[:])) } else { @@ -764,10 +783,15 @@ func InitOffChainMessageChainConfig( teleporterAddress common.Address, version uint64, ) (*avalancheWarp.UnsignedMessage, string) { - unsignedMessage := CreateOffChainRegistryMessage(networkID, subnet, registryAddress, teleporterregistry.ProtocolRegistryEntry{ - Version: big.NewInt(int64(version)), - ProtocolAddress: teleporterAddress, - }) + unsignedMessage := CreateOffChainRegistryMessage( + networkID, + subnet, + registryAddress, + teleporterregistry.ProtocolRegistryEntry{ + Version: big.NewInt(int64(version)), + ProtocolAddress: teleporterAddress, + }, + ) log.Info("Adding off-chain message to Warp chain config", "messageID", unsignedMessage.ID(), "blockchainID", subnet.BlockchainID.String(),