Skip to content

Commit

Permalink
Merge pull request #2364 from area363/update-snapshot-command
Browse files Browse the repository at this point in the history
update snapshot command to latest
  • Loading branch information
area363 authored Dec 27, 2023
2 parents 710fc5e + cf5bebc commit 0f08688
Show file tree
Hide file tree
Showing 2 changed files with 185 additions and 102 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ public void Snapshot(StoreType storeType)
};
Guid chainId = chain.Id;

for (var i = 0; i < 2; i++)
for (var i = 0; i < 5; i++)
{
chain.MakeTransaction(GenesisHelper.ValidatorKey, new ActionBase[] { action });
Block block = chain.ProposeBlock(
Expand Down Expand Up @@ -334,9 +334,10 @@ public void Snapshot(StoreType storeType)
IStore storeAfterSnapshot = storeType.CreateStore(_storePath);
chainId = storeAfterSnapshot.GetCanonicalChainId() ?? new Guid();
var tipHashAfterSnapshot = storeAfterSnapshot.IndexBlockHash(chainId, -1);
var snapshotTipIndex = storeAfterSnapshot.GetBlockIndex((BlockHash)tipHashAfterSnapshot!);
var expectedGenesisPartitionSnapshotPath = Path.Combine(outputDirectory, "partition", $"snapshot-{genesisBlockEpoch}-{genesisBlockEpoch}.zip");
var expectedGenesisMetadataPath = Path.Combine(outputDirectory, "metadata", $"snapshot-{genesisBlockEpoch}-{genesisBlockEpoch}.json");
var expectedFullSnapshotPath = Path.Combine(outputDirectory, "full", $"{genesisHash}-snapshot-{tipHashAfterSnapshot}.zip");
var expectedFullSnapshotPath = Path.Combine(outputDirectory, "full", $"{genesisHash}-snapshot-{tipHashAfterSnapshot}-{snapshotTipIndex}.zip");
storeAfterSnapshot.Dispose();

Assert.True(File.Exists(expectedGenesisPartitionSnapshotPath));
Expand All @@ -360,8 +361,8 @@ public void Snapshot(StoreType storeType)
Assert.True(File.Exists(expectedPartitionSnapshotPath));
Assert.True(File.Exists(expectedStateSnapshotPath));
Assert.True(File.Exists(expectedMetadataPath));
Assert.Equal(3, indexCountBeforeSnapshot);
Assert.Equal(2, indexCountAfterSnapshot);
Assert.Equal(6, indexCountBeforeSnapshot);
Assert.Equal(5, indexCountAfterSnapshot);

Directory.Delete(outputDirectory, true);
}
Expand Down
Loading

0 comments on commit 0f08688

Please sign in to comment.