mirror of
https://github.com/clockworklabs/SpacetimeDB.git
synced 2026-05-22 07:32:16 -04:00
32 lines
686 B
Python
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)) |