Skip to content

Commit

Permalink
WIP lgos
Browse files Browse the repository at this point in the history
  • Loading branch information
maxtropets committed Sep 26, 2024
1 parent e213df0 commit 9a730a6
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 22 deletions.
3 changes: 2 additions & 1 deletion src/js/extensions/ccf/historical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,15 @@ namespace ccf::js::extensions
};
std::unordered_map<ccf::SeqNo, HistoricalHandle> historical_handles;

Impl(ccf::historical::AbstractStateCache* hs) : historical_state(hs){};
Impl(ccf::historical::AbstractStateCache* hs) : historical_state(hs) {};
};

namespace
{
static JSValue js_historical_get_state_range(
JSContext* ctx, JSValueConst this_val, int argc, JSValueConst* argv)
{
std::cout << "PATTERN historical executed" << std::endl;
if (argc != 4)
{
return JS_ThrowTypeError(
Expand Down
63 changes: 42 additions & 21 deletions tests/recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,11 @@ def test_recover_service_with_wrong_identity(network, args):
network.save_service_identity(args)
first_service_identity_file = args.previous_service_identity_file

with old_primary.client() as c:
last_view, last_seq = (
c.get('/node/commit').body.json()['transaction_id'].split('.')
)

network.stop_all_nodes()

current_ledger_dir, committed_ledger_dirs = old_primary.get_ledger()
Expand Down Expand Up @@ -254,6 +259,22 @@ def test_recover_service_with_wrong_identity(network, args):
snapshots_dir=snapshots_dir,
)

breakpoint()

primary, _ = recovered_network.find_primary()
with primary.client() as cli:
curr_view, curr_seq = (
cli.get('/node/commit').body.json()['transaction_id'].split('.')
)
response = cli.get(f"/node/receipt?transaction_id={last_view}.{last_seq}")
breakpoint()
print(response)

curr_receipt = primary.get_receipt(curr_view, curr_seq)
verify_receipt(curr_receipt.json(), network.cert)

breakpoint()

recovered_network.recover(args)

return recovered_network
Expand Down Expand Up @@ -869,26 +890,26 @@ def add(parser):
snapshot_tx_interval=30,
)

# Note: `run_corrupted_ledger` runs with very a specific node configuration
# so that the contents of recovered (and tampered) ledger chunks
# can be dictated by the test. In particular, the signature interval is large
# enough to create in-progress ledger files that do not end on a signature. The
# test is also in control of the ledger chunking.
cr.add(
"recovery_corrupt_ledger",
run_corrupted_ledger,
package="samples/apps/logging/liblogging",
nodes=infra.e2e_args.min_nodes(cr.args, f=0), # 1 node suffices for recovery
sig_ms_interval=1000,
ledger_chunk_bytes="1GB",
snapshot_tx_interval=1000000,
)

cr.add(
"recovery_snapshot_alone",
run_recover_snapshot_alone,
package="samples/apps/logging/liblogging",
nodes=infra.e2e_args.min_nodes(cr.args, f=0), # 1 node suffices for recovery
)
# # Note: `run_corrupted_ledger` runs with very a specific node configuration
# # so that the contents of recovered (and tampered) ledger chunks
# # can be dictated by the test. In particular, the signature interval is large
# # enough to create in-progress ledger files that do not end on a signature. The
# # test is also in control of the ledger chunking.
# cr.add(
# "recovery_corrupt_ledger",
# run_corrupted_ledger,
# package="samples/apps/logging/liblogging",
# nodes=infra.e2e_args.min_nodes(cr.args, f=0), # 1 node suffices for recovery
# sig_ms_interval=1000,
# ledger_chunk_bytes="1GB",
# snapshot_tx_interval=1000000,
# )

# cr.add(
# "recovery_snapshot_alone",
# run_recover_snapshot_alone,
# package="samples/apps/logging/liblogging",
# nodes=infra.e2e_args.min_nodes(cr.args, f=0), # 1 node suffices for recovery
# )

cr.run()

0 comments on commit 9a730a6

Please sign in to comment.