diff --git a/docs/e2e-integration-test-setup.md b/docs/e2e-integration-test-setup.md index fd184544b..6595c62c6 100644 --- a/docs/e2e-integration-test-setup.md +++ b/docs/e2e-integration-test-setup.md @@ -6,128 +6,130 @@ To run the demo, the following software needs to be installed. * Docker compose \[[download](https://docs.docker.com/compose/install/)\] -### Setting up the Environment +## Setting up the Environment -1. Build the `ibc-relayer` image: +1. Create an `ibc-e2e-tests` folder and clone the `IBC-Integration` repository: - ```bash - $ git clone https://github.com/icon-project/ibc-relay/ - $ cd ibc-relay/ - $ docker build -t relayer . - ``` + ```bash + mkdir ibc-e2e-tests + cd ibc-e2e-tests + git clone https://github.com/icon-project/IBC-Integration.git + ``` -2. Build the builder image for bundling contracts: +2. Build the `ibc-relayer` image: ```bash - make build-builder-img + git clone https://github.com/icon-project/ibc-relay.git + cd ibc-relay + docker build -t relayer . + cd - # Back to the root folder ``` - -3. Optimize contracts: - - Before starting to bundle contracts, update all submodules: +3. Build an `icon-chain` image ```bash - git submodule init - git submodule update --remote - ``` - - Start bundling Icon and Rust contracts: - - ```bash - make optimize-build - ``` - -### Additional steps for Apple Silicon  - -* Build an `icon-chain` image - - ```bash - git clone https://github.com/icon-project/goloop.git - cd goloop - make gochain-icon-image + git clone https://github.com/icon-project/goloop.git + cd goloop + make gochain-icon-image + cd - # Back to the root folder ``` -* Build a `goloop` image - - ```bash - git clone https://github.com/icon-project/goloop/ - cd goloop/ - make goloop-icon-image - ``` - -* Build an `archway` or `neutron` image +### Additional Images required for Apple Silicon  - **For Archway:** +If you are using an Apple Silicon machine, follow these additional steps to build required images: - ```bash - git clone https://github.com/archway-network/archway/ - cd archway - docker build -f Dockerfile.deprecated -t archway . --build-arg arch=aarch64 - ``` - - **For Neutron:** +1. Build a `goloop` image ```bash - git clone https://github.com/neutron-org/neutron.git - cd neutron - make build-docker-image + git clone https://github.com/icon-project/goloop/ + cd goloop/ + make goloop-icon-image + cd - # Back to the root folder ``` -ℹ️ Change the image name and version of Archway/Neutron in `e2e-config.yaml` or `e2e-config-neutron.yaml`. - -### Running IBC Integration System Tests - -To conduct tests for IBC integration system, carefully adhere to the provided instructions: +2. Build an `archway` or `neutron` image + + **For Archway:** + + ```bash + git clone https://github.com/archway-network/archway/ + cd archway + git checkout -b v0.5.1 v0.5.1 + docker build -f Dockerfile.deprecated -t archway . --build-arg arch=aarch64 + cd - # Back to the root folder + ``` + + **For Neutron:** + + ```bash + git clone https://github.com/neutron-org/neutron.git + cd neutron + make build-docker-image + cd - # Back to the root folder + ``` + +## Running IBC Integration System Tests + +To conduct tests for the IBC integration system, follow these steps: #### 1. Configure Environment Variables -Prior to initiating the tests, ensure proper configuration of essential environment variables, which play a pivotal role in the testing process: +Before initiating the tests, configure essential environment variables: -- **`E2E_CONFIG_PATH`**: Set this variable to the absolute path of your chosen configuration file. For Archway, utilize `sample-config-archway.yaml`, and for Neutron, employ `sample-config-neutron.yaml`. -- **`GOLOOP_IMAGE_ENV`**: Indicate the name of the Goloop image. +- **`E2E_CONFIG_PATH`**: Set this variable to the absolute path of your chosen configuration file. You can create these configuration files using the sample files provided in the `IBC-Integration` source folder. Sample configuration files are available at the following locations: + - For Archway, use: `IBC-Integration/test/testsuite/sample-config-archway.yaml` + - For Neutron, use: `IBC-Integration/test/testsuite/sample-config-neutron.yaml` +- **`GOLOOP_IMAGE_ENV`**: Specify the name of the Goloop image. - **`GOLOOP_IMAGE_TAG_ENV`**: Specify the version of the Goloop image. Here's an example of environment variable configuration: ```bash -export E2E_CONFIG_PATH=/home/User/IBC-integration/sample-config-archway.yaml +export E2E_CONFIG_PATH=/path/to/config.yaml export GOLOOP_IMAGE_ENV=goloop-icon export GOLOOP_IMAGE_TAG_ENV=latest ``` -#### 2. Run the Test Script +ℹ️ Please note that most of the config content can be used same as it in sample config however you may need to update the image name and version for Archway, Neutron, and Icon in the configuration file you create. -Use the appropriate command to run the test suite. Depending on your specific testing requirements, you can use the following command: - -```bash -./scripts/execute-test.sh [options] -``` -Replace `[options]` with any command-line options or arguments that the test script supports. To view more details about available options and usage, run the following command: +After configuring these variables, navigate to the `IBC-Integration` source folder: ```bash -./scripts/execute-test.sh --help +cd IBC-Integration ``` -This will display the available options, explain how to use them, and provide additional information about running the tests. +#### 2. Run the Test Script +Use the appropriate command to run the test suite. Depending on your specific testing requirements, you can use the following command: -#### 3. Execute the Test Suite +```bash +./scripts/execute-test.sh [options] +``` -Depending on your specific testing requirements, employ the appropriate commands to run the test suite: +Replace `[options]` with any command-line options or arguments that the test script supports. Here's an option block to help you: +```markdown +Options: + --clean: Clean contract directories (true/false, default: false). + --build-ibc: Build IBC contracts (true/false, default: false). + --build-xcall: Build xCall contracts (true/false, default: false). + --xcall-branch : Specify the xCall branch to build (default: main). + --use-docker: Use Docker for building contracts(true/false, default: false). + --test : Specify the type of test (e2e, e2e-demo, integration, default: e2e). +``` -- To execute the end-to-end tests: +To perform an end-to-end (e2e) test with all the necessary builds, execute the following command: ```bash -go test -v ./test/e2e -timeout 0 +./scripts/execute-test.sh --build-ibc --build-xcall --use-docker --test e2e ``` +This command covers building IBC and xCall contracts while utilizing Docker and running an end-to-end test. -- To run the integration tests: +Once you've initially built the contracts using the command above, you can easily execute the e2e test by using the following simplified command: ```bash -go test -v ./test/integration -timeout 0 +./scripts/execute-test.sh --test e2e ``` -#### 3. Set Up the Demo Test Environment (Optional) +### Set Up the Demo Test Environment (Optional) If necessary, establish the e2e demo test environment by executing the following command: @@ -135,12 +137,32 @@ If necessary, establish the e2e demo test environment by executing the following make e2e-demo-setup ``` -During the setup process, distinct configuration files are generated in the `test/e2e-demo/ibc-config` directory. These files include contract addresses, along with wallets containing mnemonic/private keys. These keys are essential for conducting subsequent tests. +During the setup process, distinct configuration files are generated in the `IBC-Integration/test/e2e-demo/ibc-config` directory. These files include contract addresses, along with wallets containing mnemonic/private keys. These keys are essential for conducting subsequent tests. -#### 4. Clean Up the Demo Test Environment (Optional) +#### Clean Up the Demo Test Environment (Optional) Upon completion of the testing process, if you've set up the e2e demo environment, you can execute the following command to perform a cleanup: ```bash make e2e-demo-clean ``` + +### Other commands available inside IBC-Integration repo + +1. Build the builder image for bundling contracts: + + ```bash + make build-builder-img + ``` + +2. Bundle and optimize IBC core contracts: + + ```bash + make optimize-build + ``` + +3. Bundle and optimize xcall-multi contracts: + + ```bash + make optimize-xcall + ``` \ No newline at end of file diff --git a/test/chains/icon/localnet.go b/test/chains/icon/localnet.go index 0a4e823f3..fc73f8e69 100644 --- a/test/chains/icon/localnet.go +++ b/test/chains/icon/localnet.go @@ -381,14 +381,36 @@ func (c *IconLocalnet) SetupIBC(ctx context.Context, keyName string) (context.Co c.IBCAddresses = contracts.ContractAddress params := `{"name": "test","country": "KOR","city": "Seoul","email": "prep@icon.foundation.com","website": "https://icon.kokoa.com","details": "https://icon.kokoa.com/json/details.json","p2pEndpoint": "localhost:9080"}` - _, _ = c.executeContract(ctx, "cx0000000000000000000000000000000000000000", interchaintest.IBCOwnerAccount, "registerPRep", params) + ctx, err = c.executeContract(ctx, "cx0000000000000000000000000000000000000000", interchaintest.IBCOwnerAccount, "registerPRep", params) + if err != nil { + c.log.Error("Error on registerPRep", + zap.Error(err), + ) + panic(err) + } params = `{"pubKey":"0x04b3d972e61b4e8bf796c00e84030d22414a94d1830be528586e921584daadf934f74bd4a93146e5c3d34dc3af0e6dbcfe842318e939f8cc467707d6f4295d57e5"}` - _, _ = c.executeContract(ctx, "cx0000000000000000000000000000000000000000", interchaintest.IBCOwnerAccount, "setPRepNodePublicKey", params) + ctx, err = c.executeContract(ctx, "cx0000000000000000000000000000000000000000", interchaintest.IBCOwnerAccount, "setPRepNodePublicKey", params) + if err != nil { + c.log.Error("Error on setPRepNodePublicKey", + zap.Error(err), + ) + panic(err) + } params = `{"networkTypeName":"eth", "name":"testNetwork", "owner":"` + ibcAddress + `"}` - ctx, _ = c.executeContract(ctx, "cx0000000000000000000000000000000000000001", interchaintest.IBCOwnerAccount, "openBTPNetwork", params) - //height, _ := ctx.Value("txResult").(icontypes.TransactionResult).BlockHeight.Int() - id := ctx.Value("txResult").(*icontypes.TransactionResult).EventLogs[1].Indexed[2] - typeId := ctx.Value("txResult").(*icontypes.TransactionResult).EventLogs[1].Indexed[1] + ctx, err = c.executeContract(ctx, "cx0000000000000000000000000000000000000001", interchaintest.IBCOwnerAccount, "openBTPNetwork", params) + if err != nil { + c.log.Error("Error on openBTPNetwork", + zap.Error(err), + ) + panic(err) + } + txResult := ctx.Value("txResult").(*icontypes.TransactionResult) + if txResult == nil { + c.log.Error("txResult is nil") + } + event := txResult.EventLogs[1] + id := event.Indexed[2] + typeId := event.Indexed[1] btpNetworkId, _ := icontypes.HexInt(id).Int() btpNetworkTypeId, _ := icontypes.HexInt(typeId).Int() @@ -776,8 +798,8 @@ func (c *IconLocalnet) executeContract(ctx context.Context, contractAddress, key return nil, fmt.Errorf("error when executing contract %v ", err) } _, res, err := c.getFullNode().Client.WaitForResults(ctx, &icontypes.TransactionHashParam{Hash: icontypes.NewHexBytes(txHashByte)}) - if err != nil { - return nil, err + if err != nil || res == nil { + return context.WithValue(ctx, "txResult", icontypes.TransactionResult{}), err } if res.Status == "0x1" { return context.WithValue(ctx, "txResult", res), nil @@ -787,8 +809,17 @@ func (c *IconLocalnet) executeContract(ctx context.Context, contractAddress, key if err == nil { logs, _ := json.Marshal(trace.Logs) fmt.Printf("---------debug trace start-----------\n%s\n---------debug trace end-----------\n", string(logs)) + } else { + c.log.Error("Attempting to retrieve the tx result once again.", + zap.String("txHash", hash), + ) + _, res, err = c.getFullNode().Client.WaitForResults(ctx, &icontypes.TransactionHashParam{Hash: icontypes.NewHexBytes(txHashByte)}) + if res.Status == "0x1" { + return context.WithValue(ctx, "txResult", res), nil + } } - return ctx, fmt.Errorf("%s", res.Failure.MessageValue) + + return context.WithValue(ctx, "txResult", icontypes.TransactionResult{}), fmt.Errorf("%s", res.Failure.MessageValue) } func (c *IconLocalnet) ExecuteContract(ctx context.Context, contractAddress, keyName, methodName string, params map[string]interface{}) (context.Context, error) {