Skip to content

Commit

Permalink
Restart test: Simplify by storing the stateDB
Browse files Browse the repository at this point in the history
Instead of individually storing the object, just save the stateDB,
which is intended to be the persistent layer.
  • Loading branch information
Geod24 committed May 17, 2021
1 parent 1b749ae commit e26db46
Showing 1 changed file with 7 additions and 27 deletions.
34 changes: 7 additions & 27 deletions source/agora/test/Restart.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ version (unittest):

import agora.api.Validator;
import agora.common.Config;
import agora.common.ManagedDatabase;
import agora.consensus.data.Block;
import agora.consensus.data.Params;
import agora.test.Base;
Expand Down Expand Up @@ -57,14 +58,10 @@ private class PersistentNode : TestValidatorNode

mixin ForwardCtor!();

///
private static UTXOSet utxo_set_saved;
///
private static EnrollmentManager em_saved;
/// Note: We only save the stateDB, not the cacheDB, as we don't test it
private static ManagedDatabase stateDB_saved;
///
private static IBlockStorage blockstorage_saved;
///
private static FeeManager fee_man;

///
protected override IBlockStorage makeBlockStorage () @system
Expand All @@ -75,29 +72,12 @@ private class PersistentNode : TestValidatorNode
}

///
protected override UTXOSet makeUTXOSet ()
{
if (utxo_set_saved is null)
utxo_set_saved = super.makeUTXOSet();
return utxo_set_saved;
}

///
protected override EnrollmentManager makeEnrollmentManager ()
{
if (em_saved is null)
em_saved = super.makeEnrollmentManager();
return em_saved;
}

///
protected override FeeManager makeFeeManager ()
protected override ManagedDatabase makeStateDB ()
{
if (fee_man is null)
fee_man = super.makeFeeManager();
return fee_man;
if (stateDB_saved is null)
stateDB_saved = super.makeStateDB();
return stateDB_saved;
}

}

private class WithPersistentNodeAPIManager : TestAPIManager
Expand Down

0 comments on commit e26db46

Please sign in to comment.