Skip to content

Commit 496262a

Browse files
committed
Add block reset to write_test.
1 parent 77e52fb commit 496262a

File tree

1 file changed

+13
-28
lines changed

1 file changed

+13
-28
lines changed

console/executor_test_writer.cpp

Lines changed: 13 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@
2525
namespace libbitcoin {
2626
namespace node {
2727

28-
////using boost::format;
28+
using boost::format;
2929
using namespace network;
3030
using namespace system;
3131

32+
#if defined(UNDEFINED)
33+
3234
// arbitrary testing (non-const).
3335
void executor::write_test(const hash_digest&)
3436
{
3537
logger("No write test implemented.");
3638
}
3739

38-
#if defined(UNDEFINED)
39-
4040
void executor::write_test(const system::hash_digest&)
4141
{
4242
for (database::header_link link{ 793'008_u32 }; link < 885'000_u32; ++link)
@@ -201,40 +201,25 @@ void executor::write_test(const system::hash_digest&)
201201
logger(format("block" BN_WRITE_ROW) % height % span.count());
202202
}
203203

204-
void executor::write_test(const system::hash_digest&)
205-
{
206-
constexpr auto hash251684 = base16_hash(
207-
"00000000000000720e4c59ad28a8b61f38015808e92465e53111e3463aed80de");
208-
const auto link = query_.to_header(hash251684);
204+
#endif // UNDEFINED
209205

206+
void executor::write_test(const system::hash_digest& hash)
207+
{
208+
const auto id = encode_hash(hash);
209+
const auto link = query_.to_header(hash);
210210
if (link.is_terminal())
211211
{
212-
logger("link.is_terminal()");
213-
return;
212+
logger(format("Block [%1%] not found.") % id);
214213
}
215-
216-
if (query_.confirmed_records() != 251684u)
217-
{
218-
logger("!query_.confirmed_records() != 251684u");
219-
return;
220-
}
221-
222-
if (!query_.push_confirmed(link, true))
214+
else if (query_.set_block_unknown(link))
223215
{
224-
logger("!query_.push_confirmed(link)");
225-
return;
216+
logger(format("Successfully reset block [%1%].") % id);
226217
}
227-
228-
if (query_.confirmed_records() != 251685u)
218+
else
229219
{
230-
logger("!query_.confirmed_records() != 251685u");
231-
return;
220+
logger(format("Failed to reset block [%1%].") % id);
232221
}
233-
234-
logger("Successfully confirmed block 251684.");
235222
}
236223

237-
#endif // UNDEFINED
238-
239224
} // namespace node
240225
} // namespace libbitcoin

0 commit comments

Comments
 (0)