use hive_test for monero and wownero tests

This commit is contained in:
sneurlax 2022-11-10 10:46:09 -06:00
parent 23d2de26d7
commit 6e48fc4ea6
2 changed files with 36 additions and 16 deletions

View file

@ -81,19 +81,29 @@ void main() async {
if (Platform.isIOS) {
appDir = (await getLibraryDirectory());
}
await Hive.close();
Hive.init(appDir.path);
Hive.registerAdapter(NodeAdapter());
Hive.registerAdapter(WalletInfoAdapter());
Hive.registerAdapter(WalletTypeAdapter());
Hive.registerAdapter(UnspentCoinsInfoAdapter());
monero.onStartup();
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
walletService = monero.createMoneroWalletService(_walletInfoSource);
bool hiveAdaptersRegistered = false;
group("Mainnet tests", () {
setUp(() async {
await setUpTestHive();
if (!hiveAdaptersRegistered) {
hiveAdaptersRegistered = true;
Hive.registerAdapter(NodeAdapter());
Hive.registerAdapter(WalletInfoAdapter());
Hive.registerAdapter(WalletTypeAdapter());
Hive.registerAdapter(UnspentCoinsInfoAdapter());
final wallets = await Hive.openBox('wallets');
await wallets.put('currentWalletName', name);
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
walletService = monero.createMoneroWalletService(_walletInfoSource);
}
try {
// if (name?.isEmpty ?? true) {
// name = await generateName();

View file

@ -72,19 +72,29 @@ void main() async {
if (Platform.isIOS) {
appDir = (await getLibraryDirectory());
}
await Hive.close();
Hive.init(appDir.path);
Hive.registerAdapter(NodeAdapter());
Hive.registerAdapter(WalletInfoAdapter());
Hive.registerAdapter(WalletTypeAdapter());
Hive.registerAdapter(UnspentCoinsInfoAdapter());
wownero.onStartup();
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
walletService = wownero.createWowneroWalletService(_walletInfoSource);
bool hiveAdaptersRegistered = false;
group("Wownero 14 word seed generation", () {
setUp(() async {
await setUpTestHive();
if (!hiveAdaptersRegistered) {
hiveAdaptersRegistered = true;
Hive.registerAdapter(NodeAdapter());
Hive.registerAdapter(WalletInfoAdapter());
Hive.registerAdapter(WalletTypeAdapter());
Hive.registerAdapter(UnspentCoinsInfoAdapter());
final wallets = await Hive.openBox('wallets');
await wallets.put('currentWalletName', name);
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
walletService = wownero.createWowneroWalletService(_walletInfoSource);
}
bool hasThrown = false;
try {
name = 'namee${Random().nextInt(10000000)}';