Skip to content

Commit 5d27b4d

Browse files
authored
Add e2e tests for icm deploy and sendMsg commands (#2798)
* Add e2e tests for icm deploy command * Add icm sendMsg from cchain to subnet e2e test * Add rest of the e2e tests for icm sendMsg * Fix errors * Refactor the tests * Refactor SendICMMessage util function * Added test for hex encoded message * Addressed the comments * Remove cchain to cchain test * Add a check for contracts being deployed
1 parent 1ada710 commit 5d27b4d

File tree

11 files changed

+904
-30
lines changed

11 files changed

+904
-30
lines changed

.github/workflows/e2e-test.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ jobs:
1818
"\\[APM\\]",
1919
"\\[Error handling\\]",
2020
"\\[Key\\]",
21+
"\\[ICM\\]",
2122
"\\[Network\\]",
2223
"\\[Blockchain Configure\\]",
2324
"\\[Package Management\\]",

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ test: fmt vet ## Run tests.
3535

3636
lint: ## Run golangci-lint against code.
3737
golangci-lint run --path-prefix=.
38+
gofumpt -w .
3839

3940
build: fmt vet ## Build avalanche CLI binary.
4041
scripts/build.sh

cmd/interchaincmd/messengercmd/send_msg.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func sendMsg(_ *cobra.Command, args []string) error {
234234
time.Sleep(arrivalCheckInterval)
235235
}
236236

237-
ux.Logger.PrintToUser("Message successfully Teleported!")
237+
ux.Logger.PrintToUser("Message successfully delivered!")
238238

239239
return nil
240240
}

tests/e2e/commands/icm.go

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -3,41 +3,25 @@
33
package commands
44

55
import (
6-
"fmt"
7-
"os/exec"
8-
9-
"github.com/ava-labs/avalanche-cli/pkg/constants"
106
"github.com/ava-labs/avalanche-cli/tests/e2e/utils"
11-
"github.com/onsi/gomega"
127
)
138

149
const (
1510
ICMCmd = "icm"
1611
)
1712

1813
/* #nosec G204 */
19-
func SendICMMessage(network, subnetOne, subnetTwo, message, key string) string {
20-
// Create config
21-
cmdArgs := []string{
22-
ICMCmd,
23-
"sendMsg",
24-
network,
25-
subnetOne,
26-
subnetTwo,
27-
message,
28-
"--key",
29-
key,
30-
"--" + constants.SkipUpdateFlag,
31-
}
32-
33-
cmd := exec.Command(CLIBinary, cmdArgs...)
34-
output, err := cmd.CombinedOutput()
35-
if err != nil {
36-
fmt.Println(cmd.String())
37-
fmt.Println(string(output))
38-
utils.PrintStdErr(err)
39-
}
40-
gomega.Expect(err).Should(gomega.BeNil())
14+
func SendICMMessage(args []string, testFlags utils.TestFlags) (string, error) {
15+
return utils.TestCommand(utils.ICMCmd, "sendMsg", args, utils.GlobalFlags{
16+
"local": true,
17+
"skip-update-check": true,
18+
}, testFlags)
19+
}
4120

42-
return string(output)
21+
/* #nosec G204 */
22+
func DeployICMContracts(args []string, testFlags utils.TestFlags) (string, error) {
23+
return utils.TestCommand(utils.ICMCmd, "deploy", args, utils.GlobalFlags{
24+
"local": true,
25+
"skip-update-check": true,
26+
}, testFlags)
4327
}

tests/e2e/commands/relayer.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// / Copyright (C) 2025, Ava Labs, Inc. All rights reserved.
2+
// See the file LICENSE for licensing terms.
3+
4+
package commands
5+
6+
import (
7+
"github.com/ava-labs/avalanche-cli/tests/e2e/utils"
8+
)
9+
10+
/* #nosec G204 */
11+
func StopRelayer() (string, error) {
12+
return utils.TestCommand(InterchainCMD, "relayer", []string{"stop"}, utils.GlobalFlags{
13+
"local": true,
14+
"skip-update-check": true,
15+
}, utils.TestFlags{})
16+
}
17+
18+
/* #nosec G204 */
19+
func DeployRelayer(args []string, testFlags utils.TestFlags) (string, error) {
20+
return utils.TestCommand(InterchainCMD, "relayer", args, utils.GlobalFlags{
21+
"local": true,
22+
"skip-update-check": true,
23+
}, testFlags)
24+
}

tests/e2e/e2e_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import (
1313
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/apm"
1414
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/blockchain/configure"
1515
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/errhandling"
16+
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/icm/deploy"
17+
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/icm/sendMsg"
1618
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/key/create"
1719
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/key/delete"
1820
_ "github.com/ava-labs/avalanche-cli/tests/e2e/testcases/key/export"

0 commit comments

Comments
 (0)