From 2dabb52c4ef027d852011e09af96293f6295b7e8 Mon Sep 17 00:00:00 2001 From: Mathieu Hofman Date: Sat, 22 Jun 2024 03:43:26 +0000 Subject: [PATCH] test(a3p): add test for snapshots export and restore --- ...-synthetic-chain-npm-0.1.0-148de716a6.patch | 13 +++++++++++++ a3p-integration/package.json | 2 +- .../z:acceptance/state-sync-snapshots-test.sh | 14 ++++++++++++++ a3p-integration/proposals/z:acceptance/test.sh | 2 ++ a3p-integration/yarn.lock | 18 ++++++++++++++++-- 5 files changed, 46 insertions(+), 3 deletions(-) create mode 100644 a3p-integration/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch create mode 100755 a3p-integration/proposals/z:acceptance/state-sync-snapshots-test.sh diff --git a/a3p-integration/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch b/a3p-integration/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch new file mode 100644 index 00000000000..3d01386399d --- /dev/null +++ b/a3p-integration/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch @@ -0,0 +1,13 @@ +diff --git a/dist/upgrade-test-scripts/env_setup.sh b/dist/upgrade-test-scripts/env_setup.sh +index 617a0fbe7efdfa457e28fc52806dba1b323930d8..25f52a6cf133dca830bd0dcd47c91700e6a8effe 100755 +--- a/dist/upgrade-test-scripts/env_setup.sh ++++ b/dist/upgrade-test-scripts/env_setup.sh +@@ -100,7 +100,7 @@ killAgd() { + AGD_PID=$(cat $HOME/.agoric/agd.pid) + kill $AGD_PID + rm $HOME/.agoric/agd.pid +- wait $AGD_PID || true ++ tail --pid=$AGD_PID -f /dev/null || true + } + + provisionSmartWallet() { diff --git a/a3p-integration/package.json b/a3p-integration/package.json index ad8954bd0da..71207d38918 100644 --- a/a3p-integration/package.json +++ b/a3p-integration/package.json @@ -12,7 +12,7 @@ "doctor": "yarn synthetic-chain doctor" }, "dependencies": { - "@agoric/synthetic-chain": "^0.1.0", + "@agoric/synthetic-chain": "patch:@agoric/synthetic-chain@npm%3A0.1.0#~/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch", "@types/better-sqlite3": "^7.6.9" }, "packageManager": "yarn@4.2.2", diff --git a/a3p-integration/proposals/z:acceptance/state-sync-snapshots-test.sh b/a3p-integration/proposals/z:acceptance/state-sync-snapshots-test.sh new file mode 100755 index 00000000000..f4dcf018e97 --- /dev/null +++ b/a3p-integration/proposals/z:acceptance/state-sync-snapshots-test.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +source /usr/src/upgrade-test-scripts/env_setup.sh + +set -e + +killAgd +agd snapshots export +SNAPSHOT_DETAILS=$(agd snapshots list | head -n1 | sed -E 's/height: ([0-9]+) format: ([0-9]+) chunks: [0-9]+/\1 \2/') +echo found snapshot $SNAPSHOT_DETAILS +rm -rf /root/.agoric/data/application.db /root/.agoric/data/agoric +agd snapshots restore $SNAPSHOT_DETAILS + +startAgd diff --git a/a3p-integration/proposals/z:acceptance/test.sh b/a3p-integration/proposals/z:acceptance/test.sh index 38ffa27a4ae..0447826a85d 100755 --- a/a3p-integration/proposals/z:acceptance/test.sh +++ b/a3p-integration/proposals/z:acceptance/test.sh @@ -11,3 +11,5 @@ GLOBIGNORE=initial.test.js yarn ava ./*.test.js ./create-kread-item-test.sh + +./state-sync-snapshots-test.sh diff --git a/a3p-integration/yarn.lock b/a3p-integration/yarn.lock index ea0f0da0407..c5c8e80616e 100644 --- a/a3p-integration/yarn.lock +++ b/a3p-integration/yarn.lock @@ -5,7 +5,7 @@ __metadata: version: 8 cacheKey: 10c0 -"@agoric/synthetic-chain@npm:^0.1.0": +"@agoric/synthetic-chain@npm:0.1.0": version: 0.1.0 resolution: "@agoric/synthetic-chain@npm:0.1.0" dependencies: @@ -19,6 +19,20 @@ __metadata: languageName: node linkType: hard +"@agoric/synthetic-chain@patch:@agoric/synthetic-chain@npm%3A0.1.0#~/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch": + version: 0.1.0 + resolution: "@agoric/synthetic-chain@patch:@agoric/synthetic-chain@npm%3A0.1.0#~/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch::version=0.1.0&hash=4a65eb" + dependencies: + "@endo/zip": "npm:^1.0.1" + better-sqlite3: "npm:^9.4.0" + chalk: "npm:^5.3.0" + execa: "npm:^8.0.1" + bin: + synthetic-chain: dist/cli/cli.js + checksum: 10c0/e974038161b1a9570912a02d9366c6680bc13ee3dfd0e49d06e5ce5e93dbcddf04d1d4cd453af0969bf29ccfe96ce3e141a214539722449add90b13f0785f1f7 + languageName: node + linkType: hard + "@endo/zip@npm:^1.0.1": version: 1.0.1 resolution: "@endo/zip@npm:1.0.1" @@ -990,7 +1004,7 @@ __metadata: version: 0.0.0-use.local resolution: "root-workspace-0b6124@workspace:." dependencies: - "@agoric/synthetic-chain": "npm:^0.1.0" + "@agoric/synthetic-chain": "patch:@agoric/synthetic-chain@npm%3A0.1.0#~/.yarn/patches/@agoric-synthetic-chain-npm-0.1.0-148de716a6.patch" "@types/better-sqlite3": "npm:^7.6.9" languageName: unknown linkType: soft