Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify local network struct #639

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tests/flows/governance/validator_set_sig.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {
// ************************************************************************************************

// Execute the ValidatorSetSig executeCall and wait for acceptance
receipt := network.ExecuteValidatorSetSigCallAndVerify(
receipt := utils.ExecuteValidatorSetSigCallAndVerify(
ctx,
subnetB,
subnetA,
Expand All @@ -172,7 +172,7 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {

// Resend the same message again and it should fail due to nonce being consumed

_ = network.ExecuteValidatorSetSigCallAndVerify(
_ = utils.ExecuteValidatorSetSigCallAndVerify(
ctx,
subnetB,
subnetA,
Expand All @@ -188,7 +188,7 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {
Expect(endingBalance).Should(Equal(big.NewInt(100)))

// Send another valid transaction with the incremented nonce
receipt2 := network.ExecuteValidatorSetSigCallAndVerify(
receipt2 := utils.ExecuteValidatorSetSigCallAndVerify(
ctx,
subnetB,
subnetA,
Expand Down Expand Up @@ -219,7 +219,7 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {

// Send the third transaction where the validatorSetSig contract expects validator signatures
// from the same chain that it is deployed on.
receipt3 := network.ExecuteValidatorSetSigCallAndVerify(
receipt3 := utils.ExecuteValidatorSetSigCallAndVerify(
ctx,
subnetB,
subnetB,
Expand Down
5 changes: 2 additions & 3 deletions tests/flows/ictt/erc20_home_erc20_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
erc20tokenremote "github.com/ava-labs/teleporter/abi-bindings/go/ictt/TokenRemote/ERC20TokenRemote"
localnetwork "github.com/ava-labs/teleporter/tests/network"
"github.com/ava-labs/teleporter/tests/utils"
teleporterUtils "github.com/ava-labs/teleporter/tests/utils"
"github.com/ethereum/go-ethereum/crypto"
. "github.com/onsi/gomega"
)
Expand Down Expand Up @@ -135,7 +134,7 @@ func ERC20TokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, teleport

// Transfer back to home chain
// Fund recipient with gas tokens on subnet A
teleporterUtils.SendNativeTransfer(
utils.SendNativeTransfer(
ctx,
subnetAInfo,
fundedKey,
Expand All @@ -158,7 +157,7 @@ func ERC20TokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, teleport
erc20TokenRemote,
erc20TokenRemoteAddress,
inputB,
teleporterUtils.BigIntSub(transferredAmount, inputB.PrimaryFee),
utils.BigIntSub(transferredAmount, inputB.PrimaryFee),
recipientKey,
)

Expand Down
7 changes: 3 additions & 4 deletions tests/flows/ictt/native_home_erc20_remote.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
erc20tokenremote "github.com/ava-labs/teleporter/abi-bindings/go/ictt/TokenRemote/ERC20TokenRemote"
localnetwork "github.com/ava-labs/teleporter/tests/network"
"github.com/ava-labs/teleporter/tests/utils"
teleporterUtils "github.com/ava-labs/teleporter/tests/utils"
"github.com/ethereum/go-ethereum/crypto"
. "github.com/onsi/gomega"
)
Expand Down Expand Up @@ -131,7 +130,7 @@ func NativeTokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, telepor
Expect(balance).Should(Equal(transferredAmount))

// Fund recipient with gas tokens on subnet A
teleporterUtils.SendNativeTransfer(
utils.SendNativeTransfer(
ctx,
subnetAInfo,
fundedKey,
Expand All @@ -155,7 +154,7 @@ func NativeTokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, telepor
erc20TokenRemote,
erc20TokenRemoteAddress,
inputA,
teleporterUtils.BigIntSub(transferredAmount, inputA.PrimaryFee),
utils.BigIntSub(transferredAmount, inputA.PrimaryFee),
recipientKey,
)

Expand All @@ -177,5 +176,5 @@ func NativeTokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, telepor
transferredAmount,
)

teleporterUtils.CheckBalance(ctx, recipientAddress, transferredAmount, cChainInfo.RPCClient)
utils.CheckBalance(ctx, recipientAddress, transferredAmount, cChainInfo.RPCClient)
}
3 changes: 1 addition & 2 deletions tests/flows/ictt/native_home_erc20_remote_multihop.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
nativetokenhome "github.com/ava-labs/teleporter/abi-bindings/go/ictt/TokenHome/NativeTokenHome"
localnetwork "github.com/ava-labs/teleporter/tests/network"
"github.com/ava-labs/teleporter/tests/utils"
teleporterUtils "github.com/ava-labs/teleporter/tests/utils"
"github.com/ethereum/go-ethereum/crypto"

. "github.com/onsi/gomega"
Expand Down Expand Up @@ -128,7 +127,7 @@ func NativeTokenHomeERC20TokenRemoteMultiHop(network *localnetwork.LocalNetwork,
nativeTokenHomeAddress,
wavax,
input,
teleporterUtils.BigIntSub(amount, input.PrimaryFee),
utils.BigIntSub(amount, input.PrimaryFee),
fundedKey,
)

Expand Down
13 changes: 6 additions & 7 deletions tests/flows/ictt/transparent_proxy_upgradeability.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
erc20tokenremote "github.com/ava-labs/teleporter/abi-bindings/go/ictt/TokenRemote/ERC20TokenRemote"
localnetwork "github.com/ava-labs/teleporter/tests/network"
"github.com/ava-labs/teleporter/tests/utils"
teleporterUtils "github.com/ava-labs/teleporter/tests/utils"
"github.com/ethereum/go-ethereum/crypto"
. "github.com/onsi/gomega"
)
Expand Down Expand Up @@ -60,7 +59,7 @@ func TransparentUpgradeableProxy(network *localnetwork.LocalNetwork, teleporter
uint8(1),
)
Expect(err).Should(BeNil())
teleporterUtils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())
utils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())

// Deploy a TransparentUpgradeableProxy contract on primary network for the ERC20TokenHome logic contract
erc20TokenHomeAddress, proxyAdmin, erc20TokenHome := utils.DeployTransparentUpgradeableProxy(
Expand All @@ -80,7 +79,7 @@ func TransparentUpgradeableProxy(network *localnetwork.LocalNetwork, teleporter
tokenDecimals,
)
Expect(err).Should(BeNil())
teleporterUtils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())
utils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())

// Deploy the ERC20TokenRemote contract on Subnet A
erc20TokenRemoteAddress, erc20TokenRemote := utils.DeployERC20TokenRemote(
Expand Down Expand Up @@ -165,15 +164,15 @@ func TransparentUpgradeableProxy(network *localnetwork.LocalNetwork, teleporter
uint8(1),
)
Expect(err).Should(BeNil())
teleporterUtils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())
utils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())

// Upgrade the TransparentUpgradeableProxy contract to use the new logic contract
tx, err = proxyAdmin.UpgradeAndCall(opts, erc20TokenHomeAddress, newLogic, []byte{})
Expect(err).Should(BeNil())
teleporterUtils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())
utils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())

// Send a transfer from Subnet A back to primary network
teleporterUtils.SendNativeTransfer(
utils.SendNativeTransfer(
ctx,
subnetAInfo,
fundedKey,
Expand All @@ -196,7 +195,7 @@ func TransparentUpgradeableProxy(network *localnetwork.LocalNetwork, teleporter
erc20TokenRemote,
erc20TokenRemoteAddress,
inputB,
teleporterUtils.BigIntSub(transferredAmount, inputB.PrimaryFee),
utils.BigIntSub(transferredAmount, inputB.PrimaryFee),
recipientKey,
)

Expand Down
2 changes: 1 addition & 1 deletion tests/flows/teleporter/basic_send_receive.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func BasicSendReceive(network *localnetwork.LocalNetwork, teleporter utils.Telep
// Clear the receipt queue from Subnet B -> Subnet A to have a clean slate for the test flow.
// This is only done if the test non-external networks because external networks may have
// an arbitrarily high number of receipts to be cleared from a given queue from unrelated messages.
network.ClearReceiptQueue(ctx, teleporter, fundedKey, subnetBInfo, subnetAInfo)
teleporter.ClearReceiptQueue(ctx, fundedKey, subnetBInfo, subnetAInfo)

feeAmount := big.NewInt(1)
feeTokenAddress, feeToken := utils.DeployExampleERC20(
Expand Down
6 changes: 2 additions & 4 deletions tests/flows/teleporter/registry/pause_teleporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,8 @@ func PauseTeleporter(network *localnetwork.LocalNetwork, teleporter utils.Telepo
Expect(isPaused).Should(BeTrue())

// Send a message from subnet A to subnet B, which should fail
network.SendExampleCrossChainMessageAndVerify(
teleporter.SendExampleCrossChainMessageAndVerify(
ctx,
teleporter,
subnetAInfo,
testMessengerA,
subnetBInfo,
Expand All @@ -78,9 +77,8 @@ func PauseTeleporter(network *localnetwork.LocalNetwork, teleporter utils.Telepo
Expect(isPaused).Should(BeFalse())

// Send a message from subnet A to subnet B again, which should now succeed
network.SendExampleCrossChainMessageAndVerify(
teleporter.SendExampleCrossChainMessageAndVerify(
ctx,
teleporter,
subnetAInfo,
testMessengerA,
subnetBInfo,
Expand Down
23 changes: 8 additions & 15 deletions tests/flows/teleporter/registry/teleporter_registry.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel
// Deploy the new version of Teleporter to both chains
var newTeleporterAddress common.Address
for _, subnet := range network.GetAllSubnetsInfo() {
newTeleporterAddress = utils.DeployNewTeleporterVersion(ctx, teleporter, subnet, fundedKey, teleporterByteCodeFile)
newTeleporterAddress = teleporter.DeployNewTeleporterVersion(ctx, subnet, fundedKey, teleporterByteCodeFile)
}

networkID := network.GetNetworkID()
Expand Down Expand Up @@ -92,9 +92,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel
network.RestartNodes(restartCtx, nil)

// Call addProtocolVersion on subnetB to register the new Teleporter version
network.AddProtocolVersionAndWaitForAcceptance(
teleporter.AddProtocolVersionAndWaitForAcceptance(
ctx,
teleporter,
subnetBInfo,
newTeleporterAddress,
fundedKey,
Expand All @@ -103,9 +102,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel

// Send a message using old Teleporter version to test messenger using new Teleporter version.
// Message should be received successfully since we haven't updated mininum Teleporter version yet.
network.SendExampleCrossChainMessageAndVerify(
teleporter.SendExampleCrossChainMessageAndVerify(
ctx,
teleporter,
cChainInfo,
testMessengerC,
subnetBInfo,
Expand Down Expand Up @@ -140,9 +138,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel

// Send a message using old Teleporter version to test messenger with updated minimum Teleporter version.
// Message should fail since we updated minimum Teleporter version.
network.SendExampleCrossChainMessageAndVerify(
teleporter.SendExampleCrossChainMessageAndVerify(
ctx,
teleporter,
cChainInfo,
testMessengerC,
subnetBInfo,
Expand All @@ -159,9 +156,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel
teleporter.InitializeBlockchainID(subnet, fundedKey)
}

network.SendExampleCrossChainMessageAndVerify(
teleporter.SendExampleCrossChainMessageAndVerify(
ctx,
teleporter,
subnetBInfo,
testMessengerB,
cChainInfo,
Expand All @@ -173,9 +169,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel
)

// Call addProtocolVersion on subnetA to register the new Teleporter version
network.AddProtocolVersionAndWaitForAcceptance(
teleporter.AddProtocolVersionAndWaitForAcceptance(
ctx,
teleporter,
cChainInfo,
newTeleporterAddress,
fundedKey,
Expand All @@ -184,9 +179,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel

// Send a message from A->B, which previously failed, but now using the new Teleporter version.
// Teleporter versions should match, so message should be received successfully.
network.SendExampleCrossChainMessageAndVerify(
teleporter.SendExampleCrossChainMessageAndVerify(
ctx,
teleporter,
subnetBInfo,
testMessengerB,
cChainInfo,
Expand All @@ -199,9 +193,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel

// To make sure all subnets are using the same Teleporter version, call addProtocolVersion on subnetA
// to register the new Teleporter version
network.AddProtocolVersionAndWaitForAcceptance(
teleporter.AddProtocolVersionAndWaitForAcceptance(
ctx,
teleporter,
subnetAInfo,
newTeleporterAddress,
fundedKey,
Expand Down
2 changes: 1 addition & 1 deletion tests/flows/teleporter/send_specific_receipts.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func SendSpecificReceipts(network *localnetwork.LocalNetwork, teleporter utils.T
ctx := context.Background()

// Clear the receipt queue from Subnet B -> Subnet A to have a clean slate for the test flow.
network.ClearReceiptQueue(ctx, teleporter, fundedKey, subnetBInfo, subnetAInfo)
teleporter.ClearReceiptQueue(ctx, fundedKey, subnetBInfo, subnetAInfo)

// Use mock token as the fee token
mockTokenAddress, mockToken := utils.DeployExampleERC20(
Expand Down
1 change: 0 additions & 1 deletion tests/interfaces/subnet_test_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (

// Tracks information about a test subnet used for executing tests against.
type SubnetTestInfo struct {
SubnetName string
SubnetID ids.ID
BlockchainID ids.ID
NodeURIs []string
Expand Down
Loading
Loading