use anyhow::Result;
use rogue_runtime::prelude::*;
rpc! {
pub async fn binom(n: u32, k: u32) -> u32 {
if k == 0 || k == n {
1
} else {
let left = binom(n - 1, k - 1).await;
let right = binom(n - 1, k).await;
left + right
}
}
}
#[tokio::test]
async fn test_rpc_runtime() -> Result<()> {
let runtime = Runtime::create("test".to_string()).await?;
runtime
.execute_local(async move {
assert_eq!(binom(10, 3).await, 120);
assert_eq!(binom(10, 5).await, 252);
assert_eq!(binom(15, 0).await, 1);
assert_eq!(binom(15, 15).await, 1);
Ok(())
})
.await?;
Ok(())
}