Skip to content

Commit

Permalink
more renames
Browse files Browse the repository at this point in the history
  • Loading branch information
iansuvak committed Dec 9, 2024
1 parent bb78bc8 commit 6985275
Show file tree
Hide file tree
Showing 11 changed files with 142 additions and 142 deletions.
90 changes: 45 additions & 45 deletions tests/allowed_addresses.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ const numKeys = 4
// Then, checks that each relayer instance is able to properly catch up on missed messages that
// match its particular configuration.
func AllowedAddresses(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) {
subnetAInfo := network.GetPrimaryNetworkInfo()
subnetBInfo, _ := network.GetTwoSubnets()
l1AInfo := network.GetPrimaryNetworkInfo()
l1BInfo, _ := network.GetTwoL1s()
fundedAddress, fundedKey := network.GetFundedAccountInfo()
err := testUtils.ClearRelayerStorage()
Expect(err).Should(BeNil())
Expand All @@ -52,7 +52,7 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
log.Info("Funding relayer address on all subnets")
relayerKey, err := crypto.GenerateKey()
Expect(err).Should(BeNil())
testUtils.FundRelayers(ctx, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, fundedKey, relayerKey)
testUtils.FundRelayers(ctx, []interfaces.L1TestInfo{l1AInfo, l1BInfo}, fundedKey, relayerKey)

// Create distinct key/address pairs to be used in the configuration, and fund them
var allowedKeys []*ecdsa.PrivateKey
Expand All @@ -63,7 +63,7 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
allowedKey, err := crypto.GenerateKey()
Expect(err).Should(BeNil())
allowedAddress := crypto.PubkeyToAddress(allowedKey.PublicKey)
testUtils.FundRelayers(ctx, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, fundedKey, allowedKey)
testUtils.FundRelayers(ctx, []interfaces.L1TestInfo{l1AInfo, l1BInfo}, fundedKey, allowedKey)
allowedKeys = append(allowedKeys, allowedKey)
allowedAddresses = append(allowedAddresses, allowedAddress)
allowedAddressesStr = append(allowedAddressesStr, allowedAddress.String())
Expand All @@ -85,8 +85,8 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
// Will send from allowed Address 0 -> 0
relayerConfig1 := testUtils.CreateDefaultRelayerConfig(
teleporter,
[]interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo},
[]interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo},
[]interfaces.L1TestInfo{l1AInfo, l1BInfo},
[]interfaces.L1TestInfo{l1AInfo, l1BInfo},
fundedAddress,
relayerKey,
)
Expand All @@ -95,8 +95,8 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
// Will send from allowed Address 1 -> 0
relayerConfig2 := testUtils.CreateDefaultRelayerConfig(
teleporter,
[]interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo},
[]interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo},
[]interfaces.L1TestInfo{l1AInfo, l1BInfo},
[]interfaces.L1TestInfo{l1AInfo, l1BInfo},
fundedAddress,
relayerKey,
)
Expand All @@ -110,18 +110,18 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
// Will send from allowed Address 2 -> 0
relayerConfig3 := testUtils.CreateDefaultRelayerConfig(
teleporter,
[]interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo},
[]interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo},
[]interfaces.L1TestInfo{l1AInfo, l1BInfo},
[]interfaces.L1TestInfo{l1AInfo, l1BInfo},
fundedAddress,
relayerKey,
)
supportedDestinations := []*config.SupportedDestination{
{
BlockchainID: subnetAInfo.BlockchainID.String(),
BlockchainID: l1AInfo.BlockchainID.String(),
Addresses: []string{allowedAddresses[relayer3AllowedDstAddressIdx].String()},
},
{
BlockchainID: subnetBInfo.BlockchainID.String(),
BlockchainID: l1BInfo.BlockchainID.String(),
Addresses: []string{allowedAddresses[relayer3AllowedDstAddressIdx].String()},
},
}
Expand All @@ -136,8 +136,8 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
// Will send from allowed Address 3 -> 0
relayerConfig4 := testUtils.CreateDefaultRelayerConfig(
teleporter,
[]interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo},
[]interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo},
[]interfaces.L1TestInfo{l1AInfo, l1BInfo},
[]interfaces.L1TestInfo{l1AInfo, l1BInfo},
fundedAddress,
relayerKey,
)
Expand All @@ -146,11 +146,11 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
}
supportedDestinations = []*config.SupportedDestination{
{
BlockchainID: subnetAInfo.BlockchainID.String(),
BlockchainID: l1AInfo.BlockchainID.String(),
Addresses: []string{allowedAddresses[relayer4AllowedDstAddressIdx].String()},
},
{
BlockchainID: subnetBInfo.BlockchainID.String(),
BlockchainID: l1BInfo.BlockchainID.String(),
Addresses: []string{allowedAddresses[relayer4AllowedDstAddressIdx].String()},
},
}
Expand Down Expand Up @@ -189,12 +189,12 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
testUtils.RelayBasicMessage(
ctx,
teleporter,
subnetAInfo,
subnetBInfo,
l1AInfo,
l1BInfo,
allowedKeys[generalAllowedAddressIdx],
allowedAddresses[generalAllowedAddressIdx],
)
height1, err := subnetAInfo.RPCClient.BlockNumber(ctx)
height1, err := l1AInfo.RPCClient.BlockNumber(ctx)
Expect(err).Should(BeNil())
// Sleep for some time to make sure the DB is updated
time.Sleep(time.Duration(5*relayerConfig1.DBWriteIntervalSeconds) * time.Second)
Expand All @@ -219,13 +219,13 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
_, _, id := testUtils.SendBasicTeleporterMessage(
ctx,
teleporter,
subnetAInfo,
subnetBInfo,
l1AInfo,
l1BInfo,
allowedKeys[generalAllowedAddressIdx], // not allowed
allowedAddresses[generalAllowedAddressIdx],
)
Consistently(func() bool {
delivered, err := teleporter.TeleporterMessenger(subnetBInfo).MessageReceived(
delivered, err := teleporter.TeleporterMessenger(l1BInfo).MessageReceived(
&bind.CallOpts{}, id,
)
Expect(err).Should(BeNil())
Expand All @@ -236,12 +236,12 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
testUtils.RelayBasicMessage(
ctx,
teleporter,
subnetAInfo,
subnetBInfo,
l1AInfo,
l1BInfo,
allowedKeys[relayer2AllowedSrcAddressIdx],
allowedAddresses[generalAllowedAddressIdx],
)
height2, err := subnetAInfo.RPCClient.BlockNumber(ctx)
height2, err := l1AInfo.RPCClient.BlockNumber(ctx)
Expect(err).Should(BeNil())
// Sleep for some time to make sure the DB is updated
time.Sleep(time.Duration(5*relayerConfig2.DBWriteIntervalSeconds) * time.Second)
Expand All @@ -266,13 +266,13 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
_, _, id = testUtils.SendBasicTeleporterMessage(
ctx,
teleporter,
subnetAInfo,
subnetBInfo,
l1AInfo,
l1BInfo,
allowedKeys[generalAllowedAddressIdx],
allowedAddresses[generalAllowedAddressIdx], // not allowed
)
Consistently(func() bool {
delivered, err := teleporter.TeleporterMessenger(subnetBInfo).MessageReceived(
delivered, err := teleporter.TeleporterMessenger(l1BInfo).MessageReceived(
&bind.CallOpts{}, id,
)
Expect(err).Should(BeNil())
Expand All @@ -283,12 +283,12 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
testUtils.RelayBasicMessage(
ctx,
teleporter,
subnetAInfo,
subnetBInfo,
l1AInfo,
l1BInfo,
allowedKeys[generalAllowedAddressIdx],
allowedAddresses[relayer3AllowedDstAddressIdx],
)
height3, err := subnetAInfo.RPCClient.BlockNumber(ctx)
height3, err := l1AInfo.RPCClient.BlockNumber(ctx)
Expect(err).Should(BeNil())
// Sleep for some time to make sure the DB is updated
time.Sleep(time.Duration(5*relayerConfig3.DBWriteIntervalSeconds) * time.Second)
Expand All @@ -312,13 +312,13 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
_, _, id = testUtils.SendBasicTeleporterMessage(
ctx,
teleporter,
subnetAInfo,
subnetBInfo,
l1AInfo,
l1BInfo,
allowedKeys[generalAllowedAddressIdx], // not allowed
allowedAddresses[generalAllowedAddressIdx],
)
Consistently(func() bool {
delivered, err := teleporter.TeleporterMessenger(subnetBInfo).MessageReceived(
delivered, err := teleporter.TeleporterMessenger(l1BInfo).MessageReceived(
&bind.CallOpts{}, id,
)
Expect(err).Should(BeNil())
Expand All @@ -329,12 +329,12 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter
testUtils.RelayBasicMessage(
ctx,
teleporter,
subnetAInfo,
subnetBInfo,
l1AInfo,
l1BInfo,
allowedKeys[relayer4AllowedSrcAddressIdx],
allowedAddresses[relayer4AllowedDstAddressIdx],
)
height4, err := subnetAInfo.RPCClient.BlockNumber(ctx)
height4, err := l1AInfo.RPCClient.BlockNumber(ctx)
Expect(err).Should(BeNil())
// Sleep for some time to make sure the DB is updated
time.Sleep(time.Duration(5*relayerConfig4.DBWriteIntervalSeconds) * time.Second)
Expand All @@ -346,26 +346,26 @@ func AllowedAddresses(network *network.LocalNetwork, teleporter utils.Teleporter

// Create relayer keys that allow all source and destination addresses
relayerID1 := database.NewRelayerID(
subnetAInfo.BlockchainID,
subnetBInfo.BlockchainID,
l1AInfo.BlockchainID,
l1BInfo.BlockchainID,
database.AllAllowedAddress,
database.AllAllowedAddress,
)
relayerID2 := database.NewRelayerID(
subnetAInfo.BlockchainID,
subnetBInfo.BlockchainID,
l1AInfo.BlockchainID,
l1BInfo.BlockchainID,
allowedAddresses[relayer2AllowedSrcAddressIdx],
database.AllAllowedAddress,
)
relayerID3 := database.NewRelayerID(
subnetAInfo.BlockchainID,
subnetBInfo.BlockchainID,
l1AInfo.BlockchainID,
l1BInfo.BlockchainID,
database.AllAllowedAddress,
allowedAddresses[relayer3AllowedDstAddressIdx],
)
relayerID4 := database.NewRelayerID(
subnetAInfo.BlockchainID,
subnetBInfo.BlockchainID,
l1AInfo.BlockchainID,
l1BInfo.BlockchainID,
allowedAddresses[relayer4AllowedSrcAddressIdx],
allowedAddresses[relayer4AllowedDstAddressIdx],
)
Expand Down
32 changes: 16 additions & 16 deletions tests/basic_relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import (
// - Relaying an already delivered message
// - Setting ProcessHistoricalBlocksFromHeight in config
func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestInfo) {
subnetAInfo := network.GetPrimaryNetworkInfo()
subnetBInfo, _ := network.GetTwoSubnets()
l1AInfo := network.GetPrimaryNetworkInfo()
l1BInfo, _ := network.GetTwoL1s()
fundedAddress, fundedKey := network.GetFundedAccountInfo()
err := testUtils.ClearRelayerStorage()
Expect(err).Should(BeNil())
Expand All @@ -40,15 +40,15 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn
log.Info("Funding relayer address on all subnets")
relayerKey, err := crypto.GenerateKey()
Expect(err).Should(BeNil())
testUtils.FundRelayers(ctx, []interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo}, fundedKey, relayerKey)
testUtils.FundRelayers(ctx, []interfaces.L1TestInfo{l1AInfo, l1BInfo}, fundedKey, relayerKey)

//
// Set up relayer config
//
relayerConfig := testUtils.CreateDefaultRelayerConfig(
teleporter,
[]interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo},
[]interfaces.SubnetTestInfo{subnetAInfo, subnetBInfo},
[]interfaces.L1TestInfo{l1AInfo, l1BInfo},
[]interfaces.L1TestInfo{l1AInfo, l1BInfo},
fundedAddress,
relayerKey,
)
Expand Down Expand Up @@ -80,8 +80,8 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn
testUtils.RelayBasicMessage(
ctx,
teleporter,
subnetAInfo,
subnetBInfo,
l1AInfo,
l1BInfo,
fundedKey,
fundedAddress,
)
Expand All @@ -93,8 +93,8 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn
testUtils.RelayBasicMessage(
ctx,
teleporter,
subnetBInfo,
subnetAInfo,
l1BInfo,
l1AInfo,
fundedKey,
fundedAddress,
)
Expand Down Expand Up @@ -124,14 +124,14 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn

// Create relayer keys that allow all source and destination addresses
relayerIDA := database.CalculateRelayerID(
subnetAInfo.BlockchainID,
subnetBInfo.BlockchainID,
l1AInfo.BlockchainID,
l1BInfo.BlockchainID,
database.AllAllowedAddress,
database.AllAllowedAddress,
)
relayerIDB := database.CalculateRelayerID(
subnetBInfo.BlockchainID,
subnetAInfo.BlockchainID,
l1BInfo.BlockchainID,
l1AInfo.BlockchainID,
database.AllAllowedAddress,
database.AllAllowedAddress,
)
Expand All @@ -143,7 +143,7 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn

// Subscribe to the destination chain
newHeadsB := make(chan *types.Header, 10)
sub, err := subnetBInfo.WSClient.SubscribeNewHead(ctx, newHeadsB)
sub, err := l1BInfo.WSClient.SubscribeNewHead(ctx, newHeadsB)
Expect(err).Should(BeNil())
defer sub.Unsubscribe()

Expand Down Expand Up @@ -174,8 +174,8 @@ func BasicRelay(network *network.LocalNetwork, teleporter utils.TeleporterTestIn
testUtils.TriggerProcessMissedBlocks(
ctx,
teleporter,
subnetAInfo,
subnetBInfo,
l1AInfo,
l1BInfo,
relayerCleanup,
relayerConfig,
fundedAddress,
Expand Down
Loading

0 comments on commit 6985275

Please sign in to comment.