From ae9990434c643caedd9180693cb68e876e4e33d7 Mon Sep 17 00:00:00 2001 From: Hamish Peebles Date: Mon, 26 Feb 2024 10:14:37 +0000 Subject: [PATCH] Fix integration tests (#37) --- .github/workflows/backend.yaml | 2 +- rs/integration_tests/src/lib.rs | 12 ++++++++++-- scripts/run-integration-tests.sh | 3 ++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/backend.yaml b/.github/workflows/backend.yaml index a9468d8..23cc4a7 100644 --- a/.github/workflows/backend.yaml +++ b/.github/workflows/backend.yaml @@ -74,4 +74,4 @@ jobs: override: true - run: rustup target add wasm32-unknown-unknown - name: Run integration tests - run: ./scripts/run-integration-tests.sh local + run: ./scripts/run-integration-tests.sh diff --git a/rs/integration_tests/src/lib.rs b/rs/integration_tests/src/lib.rs index 2df2203..750524c 100644 --- a/rs/integration_tests/src/lib.rs +++ b/rs/integration_tests/src/lib.rs @@ -63,6 +63,8 @@ fn read_push_remove_events_succeeds() { ); assert_eq!(read_response.events.len(), 5); + assert_eq!(read_response.events.first().unwrap().index, 0); + assert_eq!(read_response.events.last().unwrap().index, 4); assert_eq!(read_response.latest_event_index, Some(9)); assert_eq!(read_response.earliest_event_index_stored, Some(0)); @@ -109,8 +111,12 @@ fn install_canister(init_args: Option) -> TestEnv { fn canister_wasm() -> Vec { let file_path = canister_wasm_path(); - let mut file = File::open(&file_path) - .unwrap_or_else(|_| panic!("Failed to open file: {}", file_path.to_str().unwrap())); + let mut file = File::open(&file_path).unwrap_or_else(|e| { + panic!( + "Failed to open file: {}. Error: {e:?}", + file_path.to_str().unwrap() + ) + }); let mut bytes = Vec::new(); file.read_to_end(&mut bytes).expect("Failed to read file"); bytes @@ -123,6 +129,8 @@ fn canister_wasm_path() -> PathBuf { ) .parent() .unwrap() + .parent() + .unwrap() .join("target") .join("wasm32-unknown-unknown") .join("release") diff --git a/scripts/run-integration-tests.sh b/scripts/run-integration-tests.sh index 6e79d75..7c06de1 100755 --- a/scripts/run-integration-tests.sh +++ b/scripts/run-integration-tests.sh @@ -6,6 +6,7 @@ cd $SCRIPT_DIR/.. TESTNAME=$1 TEST_THREADS=${2:-2} +POCKET_IC_SERVER_VERSION="3.0.0" if [[ $OSTYPE == "linux-gnu"* ]] || [[ $RUNNER_OS == "Linux" ]] then @@ -23,7 +24,7 @@ cargo build --target wasm32-unknown-unknown --release -p event_sink_canister_imp cd rs/integration_tests echo "PocketIC download starting" -curl -sO https://download.dfinity.systems/ic/a7862784e8da4a97a1d608fd5b3db365de41a2d7/binaries/x86_64-$PLATFORM/pocket-ic.gz || exit 1 +curl -Ls https://github.com/dfinity/pocketic/releases/download/${POCKET_IC_SERVER_VERSION}/pocket-ic-x86_64-${PLATFORM}.gz -o pocket-ic.gz || exit 1 gzip -df pocket-ic.gz chmod +x pocket-ic echo "PocketIC download completed"