diff --git a/src/test/jtx/Env.h b/src/test/jtx/Env.h index de6b83362d..2b5397b903 100644 --- a/src/test/jtx/Env.h +++ b/src/test/jtx/Env.h @@ -589,13 +589,16 @@ public: } /** Return metadata for the last JTx. - - Effects: - - The open ledger is closed as if by a call - to close(). The metadata for the last - transaction ID, if any, is returned. - */ + * + * NOTE: this has a side effect of closing the open ledger. + * The ledger will only be closed if it includes transactions. + * + * Effects: + * + * The open ledger is closed as if by a call + * to close(). The metadata for the last + * transaction ID, if any, is returned. + */ std::shared_ptr meta(); diff --git a/src/test/jtx/impl/Env.cpp b/src/test/jtx/impl/Env.cpp index ac00d3eed1..e45042e310 100644 --- a/src/test/jtx/impl/Env.cpp +++ b/src/test/jtx/impl/Env.cpp @@ -446,7 +446,12 @@ Env::postconditions( std::shared_ptr Env::meta() { - close(); + if (current()->txCount() != 0) + { + // close the ledger if it has not already been closed + // (metadata is not finalized until the ledger is closed) + close(); + } auto const item = closed()->txRead(txid_); return item.second; }