Skip to content

Commit 1e46135

Browse files
committed
fix(bindingtester): push error during get bytes on directoryPartition
1 parent a17a367 commit 1e46135

File tree

1 file changed

+35
-14
lines changed
  • foundationdb-bindingtester/src

1 file changed

+35
-14
lines changed

foundationdb-bindingtester/src/main.rs

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2274,7 +2274,7 @@ impl StackMachine {
22742274
buf.push(element);
22752275
}
22762276

2277-
match self.get_current_item() {
2277+
match self.get_current_directory_item() {
22782278
Some(DirectoryStackItem::DirectoryOutput(
22792279
DirectoryOutput::DirectoryPartition(d),
22802280
)) => {
@@ -2300,7 +2300,7 @@ impl StackMachine {
23002300
// the specified key. Push 1 if it does and 0 if it doesn't.
23012301
DirectoryContains => {
23022302
let raw_prefix = self.pop_bytes().await;
2303-
let b = match self.get_current_item() {
2303+
let b = match self.get_current_directory_item() {
23042304
None => panic!("not found"),
23052305
Some(DirectoryStackItem::Subspace(s)) => s.is_start_of(&raw_prefix.to_vec()),
23062306
Some(DirectoryStackItem::DirectoryOutput(d)) => match d {
@@ -2355,23 +2355,44 @@ impl StackMachine {
23552355
};
23562356
let key = Subspace::from_bytes(&*raw_prefix).pack(&self.directory_index);
23572357

2358-
let value = match self.directory_stack.get(self.directory_index) {
2358+
match self.directory_stack.get(self.directory_index) {
23592359
None => panic!("nothing in the stack"),
23602360
Some(DirectoryStackItem::Null) => panic!("Directory is NULL"),
23612361
Some(DirectoryStackItem::Directory(_)) => {
23622362
panic!("trying to get a subspace, got a Directory")
23632363
}
2364-
Some(DirectoryStackItem::DirectoryOutput(d)) => d.bytes(),
2365-
Some(DirectoryStackItem::Subspace(s)) => s.bytes(),
2364+
Some(DirectoryStackItem::DirectoryOutput(
2365+
DirectoryOutput::DirectorySubspace(d),
2366+
)) => {
2367+
txn.set(&key, d.bytes());
2368+
println!(
2369+
"logging subspace [{}] {:?}={:?}",
2370+
self.directory_index,
2371+
unpack::<Vec<Element>>(&key).unwrap(),
2372+
d.bytes(),
2373+
);
2374+
}
2375+
Some(DirectoryStackItem::DirectoryOutput(
2376+
DirectoryOutput::DirectoryPartition(_),
2377+
)) => {
2378+
self.push_directory_err(
2379+
&instr.code,
2380+
number,
2381+
DirectoryError::Other(String::from(
2382+
"cannot get key for the root of a directory partition",
2383+
)),
2384+
);
2385+
}
2386+
Some(DirectoryStackItem::Subspace(s)) => {
2387+
txn.set(&key, s.bytes());
2388+
println!(
2389+
"logging subspace [{}] {:?}={:?}",
2390+
self.directory_index,
2391+
unpack::<Vec<Element>>(&key).unwrap(),
2392+
s.bytes(),
2393+
);
2394+
}
23662395
};
2367-
2368-
txn.set(&key, &value);
2369-
println!(
2370-
"logging subspace [{}] {:?}={:?}",
2371-
self.directory_index,
2372-
unpack::<Vec<Element>>(&key).unwrap(),
2373-
&value
2374-
);
23752396
}
23762397

23772398
// Use the current directory for this operation.
@@ -2543,7 +2564,7 @@ impl StackMachine {
25432564
}
25442565
}
25452566

2546-
fn get_current_item(&self) -> Option<&DirectoryStackItem> {
2567+
fn get_current_directory_item(&mut self) -> Option<&DirectoryStackItem> {
25472568
self.directory_stack.get(self.directory_index)
25482569
}
25492570

0 commit comments

Comments
 (0)