From ed342db5604d61ce81d09478d50013b54fbd4140 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Tue, 10 Sep 2024 10:54:36 +0200 Subject: [PATCH 01/17] chore: dfx start --pocketic --- e2e/utils.sh | 6 +++--- extensions/nns/e2e/tests/nns.bash | 2 +- extensions/nns/src/install_nns.rs | 2 +- extensions/sns/e2e/tests/sns.bash | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/e2e/utils.sh b/e2e/utils.sh index e69e730..821be5a 100644 --- a/e2e/utils.sh +++ b/e2e/utils.sh @@ -171,9 +171,9 @@ dfx_start() { # wait for it to close. Because `dfx start` leaves child processes running, we need # to close this pipe, otherwise Bats will wait indefinitely. if [[ $# -eq 0 ]]; then - dfx start --background --host "$FRONTEND_HOST" --artificial-delay 100 3>&- # Start on random port for parallel test execution + dfx start --pocketic --clean --background --host "$FRONTEND_HOST" 3>&- # Start on random port for parallel test execution else - dfx start --background --artificial-delay 100 "$@" 3>&- + dfx start --pocketic --clean --background "$@" 3>&- fi dfx_config_root="$E2E_NETWORK_DATA_DIRECTORY/replica-configuration" @@ -203,7 +203,7 @@ dfx_start() { dfx_start_for_nns_install() { # TODO: When nns-dapp supports dynamic ports, this wait can be removed. timeout 300 sh -c \ - "until dfx start --clean --background --host 127.0.0.1:8080 --verbose ; do echo waiting for port 8080 to become free; sleep 3; done" \ + "until dfx start --pocketic --clean --background --host 127.0.0.1:8080 --verbose ; do echo waiting for port 8080 to become free; sleep 3; done" \ || (echo "could not connect to replica on port 8080" && exit 1) # TODO: figure out how to plug bats' "run" into above statement, # so that below asserts will work as expected diff --git a/extensions/nns/e2e/tests/nns.bash b/extensions/nns/e2e/tests/nns.bash index b598cd8..b5f9c30 100755 --- a/extensions/nns/e2e/tests/nns.bash +++ b/extensions/nns/e2e/tests/nns.bash @@ -167,6 +167,6 @@ assert_nns_canister_id_matches() { run dfx --identity ident-1 canister call rkp4c-7iaaa-aaaaa-aaaca-cai notify_mint_cycles '(record { block_index = 5 : nat64; })' # If cycles ledger is configured correctly, then notify_mint_cycles will try to call the cycles ledger (and fail because the canister is not even created). # If it is not configured correctly, then this will complain about the cycles ledger canister id not being configured. - assert_output --partial "Canister um5iw-rqaaa-aaaaq-qaaba-cai not found" + assert_output --partial "No route to canister um5iw-rqaaa-aaaaq-qaaba-cai" } diff --git a/extensions/nns/src/install_nns.rs b/extensions/nns/src/install_nns.rs index 65770f5..643f6b7 100644 --- a/extensions/nns/src/install_nns.rs +++ b/extensions/nns/src/install_nns.rs @@ -92,7 +92,7 @@ pub async fn install_nns( verify_local_replica_type_is_system(network, networks_config)?; verify_nns_canister_ids_are_available(agent).await?; let provider_url = get_and_check_provider(network)?; - let nns_url = get_and_check_replica_url(network, logger)?; + let nns_url = provider_url.clone(); let subnet_id = get_subnet_id(agent).await?.to_text(); eprintln!("Installing the core backend wasm canisters..."); diff --git a/extensions/sns/e2e/tests/sns.bash b/extensions/sns/e2e/tests/sns.bash index 5b8f91d..2190f0b 100755 --- a/extensions/sns/e2e/tests/sns.bash +++ b/extensions/sns/e2e/tests/sns.bash @@ -58,7 +58,7 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" dfx_extension_install_manually nns dfx_new install_shared_asset subnet_type/shared_network_settings/system - dfx start --clean --background --host 127.0.0.1:8080 + dfx start --pocketic --clean --background --host 127.0.0.1:8080 wait_until_replica_healthy dfx nns install dfx nns import @@ -94,7 +94,7 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" @test "sns prepare-canisters adds NNS Root" { dfx_extension_install_manually nns install_shared_asset subnet_type/shared_network_settings/system - dfx start --clean --background --host 127.0.0.1:8080 + dfx start --pocketic --clean --background --host 127.0.0.1:8080 wait_until_replica_healthy dfx_new_frontend && dfx deploy @@ -119,7 +119,7 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" @test "sns prepare-canisters removes NNS Root" { dfx_extension_install_manually nns install_shared_asset subnet_type/shared_network_settings/system - dfx start --clean --background --host 127.0.0.1:8080 + dfx start --pocketic --clean --background --host 127.0.0.1:8080 wait_until_replica_healthy dfx_new_frontend && dfx deploy @@ -220,4 +220,4 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" @test "sns neuron-id-to-candid-subaccount --escaped has a reasonable output" { run dfx sns neuron-id-to-candid-subaccount 9f5f9fda77a03e7177126d0be8c99e931a5381731d00da53ede363140e1be5d6 --escaped assert_output 'blob \"\\9f\\5f\\9f\\da\\77\\a0\\3e\\71\\77\\12\\6d\\0b\\e8\\c9\\9e\\93\\1a\\53\\81\\73\\1d\\00\\da\\53\\ed\\e3\\63\\14\\0e\\1b\\e5\\d6\"' -} \ No newline at end of file +} From 864c2822a57cdb64f85e12bb1e2e4c059a239c48 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Tue, 1 Oct 2024 18:11:19 +0200 Subject: [PATCH 02/17] args --- e2e/utils.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/e2e/utils.sh b/e2e/utils.sh index 821be5a..e908446 100644 --- a/e2e/utils.sh +++ b/e2e/utils.sh @@ -171,9 +171,9 @@ dfx_start() { # wait for it to close. Because `dfx start` leaves child processes running, we need # to close this pipe, otherwise Bats will wait indefinitely. if [[ $# -eq 0 ]]; then - dfx start --pocketic --clean --background --host "$FRONTEND_HOST" 3>&- # Start on random port for parallel test execution + dfx start --pocketic --background --host "$FRONTEND_HOST" --artificial-delay 100 3>&- # Start on random port for parallel test execution else - dfx start --pocketic --clean --background "$@" 3>&- + dfx start --pocketic --background --artificial-delay 100 "$@" 3>&- fi dfx_config_root="$E2E_NETWORK_DATA_DIRECTORY/replica-configuration" From 10d56db7b80daa86a5e681982a4602cf873100f0 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Tue, 1 Oct 2024 18:26:16 +0200 Subject: [PATCH 03/17] dfx version --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 6ba337c..dcacce4 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -44,7 +44,7 @@ jobs: - name: Install IC SDK (dfx) uses: dfinity/setup-dfx@main with: - dfx-version: "0.23.0" + dfx-version: "0.24.1-beta.0" - name: Set prebuilt extensions directory run: echo "PREBUILT_EXTENSIONS_DIR=$HOME/prebuilt-extensions" >> $GITHUB_ENV - name: Build extension manually From 2b6190b0710d50486c2a4f12720743118363d854 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Fri, 25 Oct 2024 20:56:56 +0200 Subject: [PATCH 04/17] bump dfx --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index dcacce4..b9b1025 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -44,7 +44,7 @@ jobs: - name: Install IC SDK (dfx) uses: dfinity/setup-dfx@main with: - dfx-version: "0.24.1-beta.0" + dfx-version: "0.24.2-beta.0" - name: Set prebuilt extensions directory run: echo "PREBUILT_EXTENSIONS_DIR=$HOME/prebuilt-extensions" >> $GITHUB_ENV - name: Build extension manually From bfb41f80c957427d48ea6a19a331bffe751fc928 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Fri, 1 Nov 2024 14:29:04 +0100 Subject: [PATCH 05/17] test --- extensions/nns/e2e/tests/nns.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/nns/e2e/tests/nns.bash b/extensions/nns/e2e/tests/nns.bash index b5f9c30..b598cd8 100755 --- a/extensions/nns/e2e/tests/nns.bash +++ b/extensions/nns/e2e/tests/nns.bash @@ -167,6 +167,6 @@ assert_nns_canister_id_matches() { run dfx --identity ident-1 canister call rkp4c-7iaaa-aaaaa-aaaca-cai notify_mint_cycles '(record { block_index = 5 : nat64; })' # If cycles ledger is configured correctly, then notify_mint_cycles will try to call the cycles ledger (and fail because the canister is not even created). # If it is not configured correctly, then this will complain about the cycles ledger canister id not being configured. - assert_output --partial "No route to canister um5iw-rqaaa-aaaaq-qaaba-cai" + assert_output --partial "Canister um5iw-rqaaa-aaaaq-qaaba-cai not found" } From 7debb5cf01376f7c47aba989e8c4177b6eeb5052 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Wed, 6 Nov 2024 17:29:57 +0100 Subject: [PATCH 06/17] dfx version --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index b9b1025..10125d9 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -44,7 +44,7 @@ jobs: - name: Install IC SDK (dfx) uses: dfinity/setup-dfx@main with: - dfx-version: "0.24.2-beta.0" + dfx-version: "0.24.1" - name: Set prebuilt extensions directory run: echo "PREBUILT_EXTENSIONS_DIR=$HOME/prebuilt-extensions" >> $GITHUB_ENV - name: Build extension manually From 9749dfd08136f4e6529f033dbca8d980c6dc0aea Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Wed, 6 Nov 2024 17:37:40 +0100 Subject: [PATCH 07/17] error msg --- extensions/nns/e2e/tests/nns.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extensions/nns/e2e/tests/nns.bash b/extensions/nns/e2e/tests/nns.bash index b598cd8..b5f9c30 100755 --- a/extensions/nns/e2e/tests/nns.bash +++ b/extensions/nns/e2e/tests/nns.bash @@ -167,6 +167,6 @@ assert_nns_canister_id_matches() { run dfx --identity ident-1 canister call rkp4c-7iaaa-aaaaa-aaaca-cai notify_mint_cycles '(record { block_index = 5 : nat64; })' # If cycles ledger is configured correctly, then notify_mint_cycles will try to call the cycles ledger (and fail because the canister is not even created). # If it is not configured correctly, then this will complain about the cycles ledger canister id not being configured. - assert_output --partial "Canister um5iw-rqaaa-aaaaq-qaaba-cai not found" + assert_output --partial "No route to canister um5iw-rqaaa-aaaaq-qaaba-cai" } From 753bcc2768db5b5670bca0e871b08d096b96a7e0 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Wed, 6 Nov 2024 17:47:40 +0100 Subject: [PATCH 08/17] no USE_IC_REF --- e2e/utils.sh | 83 +++++++++++++++------------------------------------- 1 file changed, 24 insertions(+), 59 deletions(-) diff --git a/e2e/utils.sh b/e2e/utils.sh index e908446..d8a37cc 100644 --- a/e2e/utils.sh +++ b/e2e/utils.sh @@ -155,33 +155,21 @@ dfx_start() { FRONTEND_HOST="127.0.0.1:0" determine_network_directory - if [ "$USE_IC_REF" ] - then - if [[ $# -eq 0 ]]; then - dfx start --emulator --background --host "$FRONTEND_HOST" 3>&- - else - batslib_decorate "no arguments to dfx start --emulator supported yet" - fail - fi - - test -f "$E2E_NETWORK_DATA_DIRECTORY/ic-ref.port" - port=$(cat "$E2E_NETWORK_DATA_DIRECTORY/ic-ref.port") + + # Bats creates a FD 3 for test output, but child processes inherit it and Bats will + # wait for it to close. Because `dfx start` leaves child processes running, we need + # to close this pipe, otherwise Bats will wait indefinitely. + if [[ $# -eq 0 ]]; then + dfx start --pocketic --background --host "$FRONTEND_HOST" --artificial-delay 100 3>&- # Start on random port for parallel test execution else - # Bats creates a FD 3 for test output, but child processes inherit it and Bats will - # wait for it to close. Because `dfx start` leaves child processes running, we need - # to close this pipe, otherwise Bats will wait indefinitely. - if [[ $# -eq 0 ]]; then - dfx start --pocketic --background --host "$FRONTEND_HOST" --artificial-delay 100 3>&- # Start on random port for parallel test execution - else - dfx start --pocketic --background --artificial-delay 100 "$@" 3>&- - fi - - dfx_config_root="$E2E_NETWORK_DATA_DIRECTORY/replica-configuration" - printf "Configuration Root for DFX: %s\n" "${dfx_config_root}" - test -f "${dfx_config_root}/replica-1.port" - port=$(cat "${dfx_config_root}/replica-1.port") + dfx start --pocketic --background --artificial-delay 100 "$@" 3>&- fi + dfx_config_root="$E2E_NETWORK_DATA_DIRECTORY/replica-configuration" + printf "Configuration Root for DFX: %s\n" "${dfx_config_root}" + test -f "${dfx_config_root}/replica-1.port" + port=$(cat "${dfx_config_root}/replica-1.port") + webserver_port=$(cat "$E2E_NETWORK_DATA_DIRECTORY/webserver-port") printf "Replica Configured Port: %s\n" "${port}" @@ -223,37 +211,20 @@ dfx_replica() { local replica_port dfx_config_root dfx_patchelf determine_network_directory - if [ "$USE_IC_REF" ] - then - # Bats creates a FD 3 for test output, but child processes inherit it and Bats will - # wait for it to close. Because `dfx start` leaves child processes running, we need - # to close this pipe, otherwise Bats will wait indefinitely. - dfx replica --emulator --port 0 "$@" 3>&- & - export DFX_REPLICA_PID=$! - - timeout 60 sh -c \ - "until test -s \"$E2E_NETWORK_DATA_DIRECTORY/ic-ref.port\"; do echo waiting for ic-ref port; sleep 1; done" \ - || (echo "replica did not write to \"$E2E_NETWORK_DATA_DIRECTORY/ic-ref.port\" file" && exit 1) - - test -f "$E2E_NETWORK_DATA_DIRECTORY/ic-ref.port" - replica_port=$(cat "$E2E_NETWORK_DATA_DIRECTORY/ic-ref.port") - else - # Bats creates a FD 3 for test output, but child processes inherit it and Bats will - # wait for it to close. Because `dfx start` leaves child processes running, we need - # to close this pipe, otherwise Bats will wait indefinitely. - dfx replica --port 0 "$@" 3>&- & - export DFX_REPLICA_PID=$! - - timeout 60 sh -c \ - "until test -s \"$E2E_NETWORK_DATA_DIRECTORY/replica-configuration/replica-1.port\"; do echo waiting for replica port; sleep 1; done" \ - || (echo "replica did not write to port file" && exit 1) + # Bats creates a FD 3 for test output, but child processes inherit it and Bats will + # wait for it to close. Because `dfx start` leaves child processes running, we need + # to close this pipe, otherwise Bats will wait indefinitely. + dfx replica --port 0 "$@" 3>&- & + export DFX_REPLICA_PID=$! - dfx_config_root="$E2E_NETWORK_DATA_DIRECTORY/replica-configuration" - test -f "${dfx_config_root}/replica-1.port" - replica_port=$(cat "${dfx_config_root}/replica-1.port") + timeout 60 sh -c \ + "until test -s \"$E2E_NETWORK_DATA_DIRECTORY/replica-configuration/replica-1.port\"; do echo waiting for replica port; sleep 1; done" \ + || (echo "replica did not write to port file" && exit 1) - fi + dfx_config_root="$E2E_NETWORK_DATA_DIRECTORY/replica-configuration" + test -f "${dfx_config_root}/replica-1.port" + replica_port=$(cat "${dfx_config_root}/replica-1.port") printf "Replica Configured Port: %s\n" "${replica_port}" @@ -333,13 +304,7 @@ setup_actuallylocal_shared_network() { } setup_local_shared_network() { - local replica_port - if [ "$USE_IC_REF" ] - then - replica_port=$(get_ic_ref_port) - else - replica_port=$(get_replica_port) - fi + local replica_port=$(get_replica_port) [ ! -f "$E2E_NETWORKS_JSON" ] && echo "{}" >"$E2E_NETWORKS_JSON" From dba1b4a330d24e7e31b4df44ff177680e3d19568 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Wed, 6 Nov 2024 17:56:19 +0100 Subject: [PATCH 09/17] generalize --- e2e/utils.sh | 26 +++++++++++++++++++++++--- extensions/nns/e2e/tests/nns.bash | 7 ++++++- extensions/sns/e2e/tests/sns.bash | 6 +++--- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/e2e/utils.sh b/e2e/utils.sh index d8a37cc..096516d 100644 --- a/e2e/utils.sh +++ b/e2e/utils.sh @@ -25,6 +25,12 @@ dfx_extension_install_manually() ( extensions_dir="$(dfx cache show)/extensions" mkdir -p "$extensions_dir" cp -R "$PREBUILT_EXTENSIONS_DIR/$extension_name" "$extensions_dir/$extension_name" + if [ "$USE_POCKET_IC" ] + then + export DFX_START="dfx start --pocketic" + else + export DFX_START="dfx start" + fi ) standard_setup() { @@ -156,13 +162,20 @@ dfx_start() { determine_network_directory + if [ "$USE_POCKET_IC" ] + then + DFX_START="dfx start --pocketic" + else + DFX_START="dfx start" + fi + # Bats creates a FD 3 for test output, but child processes inherit it and Bats will # wait for it to close. Because `dfx start` leaves child processes running, we need # to close this pipe, otherwise Bats will wait indefinitely. if [[ $# -eq 0 ]]; then - dfx start --pocketic --background --host "$FRONTEND_HOST" --artificial-delay 100 3>&- # Start on random port for parallel test execution + $DFX_START --background --host "$FRONTEND_HOST" --artificial-delay 100 3>&- # Start on random port for parallel test execution else - dfx start --pocketic --background --artificial-delay 100 "$@" 3>&- + $DFX_START --pocketic --background --artificial-delay 100 "$@" 3>&- fi dfx_config_root="$E2E_NETWORK_DATA_DIRECTORY/replica-configuration" @@ -189,9 +202,16 @@ dfx_start() { # - It may also be that ic-nns-install, if used on a non-standard port, installs only the core canisters not the UI. # - However until we have implemented good solutions, all tests on ic-nns-install must run on port 8080. dfx_start_for_nns_install() { + if [ "$USE_POCKET_IC" ] + then + DFX_START="dfx start --pocketic" + else + DFX_START="dfx start" + fi + # TODO: When nns-dapp supports dynamic ports, this wait can be removed. timeout 300 sh -c \ - "until dfx start --pocketic --clean --background --host 127.0.0.1:8080 --verbose ; do echo waiting for port 8080 to become free; sleep 3; done" \ + "until $DFX_START --clean --background --host 127.0.0.1:8080 --verbose ; do echo waiting for port 8080 to become free; sleep 3; done" \ || (echo "could not connect to replica on port 8080" && exit 1) # TODO: figure out how to plug bats' "run" into above statement, # so that below asserts will work as expected diff --git a/extensions/nns/e2e/tests/nns.bash b/extensions/nns/e2e/tests/nns.bash index b5f9c30..bd27f5a 100755 --- a/extensions/nns/e2e/tests/nns.bash +++ b/extensions/nns/e2e/tests/nns.bash @@ -167,6 +167,11 @@ assert_nns_canister_id_matches() { run dfx --identity ident-1 canister call rkp4c-7iaaa-aaaaa-aaaca-cai notify_mint_cycles '(record { block_index = 5 : nat64; })' # If cycles ledger is configured correctly, then notify_mint_cycles will try to call the cycles ledger (and fail because the canister is not even created). # If it is not configured correctly, then this will complain about the cycles ledger canister id not being configured. - assert_output --partial "No route to canister um5iw-rqaaa-aaaaq-qaaba-cai" + if [ "$USE_POCKET_IC" ] + then + assert_output --partial "No route to canister um5iw-rqaaa-aaaaq-qaaba-cai" + else + assert_output --partial "Canister um5iw-rqaaa-aaaaq-qaaba-cai not found" + fi } diff --git a/extensions/sns/e2e/tests/sns.bash b/extensions/sns/e2e/tests/sns.bash index 21f2d56..7071bca 100755 --- a/extensions/sns/e2e/tests/sns.bash +++ b/extensions/sns/e2e/tests/sns.bash @@ -62,7 +62,7 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" echo "===== 3 =====" install_shared_asset subnet_type/shared_network_settings/system echo "===== 4 =====" - dfx start --pocketic --clean --background --host 127.0.0.1:8080 + $DFX_START --clean --background --host 127.0.0.1:8080 echo "===== 5 =====" wait_until_replica_healthy echo "===== 6 =====" @@ -107,7 +107,7 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" @test "sns prepare-canisters adds NNS Root" { dfx_extension_install_manually nns install_shared_asset subnet_type/shared_network_settings/system - dfx start --pocketic --clean --background --host 127.0.0.1:8080 + $DFX_START --clean --background --host 127.0.0.1:8080 wait_until_replica_healthy dfx_new_frontend && dfx deploy @@ -132,7 +132,7 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" @test "sns prepare-canisters removes NNS Root" { dfx_extension_install_manually nns install_shared_asset subnet_type/shared_network_settings/system - dfx start --pocketic --clean --background --host 127.0.0.1:8080 + $DFX_START --clean --background --host 127.0.0.1:8080 wait_until_replica_healthy dfx_new_frontend && dfx deploy From cbbc8e2c5915761d14ef2dccb5770193a27b4536 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Wed, 6 Nov 2024 17:59:45 +0100 Subject: [PATCH 10/17] USE_POCKET_IC --- .github/workflows/e2e.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index 10125d9..e5f1ef2 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -18,6 +18,7 @@ jobs: matrix: os: [ macos-12, ubuntu-20.04 ] extension: [ nns, sns ] + pocketic: [ "", "true" ] steps: - uses: actions/checkout@v4 with: @@ -54,6 +55,8 @@ jobs: if: matrix.extension == 'sns' - name: run test run: timeout 2400 e2e/bats/bin/bats extensions/${{ matrix.extension }}/e2e/tests/*.bash + env: + USE_POCKET_IC: ${{ matrix.pocketic }} aggregate: name: e2e:required From c0dcc7e7b50097f3e3d760f585d9857bbbb9be8d Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Wed, 6 Nov 2024 18:00:18 +0100 Subject: [PATCH 11/17] rename --- .github/workflows/e2e.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/e2e.yml b/.github/workflows/e2e.yml index e5f1ef2..6eae456 100644 --- a/.github/workflows/e2e.yml +++ b/.github/workflows/e2e.yml @@ -18,7 +18,7 @@ jobs: matrix: os: [ macos-12, ubuntu-20.04 ] extension: [ nns, sns ] - pocketic: [ "", "true" ] + pocketic: [ "", "pocketic" ] steps: - uses: actions/checkout@v4 with: From 04c9a1a5e8eab0213fce157dba4832f5e5f3cd6d Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Wed, 6 Nov 2024 18:01:48 +0100 Subject: [PATCH 12/17] fix --- e2e/utils.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/e2e/utils.sh b/e2e/utils.sh index 096516d..76a30f4 100644 --- a/e2e/utils.sh +++ b/e2e/utils.sh @@ -175,7 +175,7 @@ dfx_start() { if [[ $# -eq 0 ]]; then $DFX_START --background --host "$FRONTEND_HOST" --artificial-delay 100 3>&- # Start on random port for parallel test execution else - $DFX_START --pocketic --background --artificial-delay 100 "$@" 3>&- + $DFX_START --background --artificial-delay 100 "$@" 3>&- fi dfx_config_root="$E2E_NETWORK_DATA_DIRECTORY/replica-configuration" From d1c365075576c06dab6616479b27895855300591 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Wed, 6 Nov 2024 18:18:43 +0100 Subject: [PATCH 13/17] source --- extensions/sns/e2e/tests/sns.bash | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/extensions/sns/e2e/tests/sns.bash b/extensions/sns/e2e/tests/sns.bash index 7071bca..eafa6dd 100755 --- a/extensions/sns/e2e/tests/sns.bash +++ b/extensions/sns/e2e/tests/sns.bash @@ -56,7 +56,7 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" @test "sns propose succeeds" { echo "===== 1 =====" - dfx_extension_install_manually nns + source dfx_extension_install_manually nns echo "===== 2 =====" dfx_new echo "===== 3 =====" @@ -105,7 +105,7 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" # This test asserts that the new subcommand `prepare-canister add-nns-root` can add NNS root # as a co-controller to a dapp. @test "sns prepare-canisters adds NNS Root" { - dfx_extension_install_manually nns + source dfx_extension_install_manually nns install_shared_asset subnet_type/shared_network_settings/system $DFX_START --clean --background --host 127.0.0.1:8080 wait_until_replica_healthy @@ -130,7 +130,7 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" # This test asserts that the new subcommand `prepare-canister remove-nns-root` can remove NNS root # as a co-controller to a dapp. @test "sns prepare-canisters removes NNS Root" { - dfx_extension_install_manually nns + source dfx_extension_install_manually nns install_shared_asset subnet_type/shared_network_settings/system $DFX_START --clean --background --host 127.0.0.1:8080 wait_until_replica_healthy From efd0dfdcd0f7fc1fe40654f170b38ee5475ab9ec Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Wed, 6 Nov 2024 19:22:33 +0100 Subject: [PATCH 14/17] fix --- e2e/utils.sh | 6 ------ extensions/sns/e2e/tests/sns.bash | 12 ++++++------ 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/e2e/utils.sh b/e2e/utils.sh index 76a30f4..ac3cd2b 100644 --- a/e2e/utils.sh +++ b/e2e/utils.sh @@ -25,12 +25,6 @@ dfx_extension_install_manually() ( extensions_dir="$(dfx cache show)/extensions" mkdir -p "$extensions_dir" cp -R "$PREBUILT_EXTENSIONS_DIR/$extension_name" "$extensions_dir/$extension_name" - if [ "$USE_POCKET_IC" ] - then - export DFX_START="dfx start --pocketic" - else - export DFX_START="dfx start" - fi ) standard_setup() { diff --git a/extensions/sns/e2e/tests/sns.bash b/extensions/sns/e2e/tests/sns.bash index eafa6dd..6ed1d77 100755 --- a/extensions/sns/e2e/tests/sns.bash +++ b/extensions/sns/e2e/tests/sns.bash @@ -56,13 +56,13 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" @test "sns propose succeeds" { echo "===== 1 =====" - source dfx_extension_install_manually nns + dfx_extension_install_manually nns echo "===== 2 =====" dfx_new echo "===== 3 =====" install_shared_asset subnet_type/shared_network_settings/system echo "===== 4 =====" - $DFX_START --clean --background --host 127.0.0.1:8080 + dfx_start_for_nns_install echo "===== 5 =====" wait_until_replica_healthy echo "===== 6 =====" @@ -105,9 +105,9 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" # This test asserts that the new subcommand `prepare-canister add-nns-root` can add NNS root # as a co-controller to a dapp. @test "sns prepare-canisters adds NNS Root" { - source dfx_extension_install_manually nns + dfx_extension_install_manually nns install_shared_asset subnet_type/shared_network_settings/system - $DFX_START --clean --background --host 127.0.0.1:8080 + dfx_start_for_nns_install wait_until_replica_healthy dfx_new_frontend && dfx deploy @@ -130,9 +130,9 @@ SNS_CONFIG_FILE_NAME="sns_init.yaml" # This test asserts that the new subcommand `prepare-canister remove-nns-root` can remove NNS root # as a co-controller to a dapp. @test "sns prepare-canisters removes NNS Root" { - source dfx_extension_install_manually nns + dfx_extension_install_manually nns install_shared_asset subnet_type/shared_network_settings/system - $DFX_START --clean --background --host 127.0.0.1:8080 + dfx_start_for_nns_install wait_until_replica_healthy dfx_new_frontend && dfx deploy From d5282ba5711d0ab09a1f15a3816e51a4b3e88108 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Thu, 7 Nov 2024 07:50:43 +0100 Subject: [PATCH 15/17] drop unused dfx_start function --- e2e/utils.sh | 41 ----------------------------------------- 1 file changed, 41 deletions(-) diff --git a/e2e/utils.sh b/e2e/utils.sh index ac3cd2b..f5db3da 100644 --- a/e2e/utils.sh +++ b/e2e/utils.sh @@ -146,47 +146,6 @@ determine_network_directory() { fi } -# Start the replica in the background. -dfx_start() { - local port dfx_config_root webserver_port - dfx_patchelf - - # Start on random port for parallel test execution - FRONTEND_HOST="127.0.0.1:0" - - determine_network_directory - - if [ "$USE_POCKET_IC" ] - then - DFX_START="dfx start --pocketic" - else - DFX_START="dfx start" - fi - - # Bats creates a FD 3 for test output, but child processes inherit it and Bats will - # wait for it to close. Because `dfx start` leaves child processes running, we need - # to close this pipe, otherwise Bats will wait indefinitely. - if [[ $# -eq 0 ]]; then - $DFX_START --background --host "$FRONTEND_HOST" --artificial-delay 100 3>&- # Start on random port for parallel test execution - else - $DFX_START --background --artificial-delay 100 "$@" 3>&- - fi - - dfx_config_root="$E2E_NETWORK_DATA_DIRECTORY/replica-configuration" - printf "Configuration Root for DFX: %s\n" "${dfx_config_root}" - test -f "${dfx_config_root}/replica-1.port" - port=$(cat "${dfx_config_root}/replica-1.port") - - webserver_port=$(cat "$E2E_NETWORK_DATA_DIRECTORY/webserver-port") - - printf "Replica Configured Port: %s\n" "${port}" - printf "Webserver Configured Port: %s\n" "${webserver_port}" - - timeout 5 sh -c \ - "until nc -z localhost ${port}; do echo waiting for replica; sleep 1; done" \ - || (echo "could not connect to replica on port ${port}" && exit 1) -} - # Tries to start dfx on the default port, repeating until it succeeds or times out. # # Motivation: dfx nns install works only on port 8080, as URLs are compiled into the wasms. This means that multiple From 19f2a0c3710ac16361d2cd7a3dba0020d1d2d388 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Thu, 7 Nov 2024 17:38:09 +0100 Subject: [PATCH 16/17] drop dfx_replica --- e2e/utils.sh | 31 ------------------------------- 1 file changed, 31 deletions(-) diff --git a/e2e/utils.sh b/e2e/utils.sh index f5db3da..265059c 100644 --- a/e2e/utils.sh +++ b/e2e/utils.sh @@ -179,37 +179,6 @@ wait_until_replica_healthy() { echo "replica became healthy" } -# Start the replica in the background. -dfx_replica() { - local replica_port dfx_config_root - dfx_patchelf - determine_network_directory - - # Bats creates a FD 3 for test output, but child processes inherit it and Bats will - # wait for it to close. Because `dfx start` leaves child processes running, we need - # to close this pipe, otherwise Bats will wait indefinitely. - dfx replica --port 0 "$@" 3>&- & - export DFX_REPLICA_PID=$! - - timeout 60 sh -c \ - "until test -s \"$E2E_NETWORK_DATA_DIRECTORY/replica-configuration/replica-1.port\"; do echo waiting for replica port; sleep 1; done" \ - || (echo "replica did not write to port file" && exit 1) - - dfx_config_root="$E2E_NETWORK_DATA_DIRECTORY/replica-configuration" - test -f "${dfx_config_root}/replica-1.port" - replica_port=$(cat "${dfx_config_root}/replica-1.port") - - printf "Replica Configured Port: %s\n" "${replica_port}" - - timeout 5 sh -c \ - "until nc -z localhost ${replica_port}; do echo waiting for replica; sleep 1; done" \ - || (echo "could not connect to replica on port ${replica_port}" && exit 1) - - # ping the replica directly, because the bootstrap (that launches icx-proxy, which dfx ping usually connects to) - # is not running yet - dfx ping --wait-healthy "http://127.0.0.1:${replica_port}" -} - dfx_bootstrap() { # This only works because we use the network by name # (implicitly: --network local) From 9b5e603c170ee1c3464b6c0d191bde7136235748 Mon Sep 17 00:00:00 2001 From: Martin Raszyk Date: Thu, 7 Nov 2024 17:45:05 +0100 Subject: [PATCH 17/17] dead code --- e2e/utils.sh | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/e2e/utils.sh b/e2e/utils.sh index 265059c..05df08d 100644 --- a/e2e/utils.sh +++ b/e2e/utils.sh @@ -245,14 +245,6 @@ setup_actuallylocal_shared_network() { jq '.actuallylocal.providers=["http://127.0.0.1:'"$webserver_port"'"]' "$E2E_NETWORKS_JSON" | sponge "$E2E_NETWORKS_JSON" } -setup_local_shared_network() { - local replica_port=$(get_replica_port) - - [ ! -f "$E2E_NETWORKS_JSON" ] && echo "{}" >"$E2E_NETWORKS_JSON" - - jq ".local.bind=\"127.0.0.1:${replica_port}\"" "$E2E_NETWORKS_JSON" | sponge "$E2E_NETWORKS_JSON" -} - use_wallet_wasm() { # shellcheck disable=SC2154 export DFX_WALLET_WASM="${archive}/wallet/$1/wallet.wasm" @@ -286,10 +278,6 @@ get_replica_pid() { cat "$E2E_NETWORK_DATA_DIRECTORY/replica-configuration/replica-pid" } -get_ic_ref_port() { - cat "$E2E_NETWORK_DATA_DIRECTORY/ic-ref.port" - -} get_replica_port() { cat "$E2E_NETWORK_DATA_DIRECTORY/replica-configuration/replica-1.port" }