Files
SpacetimeDB/test/tests/panic.sh
T
Phoebe Goldman a1e9984840 Multiple server configurations for CLI (#214)
Alters the CLI's configuration format to support storing multiple server configurations,
and having each server configuration store an (optional) default identity.
Many CLI commands take an additional -s argument, the server on which to operate,
which defaults to the configured default_server.
Using -s consistently requires renaming the publish skip-clippy short flag to -S.

Per discussion with @jdetter , this PR does not directly associate identities with servers.
Instead, each server configuration stores the server's "fingerprint" (i.e. PEM-formatted ECDSA public key),
and the CLI uses that public key to decode tokens to determine if they apply to a given server.
This architecture allows the CLI to behave reasonably
when multiple server configurations use the same set of tokens,
e.g. if multiple distinct URLs resolve to the same SpacetimeDB instance.
For example, one could imagine a configuration with server configurations for both http://127.0.0.1:3000
and http://localhost:3000, which should use the same set of identities.
2023-09-01 17:29:20 +00:00

44 lines
976 B
Bash

#!/bin/bash
if [ "$DESCRIBE_TEST" = 1 ] ; then
echo "Tests to check if a SpacetimeDB module can handle a panic"
exit
fi
set -euox pipefail
source "./test/lib.include"
cat > "${PROJECT_PATH}/src/lib.rs" << EOF
use spacetimedb::{spacetimedb, println};
use std::cell::RefCell;
thread_local! {
static X: RefCell<u32> = RefCell::new(0);
}
#[spacetimedb(reducer)]
fn first() {
X.with(|x| {
let x = x.borrow_mut();
panic!()
})
}
#[spacetimedb(reducer)]
fn second() {
X.with(|x| *x.borrow_mut());
println!("Test Passed");
}
EOF
run_test cargo run publish -S -d --project-path "$PROJECT_PATH" --clear-database
[ "1" == "$(grep -c "reated new database" "$TEST_OUT")" ]
IDENT="$(grep "reated new database" "$TEST_OUT" | awk 'NF>1{print $NF}')"
set +e
cargo run call "$IDENT" first
set -e
run_test cargo run call "$IDENT" second
run_test cargo run logs "$IDENT"
[ ' Test Passed' == "$(grep 'Test Passed' "$TEST_OUT" | cut -d: -f4-)" ]