Skip to content

Commit fa9d24a

Browse files
authored
Merge pull request #639 from ava-labs/simplify-local-network-struct
Simplify local network struct
2 parents df7a170 + e9c4f76 commit fa9d24a

12 files changed

+271
-548
lines changed

tests/flows/governance/validator_set_sig.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {
150150
// ************************************************************************************************
151151

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

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

175-
_ = network.ExecuteValidatorSetSigCallAndVerify(
175+
_ = utils.ExecuteValidatorSetSigCallAndVerify(
176176
ctx,
177177
subnetB,
178178
subnetA,
@@ -188,7 +188,7 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {
188188
Expect(endingBalance).Should(Equal(big.NewInt(100)))
189189

190190
// Send another valid transaction with the incremented nonce
191-
receipt2 := network.ExecuteValidatorSetSigCallAndVerify(
191+
receipt2 := utils.ExecuteValidatorSetSigCallAndVerify(
192192
ctx,
193193
subnetB,
194194
subnetA,
@@ -219,7 +219,7 @@ func ValidatorSetSig(network *localnetwork.LocalNetwork) {
219219

220220
// Send the third transaction where the validatorSetSig contract expects validator signatures
221221
// from the same chain that it is deployed on.
222-
receipt3 := network.ExecuteValidatorSetSigCallAndVerify(
222+
receipt3 := utils.ExecuteValidatorSetSigCallAndVerify(
223223
ctx,
224224
subnetB,
225225
subnetB,

tests/flows/ictt/erc20_home_erc20_remote.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
erc20tokenremote "github.com/ava-labs/teleporter/abi-bindings/go/ictt/TokenRemote/ERC20TokenRemote"
1010
localnetwork "github.com/ava-labs/teleporter/tests/network"
1111
"github.com/ava-labs/teleporter/tests/utils"
12-
teleporterUtils "github.com/ava-labs/teleporter/tests/utils"
1312
"github.com/ethereum/go-ethereum/crypto"
1413
. "github.com/onsi/gomega"
1514
)
@@ -135,7 +134,7 @@ func ERC20TokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, teleport
135134

136135
// Transfer back to home chain
137136
// Fund recipient with gas tokens on subnet A
138-
teleporterUtils.SendNativeTransfer(
137+
utils.SendNativeTransfer(
139138
ctx,
140139
subnetAInfo,
141140
fundedKey,
@@ -158,7 +157,7 @@ func ERC20TokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, teleport
158157
erc20TokenRemote,
159158
erc20TokenRemoteAddress,
160159
inputB,
161-
teleporterUtils.BigIntSub(transferredAmount, inputB.PrimaryFee),
160+
utils.BigIntSub(transferredAmount, inputB.PrimaryFee),
162161
recipientKey,
163162
)
164163

tests/flows/ictt/native_home_erc20_remote.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
erc20tokenremote "github.com/ava-labs/teleporter/abi-bindings/go/ictt/TokenRemote/ERC20TokenRemote"
1010
localnetwork "github.com/ava-labs/teleporter/tests/network"
1111
"github.com/ava-labs/teleporter/tests/utils"
12-
teleporterUtils "github.com/ava-labs/teleporter/tests/utils"
1312
"github.com/ethereum/go-ethereum/crypto"
1413
. "github.com/onsi/gomega"
1514
)
@@ -131,7 +130,7 @@ func NativeTokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, telepor
131130
Expect(balance).Should(Equal(transferredAmount))
132131

133132
// Fund recipient with gas tokens on subnet A
134-
teleporterUtils.SendNativeTransfer(
133+
utils.SendNativeTransfer(
135134
ctx,
136135
subnetAInfo,
137136
fundedKey,
@@ -155,7 +154,7 @@ func NativeTokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, telepor
155154
erc20TokenRemote,
156155
erc20TokenRemoteAddress,
157156
inputA,
158-
teleporterUtils.BigIntSub(transferredAmount, inputA.PrimaryFee),
157+
utils.BigIntSub(transferredAmount, inputA.PrimaryFee),
159158
recipientKey,
160159
)
161160

@@ -177,5 +176,5 @@ func NativeTokenHomeERC20TokenRemote(network *localnetwork.LocalNetwork, telepor
177176
transferredAmount,
178177
)
179178

180-
teleporterUtils.CheckBalance(ctx, recipientAddress, transferredAmount, cChainInfo.RPCClient)
179+
utils.CheckBalance(ctx, recipientAddress, transferredAmount, cChainInfo.RPCClient)
181180
}

tests/flows/ictt/native_home_erc20_remote_multihop.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
nativetokenhome "github.com/ava-labs/teleporter/abi-bindings/go/ictt/TokenHome/NativeTokenHome"
99
localnetwork "github.com/ava-labs/teleporter/tests/network"
1010
"github.com/ava-labs/teleporter/tests/utils"
11-
teleporterUtils "github.com/ava-labs/teleporter/tests/utils"
1211
"github.com/ethereum/go-ethereum/crypto"
1312

1413
. "github.com/onsi/gomega"
@@ -128,7 +127,7 @@ func NativeTokenHomeERC20TokenRemoteMultiHop(network *localnetwork.LocalNetwork,
128127
nativeTokenHomeAddress,
129128
wavax,
130129
input,
131-
teleporterUtils.BigIntSub(amount, input.PrimaryFee),
130+
utils.BigIntSub(amount, input.PrimaryFee),
132131
fundedKey,
133132
)
134133

tests/flows/ictt/transparent_proxy_upgradeability.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@ import (
1010
erc20tokenremote "github.com/ava-labs/teleporter/abi-bindings/go/ictt/TokenRemote/ERC20TokenRemote"
1111
localnetwork "github.com/ava-labs/teleporter/tests/network"
1212
"github.com/ava-labs/teleporter/tests/utils"
13-
teleporterUtils "github.com/ava-labs/teleporter/tests/utils"
1413
"github.com/ethereum/go-ethereum/crypto"
1514
. "github.com/onsi/gomega"
1615
)
@@ -60,7 +59,7 @@ func TransparentUpgradeableProxy(network *localnetwork.LocalNetwork, teleporter
6059
uint8(1),
6160
)
6261
Expect(err).Should(BeNil())
63-
teleporterUtils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())
62+
utils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())
6463

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

8584
// Deploy the ERC20TokenRemote contract on Subnet A
8685
erc20TokenRemoteAddress, erc20TokenRemote := utils.DeployERC20TokenRemote(
@@ -165,15 +164,15 @@ func TransparentUpgradeableProxy(network *localnetwork.LocalNetwork, teleporter
165164
uint8(1),
166165
)
167166
Expect(err).Should(BeNil())
168-
teleporterUtils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())
167+
utils.WaitForTransactionSuccess(ctx, cChainInfo, tx.Hash())
169168

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

175174
// Send a transfer from Subnet A back to primary network
176-
teleporterUtils.SendNativeTransfer(
175+
utils.SendNativeTransfer(
177176
ctx,
178177
subnetAInfo,
179178
fundedKey,
@@ -196,7 +195,7 @@ func TransparentUpgradeableProxy(network *localnetwork.LocalNetwork, teleporter
196195
erc20TokenRemote,
197196
erc20TokenRemoteAddress,
198197
inputB,
199-
teleporterUtils.BigIntSub(transferredAmount, inputB.PrimaryFee),
198+
utils.BigIntSub(transferredAmount, inputB.PrimaryFee),
200199
recipientKey,
201200
)
202201

tests/flows/teleporter/basic_send_receive.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func BasicSendReceive(network *localnetwork.LocalNetwork, teleporter utils.Telep
2525
// Clear the receipt queue from Subnet B -> Subnet A to have a clean slate for the test flow.
2626
// This is only done if the test non-external networks because external networks may have
2727
// an arbitrarily high number of receipts to be cleared from a given queue from unrelated messages.
28-
network.ClearReceiptQueue(ctx, teleporter, fundedKey, subnetBInfo, subnetAInfo)
28+
teleporter.ClearReceiptQueue(ctx, fundedKey, subnetBInfo, subnetAInfo)
2929

3030
feeAmount := big.NewInt(1)
3131
feeTokenAddress, feeToken := utils.DeployExampleERC20(

tests/flows/teleporter/registry/pause_teleporter.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,8 @@ func PauseTeleporter(network *localnetwork.LocalNetwork, teleporter utils.Telepo
5151
Expect(isPaused).Should(BeTrue())
5252

5353
// Send a message from subnet A to subnet B, which should fail
54-
network.SendExampleCrossChainMessageAndVerify(
54+
teleporter.SendExampleCrossChainMessageAndVerify(
5555
ctx,
56-
teleporter,
5756
subnetAInfo,
5857
testMessengerA,
5958
subnetBInfo,
@@ -78,9 +77,8 @@ func PauseTeleporter(network *localnetwork.LocalNetwork, teleporter utils.Telepo
7877
Expect(isPaused).Should(BeFalse())
7978

8079
// Send a message from subnet A to subnet B again, which should now succeed
81-
network.SendExampleCrossChainMessageAndVerify(
80+
teleporter.SendExampleCrossChainMessageAndVerify(
8281
ctx,
83-
teleporter,
8482
subnetAInfo,
8583
testMessengerA,
8684
subnetBInfo,

tests/flows/teleporter/registry/teleporter_registry.go

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel
5252
// Deploy the new version of Teleporter to both chains
5353
var newTeleporterAddress common.Address
5454
for _, subnet := range network.GetAllSubnetsInfo() {
55-
newTeleporterAddress = utils.DeployNewTeleporterVersion(ctx, teleporter, subnet, fundedKey, teleporterByteCodeFile)
55+
newTeleporterAddress = teleporter.DeployNewTeleporterVersion(ctx, subnet, fundedKey, teleporterByteCodeFile)
5656
}
5757

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

9494
// Call addProtocolVersion on subnetB to register the new Teleporter version
95-
network.AddProtocolVersionAndWaitForAcceptance(
95+
teleporter.AddProtocolVersionAndWaitForAcceptance(
9696
ctx,
97-
teleporter,
9897
subnetBInfo,
9998
newTeleporterAddress,
10099
fundedKey,
@@ -103,9 +102,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel
103102

104103
// Send a message using old Teleporter version to test messenger using new Teleporter version.
105104
// Message should be received successfully since we haven't updated mininum Teleporter version yet.
106-
network.SendExampleCrossChainMessageAndVerify(
105+
teleporter.SendExampleCrossChainMessageAndVerify(
107106
ctx,
108-
teleporter,
109107
cChainInfo,
110108
testMessengerC,
111109
subnetBInfo,
@@ -140,9 +138,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel
140138

141139
// Send a message using old Teleporter version to test messenger with updated minimum Teleporter version.
142140
// Message should fail since we updated minimum Teleporter version.
143-
network.SendExampleCrossChainMessageAndVerify(
141+
teleporter.SendExampleCrossChainMessageAndVerify(
144142
ctx,
145-
teleporter,
146143
cChainInfo,
147144
testMessengerC,
148145
subnetBInfo,
@@ -159,9 +156,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel
159156
teleporter.InitializeBlockchainID(subnet, fundedKey)
160157
}
161158

162-
network.SendExampleCrossChainMessageAndVerify(
159+
teleporter.SendExampleCrossChainMessageAndVerify(
163160
ctx,
164-
teleporter,
165161
subnetBInfo,
166162
testMessengerB,
167163
cChainInfo,
@@ -173,9 +169,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel
173169
)
174170

175171
// Call addProtocolVersion on subnetA to register the new Teleporter version
176-
network.AddProtocolVersionAndWaitForAcceptance(
172+
teleporter.AddProtocolVersionAndWaitForAcceptance(
177173
ctx,
178-
teleporter,
179174
cChainInfo,
180175
newTeleporterAddress,
181176
fundedKey,
@@ -184,9 +179,8 @@ func TeleporterRegistry(network *localnetwork.LocalNetwork, teleporter utils.Tel
184179

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

200194
// To make sure all subnets are using the same Teleporter version, call addProtocolVersion on subnetA
201195
// to register the new Teleporter version
202-
network.AddProtocolVersionAndWaitForAcceptance(
196+
teleporter.AddProtocolVersionAndWaitForAcceptance(
203197
ctx,
204-
teleporter,
205198
subnetAInfo,
206199
newTeleporterAddress,
207200
fundedKey,

tests/flows/teleporter/send_specific_receipts.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func SendSpecificReceipts(network *localnetwork.LocalNetwork, teleporter utils.T
2727
ctx := context.Background()
2828

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

3232
// Use mock token as the fee token
3333
mockTokenAddress, mockToken := utils.DeployExampleERC20(

tests/interfaces/subnet_test_info.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
// Tracks information about a test subnet used for executing tests against.
1111
type SubnetTestInfo struct {
12-
SubnetName string
1312
SubnetID ids.ID
1413
BlockchainID ids.ID
1514
NodeURIs []string

0 commit comments

Comments
 (0)