Skip to content

Commit 25c986c

Browse files
committed
fix(bindingtester): fix steps until 65 for seed 1330929912
1 parent 315b2c8 commit 25c986c

File tree

3 files changed

+64
-53
lines changed

3 files changed

+64
-53
lines changed

foundationdb-bindingtester/src/main.rs

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#[macro_use]
22
extern crate log;
33

4+
// TODO: Fix 1330929912
5+
46
use foundationdb as fdb;
57
use foundationdb_sys as fdb_sys;
68

@@ -706,8 +708,8 @@ impl StackMachine {
706708
}
707709
}
708710

709-
fn push_directory_err(&mut self, code: InstrCode, number: usize, err: DirectoryError) {
710-
debug!("DIRECTORY_ERROR during {:?}: {:?}", code, err);
711+
fn push_directory_err(&mut self, code: &InstrCode, number: usize, err: DirectoryError) {
712+
error!("DIRECTORY_ERROR during {:?}: {:?}", code, err);
711713
let packed = pack(&(ERROR_DIRECTORY));
712714
self.push(number, Element::Bytes(packed.into()));
713715

@@ -719,8 +721,8 @@ impl StackMachine {
719721
| InstrCode::DirectoryMoveTo
720722
| InstrCode::DirectoryOpenSubspace = code
721723
{
722-
debug!(
723-
"pushed NULL in the directory_stack at index {} because of an error",
724+
error!(
725+
"pushed NULL in the directory_stack at index {} because of the error",
724726
self.directory_stack.len()
725727
);
726728
self.directory_stack.push(DirectoryStackItem::Null);
@@ -1738,7 +1740,7 @@ impl StackMachine {
17381740
}
17391741
};
17401742

1741-
let directory_subspace = match directory
1743+
match directory
17421744
.create(
17431745
txn,
17441746
(*path.get(0).unwrap().to_owned()).to_vec(),
@@ -1747,23 +1749,23 @@ impl StackMachine {
17471749
)
17481750
.await
17491751
{
1750-
Ok(s) => s,
1752+
Ok(directory_subspace) => {
1753+
debug!(
1754+
"pushing created {:?} at index {}",
1755+
&directory_subspace,
1756+
self.directory_stack.len()
1757+
);
1758+
self.directory_stack
1759+
.push(DirectoryStackItem::DirectorySubspace(directory_subspace));
1760+
}
17511761
Err(e) => {
1752-
panic!("could not call directory.create: {:?}", e);
1762+
self.push_directory_err(&instr.code, number, e);
17531763
}
17541764
};
1755-
1756-
debug!(
1757-
"pushing created {:?} at index {}",
1758-
&directory_subspace,
1759-
self.directory_stack.len()
1760-
);
1761-
self.directory_stack
1762-
.push(DirectoryStackItem::DirectorySubspace(directory_subspace));
17631765
}
17641766

17651767
DirectoryOpen => {
1766-
debug!("Open stack: {:?}", self.stack);
1768+
debug!("DirectoryOpen stack: {:?}", self.stack);
17671769

17681770
let path = self.pop_tuple(1).await;
17691771
let bytes_layer = self.pop_bytes().await;
@@ -1785,24 +1787,23 @@ impl StackMachine {
17851787
}
17861788
};
17871789

1788-
let directory_subspace = match directory
1790+
match directory
17891791
.open(txn, (*path.get(0).unwrap().to_owned()).to_vec(), layer)
17901792
.await
17911793
{
1792-
Ok(s) => s,
1794+
Ok(directory_subspace) => {
1795+
debug!(
1796+
"pushing newly opened {:?} at index {}",
1797+
&directory_subspace,
1798+
self.directory_stack.len()
1799+
);
1800+
self.directory_stack
1801+
.push(DirectoryStackItem::DirectorySubspace(directory_subspace));
1802+
}
17931803
Err(e) => {
1794-
self.push_directory_err(instr.code, number, e);
1795-
return Err(());
1804+
self.push_directory_err(&instr.code, number, e);
17961805
}
17971806
};
1798-
1799-
debug!(
1800-
"pushing newly opened {:?} at index {}",
1801-
&directory_subspace,
1802-
self.directory_stack.len()
1803-
);
1804-
self.directory_stack
1805-
.push(DirectoryStackItem::DirectorySubspace(directory_subspace));
18061807
}
18071808

18081809
// Use the current directory for this operation.
@@ -1989,21 +1990,20 @@ impl StackMachine {
19891990

19901991
let paths = paths.get(0).expect("could not retrieve a path");
19911992

1992-
let children = match directory.list(txn, paths.to_vec()).await {
1993-
Ok(v) => v,
1993+
match directory.list(txn, paths.to_vec()).await {
1994+
Ok(children) => {
1995+
let mut elements: Vec<Element> = vec![];
1996+
for child in children {
1997+
let element = Element::String(Cow::from(child));
1998+
elements.push(element);
1999+
}
2000+
let tuple = Element::Tuple(elements);
2001+
self.push(number, Element::Bytes(pack(&tuple).into()));
2002+
}
19942003
Err(e) => {
1995-
self.push_directory_err(instr.code, number, e);
1996-
return Err(());
2004+
self.push_directory_err(&instr.code, number, e);
19972005
}
19982006
};
1999-
2000-
let mut elements: Vec<Element> = vec![];
2001-
for child in children {
2002-
let element = Element::String(Cow::from(child));
2003-
elements.push(element);
2004-
}
2005-
let tuple = Element::Tuple(elements);
2006-
self.push(number, Element::Bytes(pack(&tuple).into()));
20072007
}
20082008

20092009
// Use the current directory for this operation.
@@ -2029,14 +2029,14 @@ impl StackMachine {
20292029
};
20302030

20312031
let paths = paths.get(0).expect("could not retrieve a path");
2032-
let exists = match directory.exists(txn, paths.to_owned()).await {
2033-
Ok(exist) => exist,
2032+
match directory.exists(txn, paths.to_owned()).await {
2033+
Ok(exists) => {
2034+
self.push(number, Element::Int(i64::from(exists)));
2035+
}
20342036
Err(e) => {
2035-
self.push_directory_err(instr.code, number, e);
2036-
return Err(());
2037+
self.push_directory_err(&instr.code, number, e);
20372038
}
20382039
};
2039-
self.push(number, Element::Int(i64::from(exists)));
20402040
}
20412041

20422042
// Use the current directory for this operation.

foundationdb/src/directory/directory_layer.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,10 @@ impl Directory for DirectoryLayer {
143143

144144
/// `exists` returns true if the directory at path (relative to the default root directory) exists, and false otherwise.
145145
async fn exists(&self, trx: &Transaction, path: Vec<String>) -> Result<bool, DirectoryError> {
146-
match dbg!(self.find_node(trx, path.to_owned(), false, None).await) {
146+
match dbg!(
147+
self.find_or_create_node(trx, path.to_owned(), false, None, None)
148+
.await
149+
) {
147150
Ok(_node) => Ok(true),
148151
Err(err) => match err {
149152
DirectoryError::PathDoesNotExists => Ok(false),
@@ -169,7 +172,9 @@ impl Directory for DirectoryLayer {
169172
/// `remove` the subdirectory of this Directory located at `path` and all of its subdirectories,
170173
/// as well as all of their contents.
171174
async fn remove(&self, trx: &Transaction, path: Vec<String>) -> Result<bool, DirectoryError> {
172-
let node = self.find_node(trx, path.to_owned(), false, None).await?;
175+
let node = self
176+
.find_or_create_node(trx, path.to_owned(), false, None, None)
177+
.await?;
173178
node.remove_all(trx).await?;
174179
Ok(true)
175180
}
@@ -181,7 +186,9 @@ impl Directory for DirectoryLayer {
181186
trx: &Transaction,
182187
path: Vec<String>,
183188
) -> Result<Vec<String>, DirectoryError> {
184-
let node = self.find_node(trx, path.to_owned(), false, None).await?;
189+
let node = self
190+
.find_or_create_node(trx, path.to_owned(), false, None, None)
191+
.await?;
185192
node.list(&trx).await
186193
}
187194
}
@@ -213,11 +220,16 @@ impl DirectoryLayer {
213220
}
214221

215222
match self
216-
.find_node(&trx, path.to_owned(), allow_create, prefix.to_owned())
223+
.find_or_create_node(
224+
&trx,
225+
path.to_owned(),
226+
allow_create,
227+
prefix.to_owned(),
228+
layer.to_owned(),
229+
)
217230
.await
218231
{
219232
Ok(node) => {
220-
// node exists, checking layer
221233
if !allow_open {
222234
return Err(DirectoryError::DirAlreadyExists);
223235
}
@@ -333,7 +345,7 @@ impl DirectoryLayer {
333345
Ok(())
334346
}
335347

336-
async fn find_node(
348+
async fn find_or_create_node(
337349
&self,
338350
trx: &Transaction,
339351
path: Vec<String>,
@@ -404,8 +416,6 @@ impl DirectoryLayer {
404416
}
405417
}
406418

407-
dbg!(&node);
408-
409419
Ok(node)
410420
}
411421

foundationdb/src/directory/node.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ impl Node {
3636
/// `check_layer` is checking the layer, throwing `IncompatibleLayer` when
3737
/// the provided layer does not match the one provided.
3838
pub(crate) fn check_layer(&self, layer: Vec<u8>) -> Result<(), DirectoryError> {
39+
dbg!(&self.layer, &layer);
3940
match &self.layer {
4041
None => Err(DirectoryError::IncompatibleLayer),
4142
Some(layer_bytes) => {

0 commit comments

Comments
 (0)