Skip to content

Commit 3a1d16f

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 3a1d16f

5 files changed

Lines changed: 76 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: 43 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
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_main_compatibility)]
12+
use vss_client_main as vss_client;
13+
#[cfg(vss_client_v050_compatibility)]
14+
use vss_client_v050 as vss_client;
15+
16+
use vss_client::client::VssClient;
17+
use vss_client::error::VssError;
18+
use vss_client::types::{
1519
DeleteObjectRequest, GetObjectRequest, GetObjectResponse, KeyValue, ListKeyVersionsRequest,
1620
PutObjectRequest,
1721
};
18-
use vss_client_v050::util::retry::{ExponentialBackoffRetryPolicy, RetryPolicy};
22+
use vss_client::util::retry::{ExponentialBackoffRetryPolicy, RetryPolicy};
1923

2024
const VSS_SERVER_BASE_URL: &str = "http://localhost:8080/vss";
2125
const KEY_ALPHA: &str = "compat/alpha";
@@ -31,7 +35,7 @@ const GLOBAL_VERSION_KEY: &str = "global_version";
3135
const LIST_PAGE_SIZE: i32 = 2;
3236

3337
#[tokio::test]
34-
async fn test_vss_client_v050_compatibility() -> Result<(), VssError> {
38+
async fn test_vss_client_compatibility() -> Result<(), VssError> {
3539
let client = VssClient::new(VSS_SERVER_BASE_URL.to_string(), retry_policy());
3640
let store_id = unique_store_id();
3741
let mut global_version = 0;
@@ -162,17 +166,32 @@ async fn test_vss_client_v050_compatibility() -> Result<(), VssError> {
162166

163167
let listed_versions =
164168
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]));
169+
let listed_keys: Vec<&str> =
170+
listed_versions.iter().map(|(k, _v)| k).map(String::as_str).collect();
171+
// Prefix listing should include only the live keys under compat/ after deletes and conflicts, and
172+
// in creation order. vss-client-v050 does not require creation-time ordering, but it is within
173+
// its API contract. vss-client-v060 and onwards require creation-time ordering.
174+
assert_eq!(listed_keys, [KEY_EPSILON, KEY_THETA, KEY_DELTA, KEY_ALPHA]);
168175
// Listing should report alpha's latest key version.
169-
assert_eq!(listed_versions[KEY_ALPHA], 2);
176+
assert_eq!(
177+
listed_versions.iter().find_map(|(k, v)| (k == KEY_ALPHA).then_some(*v)).unwrap(),
178+
2
179+
);
170180
// Listing should report delta's non-conditional write version.
171-
assert_eq!(listed_versions[KEY_DELTA], 1);
181+
assert_eq!(
182+
listed_versions.iter().find_map(|(k, v)| (k == KEY_DELTA).then_some(*v)).unwrap(),
183+
1
184+
);
172185
// Listing should report epsilon's no-global-version write version.
173-
assert_eq!(listed_versions[KEY_EPSILON], 1);
186+
assert_eq!(
187+
listed_versions.iter().find_map(|(k, v)| (k == KEY_EPSILON).then_some(*v)).unwrap(),
188+
1
189+
);
174190
// Listing should report theta's transactional write version.
175-
assert_eq!(listed_versions[KEY_THETA], 1);
191+
assert_eq!(
192+
listed_versions.iter().find_map(|(k, v)| (k == KEY_THETA).then_some(*v)).unwrap(),
193+
1
194+
);
176195

177196
let cleanup_keys =
178197
[KEY_ALPHA, KEY_DELTA, KEY_EPSILON, KEY_THETA, KEY_OUTSIDE_PREFIX, GLOBAL_VERSION_KEY];
@@ -201,7 +220,7 @@ fn unique_store_id() -> String {
201220
.duration_since(UNIX_EPOCH)
202221
.expect("system clock must be after UNIX epoch")
203222
.as_nanos();
204-
format!("v050-compat-{nanos}")
223+
format!("vss-client-compat-{nanos}")
205224
}
206225

207226
fn get_request(store_id: &str, key: &str) -> GetObjectRequest {
@@ -249,7 +268,7 @@ async fn assert_key_value(
249268
assert_eq!(value.key, key);
250269
// The key-level version must match the lifecycle step's expected version.
251270
assert_eq!(value.version, expected_version);
252-
// The stored bytes must round-trip unchanged through the v0.5.0 client.
271+
// The stored bytes must round-trip unchanged through the client.
253272
assert_eq!(value.value, expected_value);
254273
Ok(())
255274
}
@@ -284,9 +303,9 @@ fn assert_conflict<T>(result: Result<T, VssError>) {
284303
async fn list_all_key_versions(
285304
client: &VssClient<impl RetryPolicy<E = VssError>>, store_id: &str, key_prefix: Option<&str>,
286305
expected_global_version: i64,
287-
) -> Result<BTreeMap<String, i64>, VssError> {
306+
) -> Result<Vec<(String, i64)>, VssError> {
288307
let mut page_token = None;
289-
let mut key_versions = BTreeMap::new();
308+
let mut key_versions = Vec::new();
290309
let mut page_count = 0;
291310

292311
loop {
@@ -313,7 +332,7 @@ async fn list_all_key_versions(
313332
for key_value in page.key_versions {
314333
// List responses should include only key/version metadata, not stored values.
315334
assert!(key_value.value.is_empty());
316-
key_versions.insert(key_value.key, key_value.version);
335+
key_versions.push((key_value.key, key_value.version));
317336
}
318337

319338
match page.next_page_token {

0 commit comments

Comments
 (0)