Skip to content

Commit cccdcff

Browse files
committed
Run the compat test against vss-client main branch
In a previous commit, we added a compatibility test against vss-client v0.5.0. We now also run the same test against the current vss-client main branch.
1 parent 8592436 commit cccdcff

5 files changed

Lines changed: 75 additions & 26 deletions

File tree

.github/workflows/server-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,5 @@ jobs:
4848
sleep 5
4949
cd rust/server
5050
RUSTFLAGS="--cfg vss_client_v050_compatibility" cargo test
51+
cargo update -p vss-client-ng@0.6.0 --verbose
52+
RUSTFLAGS="--cfg vss_client_main_compatibility" cargo test

rust/Cargo.lock

Lines changed: 22 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

rust/Cargo.toml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,9 @@ panic = "abort"
1616

1717
[workspace.lints.rust.unexpected_cfgs]
1818
level = "forbid"
19-
check-cfg = ['cfg(noop_authorizer)', 'cfg(genproto)', 'cfg(vss_client_v050_compatibility)']
19+
check-cfg = [
20+
'cfg(noop_authorizer)',
21+
'cfg(genproto)',
22+
'cfg(vss_client_v050_compatibility)',
23+
'cfg(vss_client_main_compatibility)',
24+
]

rust/server/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,8 @@ api = { path = "../api", features = ["_test_utils"] }
3232
[target.'cfg(vss_client_v050_compatibility)'.dev-dependencies]
3333
vss-client-v050 = { package = "vss-client-ng", version = "=0.5.0" }
3434

35+
[target.'cfg(vss_client_main_compatibility)'.dev-dependencies]
36+
vss-client-main = { package = "vss-client-ng", git = "https://github.com/lightningdevkit/vss-client.git", branch = "main" }
37+
3538
[lints]
3639
workspace = true

rust/server/tests/vss_client_v050_compatibility.rs renamed to rust/server/tests/vss_client_compatibility.rs

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
//! Compatibility shakedown for the pinned vss-client-ng v0.5.0 dependency against current
2-
//! vss-server master. This test assumes a no-auth VSS server is already running at
3-
//! `localhost:8080` and exercises a full client lifecycle through the public v0.5.0 client API:
4-
//! empty listing, missing-key reads, conditional and non-conditional writes, gets, conflict
5-
//! handling, transactional put/delete, direct deletes, paginated listing, and cleanup.
1+
//! Compatibility shakedown for vss-client-ng dependencies against current vss-server master. This
2+
//! test assumes a no-auth VSS server is already running at `localhost:8080` and exercises a full
3+
//! client lifecycle through the public client API: empty listing, missing-key reads, conditional
4+
//! and non-conditional writes, gets, conflict handling, transactional put/delete, direct deletes,
5+
//! paginated listing, and cleanup.
66
7-
#![cfg(vss_client_v050_compatibility)]
7+
#![cfg(any(vss_client_v050_compatibility, vss_client_main_compatibility))]
88

9-
use std::collections::{BTreeMap, BTreeSet};
109
use std::time::{Duration, SystemTime, UNIX_EPOCH};
1110

12-
use vss_client_v050::client::VssClient;
13-
use vss_client_v050::error::VssError;
14-
use vss_client_v050::types::{
11+
#[cfg(vss_client_v050_compatibility)]
12+
use vss_client_v050 as vss_client;
13+
#[cfg(vss_client_main_compatibility)]
14+
use vss_client_main as vss_client;
15+
use vss_client::client::VssClient;
16+
use vss_client::error::VssError;
17+
use vss_client::types::{
1518
DeleteObjectRequest, GetObjectRequest, GetObjectResponse, KeyValue, ListKeyVersionsRequest,
1619
PutObjectRequest,
1720
};
18-
use vss_client_v050::util::retry::{ExponentialBackoffRetryPolicy, RetryPolicy};
21+
use vss_client::util::retry::{ExponentialBackoffRetryPolicy, RetryPolicy};
1922

2023
const VSS_SERVER_BASE_URL: &str = "http://localhost:8080/vss";
2124
const KEY_ALPHA: &str = "compat/alpha";
@@ -31,7 +34,7 @@ const GLOBAL_VERSION_KEY: &str = "global_version";
3134
const LIST_PAGE_SIZE: i32 = 2;
3235

3336
#[tokio::test]
34-
async fn test_vss_client_v050_compatibility() -> Result<(), VssError> {
37+
async fn test_vss_client_compatibility() -> Result<(), VssError> {
3538
let client = VssClient::new(VSS_SERVER_BASE_URL.to_string(), retry_policy());
3639
let store_id = unique_store_id();
3740
let mut global_version = 0;
@@ -162,17 +165,32 @@ async fn test_vss_client_v050_compatibility() -> Result<(), VssError> {
162165

163166
let listed_versions =
164167
list_all_key_versions(&client, &store_id, Some(KEY_PREFIX), global_version).await?;
165-
let listed_keys: BTreeSet<&str> = listed_versions.keys().map(String::as_str).collect();
166-
// Prefix listing should include only the live keys under compat/ after deletes and conflicts.
167-
assert_eq!(listed_keys, BTreeSet::from([KEY_ALPHA, KEY_DELTA, KEY_EPSILON, KEY_THETA]));
168+
let listed_keys: Vec<&str> =
169+
listed_versions.iter().map(|(k, _v)| k).map(String::as_str).collect();
170+
// Prefix listing should include only the live keys under compat/ after deletes and conflicts, and
171+
// in creation order. vss-client-v050 does not require creation-time ordering, but it is within
172+
// its API contract. vss-client-v060 and onwards require creation-time ordering.
173+
assert_eq!(listed_keys, [KEY_EPSILON, KEY_THETA, KEY_DELTA, KEY_ALPHA]);
168174
// Listing should report alpha's latest key version.
169-
assert_eq!(listed_versions[KEY_ALPHA], 2);
175+
assert_eq!(
176+
listed_versions.iter().find_map(|(k, v)| (k == KEY_ALPHA).then_some(*v)).unwrap(),
177+
2
178+
);
170179
// Listing should report delta's non-conditional write version.
171-
assert_eq!(listed_versions[KEY_DELTA], 1);
180+
assert_eq!(
181+
listed_versions.iter().find_map(|(k, v)| (k == KEY_DELTA).then_some(*v)).unwrap(),
182+
1
183+
);
172184
// Listing should report epsilon's no-global-version write version.
173-
assert_eq!(listed_versions[KEY_EPSILON], 1);
185+
assert_eq!(
186+
listed_versions.iter().find_map(|(k, v)| (k == KEY_EPSILON).then_some(*v)).unwrap(),
187+
1
188+
);
174189
// Listing should report theta's transactional write version.
175-
assert_eq!(listed_versions[KEY_THETA], 1);
190+
assert_eq!(
191+
listed_versions.iter().find_map(|(k, v)| (k == KEY_THETA).then_some(*v)).unwrap(),
192+
1
193+
);
176194

177195
let cleanup_keys =
178196
[KEY_ALPHA, KEY_DELTA, KEY_EPSILON, KEY_THETA, KEY_OUTSIDE_PREFIX, GLOBAL_VERSION_KEY];
@@ -201,7 +219,7 @@ fn unique_store_id() -> String {
201219
.duration_since(UNIX_EPOCH)
202220
.expect("system clock must be after UNIX epoch")
203221
.as_nanos();
204-
format!("v050-compat-{nanos}")
222+
format!("vss-client-compat-{nanos}")
205223
}
206224

207225
fn get_request(store_id: &str, key: &str) -> GetObjectRequest {
@@ -249,7 +267,7 @@ async fn assert_key_value(
249267
assert_eq!(value.key, key);
250268
// The key-level version must match the lifecycle step's expected version.
251269
assert_eq!(value.version, expected_version);
252-
// The stored bytes must round-trip unchanged through the v0.5.0 client.
270+
// The stored bytes must round-trip unchanged through the client.
253271
assert_eq!(value.value, expected_value);
254272
Ok(())
255273
}
@@ -284,9 +302,9 @@ fn assert_conflict<T>(result: Result<T, VssError>) {
284302
async fn list_all_key_versions(
285303
client: &VssClient<impl RetryPolicy<E = VssError>>, store_id: &str, key_prefix: Option<&str>,
286304
expected_global_version: i64,
287-
) -> Result<BTreeMap<String, i64>, VssError> {
305+
) -> Result<Vec<(String, i64)>, VssError> {
288306
let mut page_token = None;
289-
let mut key_versions = BTreeMap::new();
307+
let mut key_versions = Vec::new();
290308
let mut page_count = 0;
291309

292310
loop {
@@ -313,7 +331,7 @@ async fn list_all_key_versions(
313331
for key_value in page.key_versions {
314332
// List responses should include only key/version metadata, not stored values.
315333
assert!(key_value.value.is_empty());
316-
key_versions.insert(key_value.key, key_value.version);
334+
key_versions.push((key_value.key, key_value.version));
317335
}
318336

319337
match page.next_page_token {

0 commit comments

Comments
 (0)