Use dockertest for the newly added serai-client-serai test

This commit is contained in:
Luke Parker
2025-11-07 02:06:34 -05:00
parent ce08fad931
commit 4653ef4a61
12 changed files with 144 additions and 33 deletions

View File

@@ -30,3 +30,6 @@ async-lock = "3"
[dev-dependencies]
tokio = { version = "1", default-features = false, features = ["rt", "macros"] }
dockertest = "0.5"
serai-docker-tests = { path = "../../../tests/docker" }
serai-substrate-tests = { path = "../../../tests/substrate" }

View File

@@ -1,9 +1,19 @@
use serai_client_serai::*;
#[tokio::test]
async fn main() {
let serai = Serai::new("http://127.0.0.1:9944".to_string()).unwrap();
let block = serai.block_by_number(0).await.unwrap();
assert_eq!(serai.block(block.header.hash()).await.unwrap(), block);
assert!(serai.finalized(block.header.hash()).await.unwrap());
async fn blockchain() {
let mut test = dockertest::DockerTest::new();
let (composition, handle) = serai_substrate_tests::composition(
"alice",
serai_docker_tests::fresh_logs_folder(true, "serai-client/blockchain"),
);
test.provide_container(composition);
test
.run_async(async |ops| {
let serai = serai_substrate_tests::rpc(&ops, handle).await;
let block = serai.block_by_number(0).await.unwrap();
assert_eq!(serai.block(block.header.hash()).await.unwrap(), block);
assert!(serai.finalized(block.header.hash()).await.unwrap());
})
.await;
}