Files
SpacetimeDB/smoketests/tests/panic.py
2024-09-09 23:30:31 +00:00

32 lines
686 B
Python

from .. import Smoketest
class Panic(Smoketest):
MODULE_CODE = """
use 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");
}
"""
def test_panic(self):
"""Tests to check if a SpacetimeDB module can handle a panic without corrupting"""
with self.assertRaises(Exception):
self.call("first")
self.call("second")
self.assertIn("Test Passed", self.logs(2))