This repository was archived by the owner on Dec 3, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 43
Expand file tree
/
Copy pathpause_teleporter.go
More file actions
98 lines (85 loc) · 2.77 KB
/
pause_teleporter.go
File metadata and controls
98 lines (85 loc) · 2.77 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
package registry
import (
"context"
localnetwork "github.com/ava-labs/icm-contracts/tests/network"
"github.com/ava-labs/icm-contracts/tests/utils"
"github.com/ava-labs/subnet-evm/accounts/abi/bind"
. "github.com/onsi/gomega"
)
func PauseTeleporter(network *localnetwork.LocalAvalancheNetwork, teleporter utils.TeleporterTestInfo) {
l1AInfo := network.GetPrimaryNetworkInfo()
l1BInfo, _ := network.GetTwoL1s()
fundedAddress, fundedKey := network.GetFundedAccountInfo()
//
// Deploy TestMessenger to L1s A and B
//
ctx := context.Background()
teleporterAddress := teleporter.TeleporterMessengerAddress(l1AInfo)
_, testMessengerA := utils.DeployTestMessenger(
ctx,
fundedKey,
fundedAddress,
teleporter.TeleporterRegistryAddress(l1AInfo),
l1AInfo,
)
testMessengerAddressB, testMessengerB := utils.DeployTestMessenger(
ctx,
fundedKey,
fundedAddress,
teleporter.TeleporterRegistryAddress(l1BInfo),
l1BInfo,
)
// Pause Teleporter on L1 B
opts, err := bind.NewKeyedTransactorWithChainID(
fundedKey,
l1BInfo.EVMChainID,
)
Expect(err).Should(BeNil())
tx, err := testMessengerB.PauseTeleporterAddress(opts, teleporterAddress)
Expect(err).Should(BeNil())
receipt := utils.WaitForTransactionSuccess(ctx, l1BInfo, tx.Hash())
pauseTeleporterEvent, err := utils.GetEventFromLogs(receipt.Logs, testMessengerB.ParseTeleporterAddressPaused)
Expect(err).Should(BeNil())
Expect(pauseTeleporterEvent.TeleporterAddress).Should(Equal(teleporterAddress))
isPaused, err := testMessengerB.IsTeleporterAddressPaused(&bind.CallOpts{}, teleporterAddress)
Expect(err).Should(BeNil())
Expect(isPaused).Should(BeTrue())
aggregator := network.GetSignatureAggregator()
defer aggregator.Shutdown()
// Send a message from L1 A to L1 B, which should fail
teleporter.SendExampleCrossChainMessageAndVerify(
ctx,
l1AInfo,
testMessengerA,
l1BInfo,
testMessengerAddressB,
testMessengerB,
fundedKey,
"message_1",
aggregator,
false,
)
// Unpause Teleporter on L1 B
tx, err = testMessengerB.UnpauseTeleporterAddress(opts, teleporterAddress)
Expect(err).Should(BeNil())
receipt = utils.WaitForTransactionSuccess(ctx, l1BInfo, tx.Hash())
unpauseTeleporterEvent, err := utils.GetEventFromLogs(receipt.Logs, testMessengerB.ParseTeleporterAddressUnpaused)
Expect(err).Should(BeNil())
Expect(unpauseTeleporterEvent.TeleporterAddress).Should(Equal(teleporterAddress))
isPaused, err = testMessengerB.IsTeleporterAddressPaused(&bind.CallOpts{}, teleporterAddress)
Expect(err).Should(BeNil())
Expect(isPaused).Should(BeFalse())
// Send a message from L1 A to L1 B again, which should now succeed
teleporter.SendExampleCrossChainMessageAndVerify(
ctx,
l1AInfo,
testMessengerA,
l1BInfo,
testMessengerAddressB,
testMessengerB,
fundedKey,
"message_2",
aggregator,
true,
)
}