aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbryan newbold <bnewbold@robocracy.org>2023-03-09 12:26:46 -0800
committerbryan newbold <bnewbold@robocracy.org>2023-03-09 12:26:46 -0800
commitbca44be1b01d2fd2f021cfaed344ff945f9b41b6 (patch)
tree23c1ecdbed971768f970b61a805c4be96d98fe3e
parent1c5ce5dd9b9c0883fa660c415c7336d6e1382e32 (diff)
downloadadenosine-bca44be1b01d2fd2f021cfaed344ff945f9b41b6.tar.gz
adenosine-bca44be1b01d2fd2f021cfaed344ff945f9b41b6.zip
mst interop: update to upstream (typescript) values
-rw-r--r--adenosine/tests/test_mst_interop.rs120
1 files changed, 60 insertions, 60 deletions
diff --git a/adenosine/tests/test_mst_interop.rs b/adenosine/tests/test_mst_interop.rs
index cfc8727..9c6f3df 100644
--- a/adenosine/tests/test_mst_interop.rs
+++ b/adenosine/tests/test_mst_interop.rs
@@ -16,48 +16,28 @@ fn test_known_maps() {
);
let mut trivial_map: BTreeMap<String, Cid> = Default::default();
- trivial_map.insert("asdf".to_string(), cid1);
+ trivial_map.insert("com.example.record/3jqfcqzm3fo2j".to_string(), cid1);
assert_eq!(
repo.mst_from_map(&trivial_map).unwrap().to_string(),
- "bafyreidaftbr35xhh4lzmv5jcoeufqjh75ohzmz6u56v7n2ippbtxdgqqe"
+ "bafyreibj4lsc3aqnrvphp5xmrnfoorvru4wynt6lwidqbm2623a6tatzdu"
);
let mut singlelayer2_map: BTreeMap<String, Cid> = Default::default();
- singlelayer2_map.insert("com.example.record/9ba1c7247ede".to_string(), cid1);
+ singlelayer2_map.insert("com.example.record/3jqfcqzm3fx2j".to_string(), cid1);
assert_eq!(
repo.mst_from_map(&singlelayer2_map).unwrap().to_string(),
- "bafyreid4g5smj6ukhrjasebt6myj7wmtm2eijouteoyueoqgoh6vm5jkae"
+ "bafyreih7wfei65pxzhauoibu3ls7jgmkju4bspy4t2ha2qdjnzqvoy33ai"
);
let mut simple_map: BTreeMap<String, Cid> = Default::default();
- simple_map.insert("asdf".to_string(), cid1);
- simple_map.insert("88bfafc7".to_string(), cid1);
- simple_map.insert("2a92d355".to_string(), cid1);
- simple_map.insert("app.bsky.feed.post/454397e440ec".to_string(), cid1);
- simple_map.insert("app.bsky.feed.post/9adeb165882c".to_string(), cid1);
+ simple_map.insert("com.example.record/3jqfcqzm3fp2j".to_string(), cid1);
+ simple_map.insert("com.example.record/3jqfcqzm3fr2j".to_string(), cid1);
+ simple_map.insert("com.example.record/3jqfcqzm3fs2j".to_string(), cid1);
+ simple_map.insert("com.example.record/3jqfcqzm3ft2j".to_string(), cid1);
+ simple_map.insert("com.example.record/3jqfcqzm4fc2j".to_string(), cid1);
assert_eq!(
repo.mst_from_map(&simple_map).unwrap().to_string(),
- "bafyreiecb33zh7r2sc3k2wthm6exwzfktof63kmajeildktqc25xj6qzx4"
- );
-}
-
-// TODO: behavior of these wide-char keys is undefined behavior in string MST
-#[ignore]
-#[test]
-fn test_tricky_map() {
- let mut repo = RepoStore::open_ephemeral().unwrap();
- let cid1 =
- Cid::from_str("bafyreie5cvv4h45feadgeuwhbcutmh6t2ceseocckahdoe6uat64zmz454").unwrap();
-
- let mut tricky_map: BTreeMap<String, Cid> = Default::default();
- tricky_map.insert("".to_string(), cid1);
- tricky_map.insert("jalapeño".to_string(), cid1);
- tricky_map.insert("coöperative".to_string(), cid1);
- tricky_map.insert("coüperative".to_string(), cid1);
- tricky_map.insert("abc\x00".to_string(), cid1);
- assert_eq!(
- repo.mst_from_map(&tricky_map).unwrap().to_string(),
- "bafyreiecb33zh7r2sc3k2wthm6exwzfktof63kmajeildktqc25xj6qzx4"
+ "bafyreicmahysq4n6wfuxo522m6dpiy7z7qzym3dzs756t5n7nfdgccwq7m"
);
}
@@ -69,24 +49,24 @@ fn test_trims_top() {
let mut repo = RepoStore::open_ephemeral().unwrap();
let cid1 =
Cid::from_str("bafyreie5cvv4h45feadgeuwhbcutmh6t2ceseocckahdoe6uat64zmz454").unwrap();
- let l1root = "bafyreihuyj2vzb2vjw3yhxg6dy25achg5fmre6gg5m6fjtxn64bqju4dee";
- let l0root = "bafyreibmijjc63mekkjzl3v2pegngwke5u6cu66g75z6uw27v64bc6ahqi";
+ let l1root = "bafyreifnqrwbk6ffmyaz5qtujqrzf5qmxf7cbxvgzktl4e3gabuxbtatv4";
+ let l0root = "bafyreie4kjuxbwkhzg2i5dljaswcroeih4dgiqq6pazcmunwt2byd725vi";
// NOTE: this test doesn't do much in this case of rust implementation
let mut trim_map: BTreeMap<String, Cid> = Default::default();
- trim_map.insert("com.example.record/40c73105b48f".to_string(), cid1); // level 0
- trim_map.insert("com.example.record/e99bf3ced34b".to_string(), cid1); // level 0
- trim_map.insert("com.example.record/893e6c08b450".to_string(), cid1); // level 0
- trim_map.insert("com.example.record/9cd8b6c0cc02".to_string(), cid1); // level 0
- trim_map.insert("com.example.record/cbe72d33d12a".to_string(), cid1); // level 0
- trim_map.insert("com.example.record/a15e33ba0f6c".to_string(), cid1); // level 1
+ trim_map.insert("com.example.record/3jqfcqzm3fn2j".to_string(), cid1); // level 0
+ trim_map.insert("com.example.record/3jqfcqzm3fo2j".to_string(), cid1); // level 0
+ trim_map.insert("com.example.record/3jqfcqzm3fp2j".to_string(), cid1); // level 0
+ trim_map.insert("com.example.record/3jqfcqzm3fs2j".to_string(), cid1); // level 0
+ trim_map.insert("com.example.record/3jqfcqzm3ft2j".to_string(), cid1); // level 0
+ trim_map.insert("com.example.record/3jqfcqzm3fu2j".to_string(), cid1); // level 1
let trim_before_cid = repo.mst_from_map(&trim_map).unwrap();
print_mst_keys(&mut repo.db, &trim_before_cid).unwrap();
assert_eq!(trim_before_cid.to_string(), l1root);
// NOTE: if we did mutations in-place, this is where we would mutate
- trim_map.remove("com.example.record/a15e33ba0f6c");
+ trim_map.remove("com.example.record/3jqfcqzm3fs2j");
let trim_after_cid = repo.mst_from_map(&trim_map).unwrap();
assert_eq!(trim_after_cid.to_string(), l0root);
}
@@ -98,28 +78,34 @@ fn test_insertion() {
let mut repo = RepoStore::open_ephemeral().unwrap();
let cid1 =
Cid::from_str("bafyreie5cvv4h45feadgeuwhbcutmh6t2ceseocckahdoe6uat64zmz454").unwrap();
- let l1root = "bafyreiagt55jzvkenoa4yik77dhomagq2uj26ix4cijj7kd2py2u3s43ve";
- let l2root = "bafyreiddrz7qbvfattp5dzzh4ldohsaobatsg7f5l6awxnmuydewq66qoa";
+ let l1root = "bafyreiettyludka6fpgp33stwxfuwhkzlur6chs4d2v4nkmq2j3ogpdjem";
+ let l2root = "bafyreid2x5eqs4w4qxvc5jiwda4cien3gw2q6cshofxwnvv7iucrmfohpm";
// TODO: actual mutation instead of rebuild from scratch
let mut insertion_map: BTreeMap<String, Cid> = Default::default();
- insertion_map.insert("com.example.record/403e2aeebfdb".to_string(), cid1); // A; level 0
- insertion_map.insert("com.example.record/40c73105b48f".to_string(), cid1); // B; level 0
- insertion_map.insert("com.example.record/645787eb4316".to_string(), cid1); // C; level 0
- insertion_map.insert("com.example.record/7ca4e61d6fbc".to_string(), cid1); // D; level 1
- insertion_map.insert("com.example.record/893e6c08b450".to_string(), cid1); // E; level 0
- insertion_map.insert("com.example.record/9cd8b6c0cc02".to_string(), cid1); // G; level 0
- insertion_map.insert("com.example.record/cbe72d33d12a".to_string(), cid1); // H; level 0
- insertion_map.insert("com.example.record/dbea731be795".to_string(), cid1); // I; level 1
- insertion_map.insert("com.example.record/e2ef555433f2".to_string(), cid1); // J; level 0
- insertion_map.insert("com.example.record/e99bf3ced34b".to_string(), cid1); // K; level 0
- insertion_map.insert("com.example.record/f728ba61e4b6".to_string(), cid1); // L; level 0
+ insertion_map.insert("com.example.record/3jqfcqzm3fo2j".to_string(), cid1); // A; level 0
+ insertion_map.insert("com.example.record/3jqfcqzm3fp2j".to_string(), cid1); // B; level 0
+ insertion_map.insert("com.example.record/3jqfcqzm3fr2j".to_string(), cid1); // C; level 0
+ insertion_map.insert("com.example.record/3jqfcqzm3fs2j".to_string(), cid1); // D; level 1
+ insertion_map.insert("com.example.record/3jqfcqzm3ft2j".to_string(), cid1); // E; level 0
+ insertion_map.insert("com.example.record/3jqfcqzm3fz2j".to_string(), cid1); // G; level 0
+ insertion_map.insert("com.example.record/3jqfcqzm4fc2j".to_string(), cid1); // H; level 0
+ insertion_map.insert("com.example.record/3jqfcqzm4fd2j".to_string(), cid1); // I; level 1
+ insertion_map.insert("com.example.record/3jqfcqzm4ff2j".to_string(), cid1); // J; level 0
+ insertion_map.insert("com.example.record/3jqfcqzm4fg2j".to_string(), cid1); // K; level 0
+ insertion_map.insert("com.example.record/3jqfcqzm4fh2j".to_string(), cid1); // L; level 0
let insertion_before_cid = repo.mst_from_map(&insertion_map).unwrap();
assert_eq!(insertion_before_cid.to_string(), l1root);
- insertion_map.insert("com.example.record/9ba1c7247ede".to_string(), cid1);
+ // insert F, which will push E out of the node with G+H to a new node under D
+ insertion_map.insert("com.example.record/3jqfcqzm3fx2j".to_string(), cid1);
let insertion_after_cid = repo.mst_from_map(&insertion_map).unwrap();
assert_eq!(insertion_after_cid.to_string(), l2root);
+
+ // remove F, which should push E back over with G+H
+ insertion_map.remove("com.example.record/3jqfcqzm3fx2j");
+ let insertion_after_cid = repo.mst_from_map(&insertion_map).unwrap();
+ assert_eq!(insertion_after_cid.to_string(), l1root);
}
#[test]
@@ -130,23 +116,37 @@ fn test_higher_layers() {
let mut repo = RepoStore::open_ephemeral().unwrap();
let cid1 =
Cid::from_str("bafyreie5cvv4h45feadgeuwhbcutmh6t2ceseocckahdoe6uat64zmz454").unwrap();
- let l0root = "bafyreicivoa3p3ttcebdn2zfkdzenkd2uk3gxxlaz43qvueeip6yysvq2m";
- let l2root = "bafyreidwoqm6xlewxzhrx6ytbyhsazctlv72txtmnd4au6t53z2vpzn7wa";
- let l2root2 = "bafyreiapru27ce4wdlylk5revtr3hewmxhmt3ek5f2ypioiivmdbv5igrm";
+ let l0root = "bafyreidfcktqnfmykz2ps3dbul35pepleq7kvv526g47xahuz3rqtptmky";
+ let l2root = "bafyreiavxaxdz7o7rbvr3zg2liox2yww46t7g6hkehx4i4h3lwudly7dhy";
+ let l2root2 = "bafyreig4jv3vuajbsybhyvb7gggvpwh2zszwfyttjrj6qwvcsp24h6popu";
// TODO: actual mutation instead of rebuild from scratch
let mut higher_map: BTreeMap<String, Cid> = Default::default();
- higher_map.insert("com.example.record/403e2aeebfdb".to_string(), cid1); // A; level 0
- higher_map.insert("com.example.record/cbe72d33d12a".to_string(), cid1); // C; level 0
+ higher_map.insert("com.example.record/3jqfcqzm3ft2j".to_string(), cid1); // A; level 0
+ higher_map.insert("com.example.record/3jqfcqzm3fz2j".to_string(), cid1); // C; level 0
let higher_before_cid = repo.mst_from_map(&higher_map).unwrap();
assert_eq!(higher_before_cid.to_string(), l0root);
- higher_map.insert("com.example.record/9ba1c7247ede".to_string(), cid1); // B; level 2
+ // insert B, which is two levels above
+ higher_map.insert("com.example.record/3jqfcqzm3fx2j".to_string(), cid1); // B; level 2
let higher_after_cid = repo.mst_from_map(&higher_map).unwrap();
print_mst_keys(&mut repo.db, &higher_after_cid).unwrap();
assert_eq!(higher_after_cid.to_string(), l2root);
- higher_map.insert("com.example.record/fae7a851fbeb".to_string(), cid1); // D; level 1
+ // remove B
+ higher_map.remove("com.example.record/3jqfcqzm3fx2j");
+ let higher_after_cid = repo.mst_from_map(&higher_map).unwrap();
+ print_mst_keys(&mut repo.db, &higher_after_cid).unwrap();
+ assert_eq!(higher_after_cid.to_string(), l0root);
+
+ // insert B (level=2) and D (level=1)
+ higher_map.insert("com.example.record/3jqfcqzm3fx2j".to_string(), cid1); // B; level 2
+ higher_map.insert("com.example.record/3jqfcqzm4fd2j".to_string(), cid1); // D; level 1
let higher_after_cid = repo.mst_from_map(&higher_map).unwrap();
assert_eq!(higher_after_cid.to_string(), l2root2);
+
+ // remove D
+ higher_map.remove("com.example.record/3jqfcqzm4fd2j");
+ let higher_after_cid = repo.mst_from_map(&higher_map).unwrap();
+ assert_eq!(higher_after_cid.to_string(), l2root);
}