From 6223df54320afea50d258580d4780b820491d35d Mon Sep 17 00:00:00 2001 From: sneurlax Date: Mon, 7 Nov 2022 11:21:10 -0600 Subject: [PATCH] specify tests for 14 word seeds and add more error checking code to test and update ref to flutter_libmonero enabling tests (mocked storage, etc) --- crypto_plugins/flutter_libmonero | 2 +- .../coins/wownero/wownero_wallet_test.dart | 45 +++++++++++-------- .../wownero/wownero_wallet_test_data.dart | 4 +- 3 files changed, 30 insertions(+), 21 deletions(-) diff --git a/crypto_plugins/flutter_libmonero b/crypto_plugins/flutter_libmonero index 277d922c3..d92fea3e6 160000 --- a/crypto_plugins/flutter_libmonero +++ b/crypto_plugins/flutter_libmonero @@ -1 +1 @@ -Subproject commit 277d922c3b1d637c1ccda25f51395c618d293015 +Subproject commit d92fea3e6b915b79697deafbd5710fb4c15bfc76 diff --git a/test/services/coins/wownero/wownero_wallet_test.dart b/test/services/coins/wownero/wownero_wallet_test.dart index e64dd772c..83b4844c7 100644 --- a/test/services/coins/wownero/wownero_wallet_test.dart +++ b/test/services/coins/wownero/wownero_wallet_test.dart @@ -83,13 +83,13 @@ void main() async { _walletInfoSource = await Hive.openBox(WalletInfo.boxName); walletService = wownero.createWowneroWalletService(_walletInfoSource); - group("Wownero tests", () { + group("Wownero 14 word tests", () { setUp(() async { try { final dirPath = await pathForWalletDir(name: name, type: type); path = await pathForWallet(name: name, type: type); credentials = wownero.createWowneroRestoreWalletFromSeedCredentials( - name: name, height: 465760, mnemonic: testMnemonic); + name: name, height: 465760, mnemonic: testMnemonic14); walletInfo = WalletInfo.external( id: WalletBase.idFor(name, type), @@ -116,27 +116,36 @@ void main() async { } }); - test("Test mainnet address generation from seed", () async { + test("Test mainnet address generation from 14 word seed", () async { final wallet = await _walletCreationService.restoreFromSeed(credentials); walletInfo.address = wallet.walletAddresses.address; - await _walletInfoSource.add(walletInfo); + bool hasThrown = false; + try { + await _walletInfoSource.add(walletInfo); + walletBase?.close(); + walletBase = wallet as WowneroWalletBase; + + expect(walletInfo.address, mainnetTestData14[0][0]); + expect( + await walletBase!.getTransactionAddress(0, 0), mainnetTestData14[0][0]); + expect( + await walletBase!.getTransactionAddress(0, 1), mainnetTestData14[0][1]); + expect( + await walletBase!.getTransactionAddress(0, 2), mainnetTestData14[0][2]); + expect( + await walletBase!.getTransactionAddress(1, 0), mainnetTestData14[1][0]); + expect( + await walletBase!.getTransactionAddress(1, 1), mainnetTestData14[1][1]); + expect( + await walletBase!.getTransactionAddress(1, 2), mainnetTestData14[1][2]); + } catch (_) { + hasThrown = true; + } + expect(hasThrown, false); + walletBase?.close(); walletBase = wallet as WowneroWalletBase; - - expect(walletInfo.address, mainnetTestData[0][0]); - expect( - await walletBase!.getTransactionAddress(0, 0), mainnetTestData[0][0]); - expect( - await walletBase!.getTransactionAddress(0, 1), mainnetTestData[0][1]); - expect( - await walletBase!.getTransactionAddress(0, 2), mainnetTestData[0][2]); - expect( - await walletBase!.getTransactionAddress(1, 0), mainnetTestData[1][0]); - expect( - await walletBase!.getTransactionAddress(1, 1), mainnetTestData[1][1]); - expect( - await walletBase!.getTransactionAddress(1, 2), mainnetTestData[1][2]); }); }); } diff --git a/test/services/coins/wownero/wownero_wallet_test_data.dart b/test/services/coins/wownero/wownero_wallet_test_data.dart index b0d93a448..8ab825dfa 100644 --- a/test/services/coins/wownero/wownero_wallet_test_data.dart +++ b/test/services/coins/wownero/wownero_wallet_test_data.dart @@ -1,6 +1,6 @@ -String testMnemonic = +String testMnemonic14 = 'weather cruise school such silly profit clerk wage reduce obtain ill sand episode shadow'; -var mainnetTestData = [ +var mainnetTestData14 = [ [ 'Wo3jmHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmsEi', 'WW3K54QzmMFB1uTZh3LVvgQYqANLmX1FkJHLJ4sU1E7BQmp8nGizyBnjNXSgsjCa4BQ3Rw3GG5jw1ByUkaUjSywm2KmHAbFvK',