Files
SpacetimeDB/smoketests/tests/panic.py
Noa 540c519002 Rewrite smoketests as python unittests (#692)
* Rewrite smoketests as python unittests

* Get all tests working and do some work on parallel unittest

* Give up on parallel unittests

* Fix CI + address comments

* Fix skip-clippy arg confusion (just use the env var)

* fix ci

* Add comments
2024-03-14 02:47:38 +00:00

32 lines
701 B
Python

from .. import Smoketest
class Panic(Smoketest):
MODULE_CODE = """
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");
}
"""
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))