very fast at protocol indexer with flexible filtering, xrpc queries, cursor-backed event stream, and more, built on fjall
rust fjall at-protocol atproto indexer
60
fork

Configure Feed

Select the types of activity you want to include in your feed.

[tests] also compare prev cid in car test case

dawn 31d21bac 558934f5

+27 -33
+27 -33
tests/repo_sync_integrity.nu
··· 93 93 $success 94 94 } 95 95 96 - # sanity check: compare getLatestCommit cid and rev between hydrant and pds 96 + # compare getLatestCommit between hydrant and pds; returns the commit record on success, null on failure 97 97 def check-latest-commit [hydrant_url: string, pds_url: string, did: string] { 98 98 print "checking getLatestCommit..." 99 99 100 - let hydrant_commit = try { 100 + let h = try { 101 101 http get $"($hydrant_url)/xrpc/com.atproto.sync.getLatestCommit?did=($did)" 102 102 } catch { 103 103 print " error fetching getLatestCommit from hydrant" 104 - return false 104 + return null 105 105 } 106 106 107 - let pds_commit = try { 107 + let p = try { 108 108 http get $"($pds_url)/xrpc/com.atproto.sync.getLatestCommit?did=($did)" 109 109 } catch { 110 110 print " error fetching getLatestCommit from pds" 111 - return false 111 + return null 112 112 } 113 113 114 - print $" hydrant: cid=($hydrant_commit.cid) rev=($hydrant_commit.rev)" 115 - print $" pds: cid=($pds_commit.cid) rev=($pds_commit.rev)" 114 + print $" cid=($h.cid) rev=($h.rev)" 116 115 117 - if $hydrant_commit.cid != $pds_commit.cid or $hydrant_commit.rev != $pds_commit.rev { 118 - print " MISMATCH: commit differs!" 119 - return false 116 + if $h.cid != $p.cid or $h.rev != $p.rev { 117 + print $" MISMATCH: hydrant cid=($h.cid) rev=($h.rev) vs pds cid=($p.cid) rev=($p.rev)" 118 + return null 120 119 } 121 120 122 121 print " ok" 123 - true 122 + $h 124 123 } 125 124 126 125 # parse `goat repo inspect` output into a record ··· 128 127 $in | lines | parse "{key}: {value}" | transpose -r -d 129 128 } 130 129 130 + # fetch a getRepo CAR and return its `goat repo inspect` info 131 + def fetch-car-info [url: string, did: string] { 132 + let car = http get $"($url)/xrpc/com.atproto.sync.getRepo?did=($did)" 133 + let tmp = (mktemp --suffix ".car") 134 + $car | save --force $tmp 135 + let info = (nix-shell -p atproto-goat --run $"goat repo inspect ($tmp)" | parse-goat-inspect) 136 + rm $tmp 137 + $info 138 + } 139 + 131 140 # fetch getRepo CARs from hydrant and pds and compare via `goat repo inspect` 132 141 def check-car [hydrant_url: string, pds_url: string, did: string] { 133 142 print "checking getRepo CAR..." 134 143 135 - let hydrant_car = try { 136 - http get $"($hydrant_url)/xrpc/com.atproto.sync.getRepo?did=($did)" 137 - } catch { 144 + let h = try { fetch-car-info $hydrant_url $did } catch { 138 145 print " error fetching CAR from hydrant" 139 146 return false 140 147 } 141 148 142 - let pds_car = try { 143 - http get $"($pds_url)/xrpc/com.atproto.sync.getRepo?did=($did)" 144 - } catch { 149 + let p = try { fetch-car-info $pds_url $did } catch { 145 150 print " error fetching CAR from pds" 146 151 return false 147 152 } 148 153 149 - let h_tmp = (mktemp --suffix ".car") 150 - let p_tmp = (mktemp --suffix ".car") 151 - $hydrant_car | save --force $h_tmp 152 - $pds_car | save --force $p_tmp 153 - 154 - print $"hydrant car: ($h_tmp)" 155 - print $"pds car: ($p_tmp)" 156 - 157 - let h_info = (nix-shell -p atproto-goat --run $"goat repo inspect ($h_tmp)" | parse-goat-inspect) 158 - let p_info = (nix-shell -p atproto-goat --run $"goat repo inspect ($p_tmp)" | parse-goat-inspect) 159 - rm $h_tmp $p_tmp 160 - 161 - print $" hydrant: data=($h_info.'Data CID') rev=($h_info.Revision)" 162 - print $" pds: data=($p_info.'Data CID') rev=($p_info.Revision)" 154 + print $" hydrant: data=($h.'Data CID') prev=($h.'Prev CID') rev=($h.Revision)" 155 + print $" pds: data=($p.'Data CID') prev=($p.'Prev CID') rev=($p.Revision)" 163 156 164 - if $h_info.'Data CID' != $p_info.'Data CID' or $h_info.Revision != $p_info.Revision { 157 + if $h.'Data CID' != $p.'Data CID' or $h.'Prev CID' != $p.'Prev CID' or $h.Revision != $p.Revision { 165 158 print " MISMATCH: CARs differ!" 166 159 return false 167 160 } ··· 195 188 if (wait-for-backfill $url) { 196 189 let integrity_passed = (check-consistency $url $pds $did) 197 190 let count_passed = (check-count $url $debug_url $did) 198 - let commit_passed = (check-latest-commit $url $pds $did) 191 + let commit = (check-latest-commit $url $pds $did) 192 + let commit_passed = $commit != null 199 193 let car_passed = if $commit_passed { check-car $url $pds $did } else { false } 200 194 201 195 if $integrity_passed and $count_passed and $commit_passed and $car_passed {