use super::DynamoDbStoreClient;
use crate::Store;
use linera_base::identifiers::ChainId;
use linera_views::{lru_caching::TEST_CACHE_SIZE, test_utils::LocalStackTestContext};
use std::mem;
#[tokio::test]
async fn guards_dont_leak() -> Result<(), anyhow::Error> {
let localstack = LocalStackTestContext::new().await?;
let table = "linera".parse()?;
let (store, _) = DynamoDbStoreClient::from_config(
localstack.dynamo_db_config(),
table,
TEST_CACHE_SIZE,
None,
)
.await?;
let chain_id = ChainId::root(1);
assert_eq!(store.client.guards.active_guards(), 0);
let chain = store.load_chain(chain_id).await?;
assert_eq!(store.client.guards.active_guards(), 1);
mem::drop(chain);
assert_eq!(store.client.guards.active_guards(), 0);
Ok(())
}