Skip to content

Commit

Permalink
Fix integration tests (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
hpeebles authored Feb 26, 2024
1 parent f04c23f commit ae99904
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/backend.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 10 additions & 2 deletions rs/integration_tests/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down Expand Up @@ -109,8 +111,12 @@ fn install_canister(init_args: Option<InitArgs>) -> TestEnv {
fn canister_wasm() -> Vec<u8> {
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
Expand All @@ -123,6 +129,8 @@ fn canister_wasm_path() -> PathBuf {
)
.parent()
.unwrap()
.parent()
.unwrap()
.join("target")
.join("wasm32-unknown-unknown")
.join("release")
Expand Down
3 changes: 2 additions & 1 deletion scripts/run-integration-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
Expand Down

0 comments on commit ae99904

Please sign in to comment.