From f984a6a20891068a497eeeca8800aa8bdc1f0a3a Mon Sep 17 00:00:00 2001 From: likho Date: Wed, 30 Nov 2022 15:06:31 +0200 Subject: [PATCH] Add test history data and WIP change tests to particl --- test/cached_electrumx_test.mocks.dart | 13 + test/electrumx_test.mocks.dart | 13 + .../pages/send_view/send_view_test.mocks.dart | 19 +- .../exchange/exchange_view_test.mocks.dart | 13 + .../lockscreen_view_screen_test.mocks.dart | 6 +- .../create_pin_view_screen_test.mocks.dart | 6 +- ...restore_wallet_view_screen_test.mocks.dart | 9 +- ...dd_custom_node_view_screen_test.mocks.dart | 6 +- .../node_details_view_screen_test.mocks.dart | 6 +- ...twork_settings_view_screen_test.mocks.dart | 6 +- .../particl/particl_history_sample_data.dart | 158 +- .../particl_transaction_data_samples.dart | 323 +- .../particl/particl_utxo_sample_data.dart | 42 +- .../coins/particl/particl_wallet_test.dart | 2601 +++++++++-------- .../particl/particl_wallet_test.mocks.dart | 2 +- .../managed_favorite_test.mocks.dart | 6 +- test/widget_tests/node_card_test.mocks.dart | 6 +- .../node_options_sheet_test.mocks.dart | 22 +- .../transaction_card_test.mocks.dart | 13 + ...et_info_row_balance_future_test.mocks.dart | 6 +- .../wallet_info_row_test.mocks.dart | 6 +- 21 files changed, 1688 insertions(+), 1594 deletions(-) diff --git a/test/cached_electrumx_test.mocks.dart b/test/cached_electrumx_test.mocks.dart index a45cdd402..68d3b695f 100644 --- a/test/cached_electrumx_test.mocks.dart +++ b/test/cached_electrumx_test.mocks.dart @@ -551,6 +551,19 @@ class MockPrefs extends _i1.Mock implements _i5.Prefs { returnValueForMissingStub: null, ); @override + int get familiarity => (super.noSuchMethod( + Invocation.getter(#familiarity), + returnValue: 0, + ) as int); + @override + set familiarity(int? familiarity) => super.noSuchMethod( + Invocation.setter( + #familiarity, + familiarity, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, diff --git a/test/electrumx_test.mocks.dart b/test/electrumx_test.mocks.dart index 9f29ae1e5..c4a9ae9b2 100644 --- a/test/electrumx_test.mocks.dart +++ b/test/electrumx_test.mocks.dart @@ -272,6 +272,19 @@ class MockPrefs extends _i1.Mock implements _i4.Prefs { returnValueForMissingStub: null, ); @override + int get familiarity => (super.noSuchMethod( + Invocation.getter(#familiarity), + returnValue: 0, + ) as int); + @override + set familiarity(int? familiarity) => super.noSuchMethod( + Invocation.setter( + #familiarity, + familiarity, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, diff --git a/test/pages/send_view/send_view_test.mocks.dart b/test/pages/send_view/send_view_test.mocks.dart index d63dafb04..b5a3e4e63 100644 --- a/test/pages/send_view/send_view_test.mocks.dart +++ b/test/pages/send_view/send_view_test.mocks.dart @@ -85,9 +85,9 @@ class _FakeManager_3 extends _i1.SmartFake implements _i6.Manager { ); } -class _FakeFlutterSecureStorageInterface_4 extends _i1.SmartFake +class _FakeSecureStorageInterface_4 extends _i1.SmartFake implements _i7.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_4( + _FakeSecureStorageInterface_4( Object parent, Invocation parentInvocation, ) : super( @@ -623,7 +623,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i7.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_4( + returnValue: _FakeSecureStorageInterface_4( this, Invocation.getter(#secureStorageInterface), ), @@ -1765,6 +1765,19 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValueForMissingStub: null, ); @override + int get familiarity => (super.noSuchMethod( + Invocation.getter(#familiarity), + returnValue: 0, + ) as int); + @override + set familiarity(int? familiarity) => super.noSuchMethod( + Invocation.setter( + #familiarity, + familiarity, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, diff --git a/test/screen_tests/exchange/exchange_view_test.mocks.dart b/test/screen_tests/exchange/exchange_view_test.mocks.dart index 0da12dbd0..8c0d72f55 100644 --- a/test/screen_tests/exchange/exchange_view_test.mocks.dart +++ b/test/screen_tests/exchange/exchange_view_test.mocks.dart @@ -223,6 +223,19 @@ class MockPrefs extends _i1.Mock implements _i3.Prefs { returnValueForMissingStub: null, ); @override + int get familiarity => (super.noSuchMethod( + Invocation.getter(#familiarity), + returnValue: 0, + ) as int); + @override + set familiarity(int? familiarity) => super.noSuchMethod( + Invocation.setter( + #familiarity, + familiarity, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, diff --git a/test/screen_tests/lockscreen_view_screen_test.mocks.dart b/test/screen_tests/lockscreen_view_screen_test.mocks.dart index a33c4ef28..2ea9822b6 100644 --- a/test/screen_tests/lockscreen_view_screen_test.mocks.dart +++ b/test/screen_tests/lockscreen_view_screen_test.mocks.dart @@ -29,9 +29,9 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeFlutterSecureStorageInterface_0 extends _i1.SmartFake +class _FakeSecureStorageInterface_0 extends _i1.SmartFake implements _i2.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_0( + _FakeSecureStorageInterface_0( Object parent, Invocation parentInvocation, ) : super( @@ -311,7 +311,7 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_0( + returnValue: _FakeSecureStorageInterface_0( this, Invocation.getter(#secureStorageInterface), ), diff --git a/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart b/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart index 3aed1dcb8..c891911ae 100644 --- a/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/create_pin_view_screen_test.mocks.dart @@ -29,9 +29,9 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeFlutterSecureStorageInterface_0 extends _i1.SmartFake +class _FakeSecureStorageInterface_0 extends _i1.SmartFake implements _i2.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_0( + _FakeSecureStorageInterface_0( Object parent, Invocation parentInvocation, ) : super( @@ -311,7 +311,7 @@ class MockNodeService extends _i1.Mock implements _i10.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_0( + returnValue: _FakeSecureStorageInterface_0( this, Invocation.getter(#secureStorageInterface), ), diff --git a/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart b/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart index cd4986e13..ee326b1d8 100644 --- a/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart +++ b/test/screen_tests/onboarding/restore_wallet_view_screen_test.mocks.dart @@ -83,9 +83,9 @@ class _FakeTransactionData_4 extends _i1.SmartFake ); } -class _FakeFlutterSecureStorageInterface_5 extends _i1.SmartFake +class _FakeSecureStorageInterface_5 extends _i1.SmartFake implements _i6.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_5( + _FakeSecureStorageInterface_5( Object parent, Invocation parentInvocation, ) : super( @@ -744,10 +744,9 @@ class MockManager extends _i1.Mock implements _i12.Manager { /// See the documentation for Mockito's code generation for more information. class MockNodeService extends _i1.Mock implements _i13.NodeService { @override - _i6.SecureStorageInterface get secureStorageInterface => - (super.noSuchMethod( + _i6.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_5( + returnValue: _FakeSecureStorageInterface_5( this, Invocation.getter(#secureStorageInterface), ), diff --git a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart index 3ac5afcc7..9cdd45a2a 100644 --- a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/add_custom_node_view_screen_test.mocks.dart @@ -28,9 +28,9 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeFlutterSecureStorageInterface_0 extends _i1.SmartFake +class _FakeSecureStorageInterface_0 extends _i1.SmartFake implements _i2.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_0( + _FakeSecureStorageInterface_0( Object parent, Invocation parentInvocation, ) : super( @@ -88,7 +88,7 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_0( + returnValue: _FakeSecureStorageInterface_0( this, Invocation.getter(#secureStorageInterface), ), diff --git a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart index 0f6447a9e..984287655 100644 --- a/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/network_settings_subviews/node_details_view_screen_test.mocks.dart @@ -28,9 +28,9 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeFlutterSecureStorageInterface_0 extends _i1.SmartFake +class _FakeSecureStorageInterface_0 extends _i1.SmartFake implements _i2.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_0( + _FakeSecureStorageInterface_0( Object parent, Invocation parentInvocation, ) : super( @@ -88,7 +88,7 @@ class MockNodeService extends _i1.Mock implements _i6.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_0( + returnValue: _FakeSecureStorageInterface_0( this, Invocation.getter(#secureStorageInterface), ), diff --git a/test/screen_tests/settings_view/settings_subviews/network_settings_view_screen_test.mocks.dart b/test/screen_tests/settings_view/settings_subviews/network_settings_view_screen_test.mocks.dart index 707da7345..cf3ed4e9a 100644 --- a/test/screen_tests/settings_view/settings_subviews/network_settings_view_screen_test.mocks.dart +++ b/test/screen_tests/settings_view/settings_subviews/network_settings_view_screen_test.mocks.dart @@ -24,9 +24,9 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeFlutterSecureStorageInterface_0 extends _i1.SmartFake +class _FakeSecureStorageInterface_0 extends _i1.SmartFake implements _i2.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_0( + _FakeSecureStorageInterface_0( Object parent, Invocation parentInvocation, ) : super( @@ -42,7 +42,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_0( + returnValue: _FakeSecureStorageInterface_0( this, Invocation.getter(#secureStorageInterface), ), diff --git a/test/services/coins/particl/particl_history_sample_data.dart b/test/services/coins/particl/particl_history_sample_data.dart index 53a082778..b2e5f9fa7 100644 --- a/test/services/coins/particl/particl_history_sample_data.dart +++ b/test/services/coins/particl/particl_history_sample_data.dart @@ -1,103 +1,105 @@ // TODO these test vectors are valid for Namecoin: update for Particl final Map> historyBatchArgs0 = { - "k_0_0": ["d17132f41b2d55c730db5b27db721020abbd4a5087c15edcccbaa106eef8cbf3"], - "k_0_1": ["cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9"], - "k_0_2": ["82a12031d679c9dd3124047742dc22c2c7c03afa9644bddf55d4c95da41bca1c"], - "k_0_3": ["bbe10c5d3c102fd805770ed2d6c5438dce42c04d3f87e3260056d04245b17ddd"], - "k_0_4": ["d9ca5255516f963d8f348911451e2c69489a70dec7f34a4810ee8b0e32fcb04d"], - "k_0_5": ["2284461fd01b17e7443775e39b19f4378a063ff148938d2e4191cea3fd80368d"], - "k_0_6": ["cd3c32fddbf265410c34a58fefcc849b02fc16978d75e501f88f9effcbecd8fe"], - "k_0_7": ["a3bcc0c3c4a140fbcc4c4f4dff18790d8a2d5f868821f47460f68f0426291b57"], - "k_0_8": ["e400f9431798c87ea35ea19b265d9e56a73fd44c239957d9947ae79e16718fb4"], - "k_0_9": ["1fe8bb16b49725bf3703274e205a4695c398e664284cc68d92d15087a54da299"], + "k_0_0": ["29e9e6410954dea9e527a0d2cac5de4dea5fb600b719badff90d6d43518d3ed8"], + "k_0_1": ["9b56ab30c7bef0e1eaa10a632c8e2dcdd11b2158d7a917c03d62936afd0015fc"], + "k_0_2": ["016b150fa7948b0841a2e755b3d40a96a5cbc1d2ac96a105d3ff201137f60d31"], + "k_0_3": ["1b668ee6f82a3f10ea0a515760f1165f53e99e979bd3c557cf6e09d793b9296d"], + "k_0_4": ["351da1f29872e3703dd92625f7face416226f54473bd853c80c1dcc2d8849b63"], + "k_0_5": ["2cd81781064f4679d09bf794d322d44903d8f66c00c8b80753eecaa40a993897"], + "k_0_6": ["ed4d0c5b4c13213e0c91805ef212bf25b81ed0ece46a2fa0d647e66cebebe53d"], + "k_0_7": ["ea558eee7a7b00b4a6207eb5ee783afa422410ababd02da879b687327caf9707"], + "k_0_8": ["90a7df71ab0a57abea44d955f78bf665785a2f104fce6348832fd79dc218d87a"], + "k_0_9": ["4b6d05c5ac9651a1e6452955cde697bbdca941b0c21021e30d0bc772c999a79d"], "k_0_10": [ - "2fabf8d61308c8b2d914489a9f02f669ed9fa68047666815cf1f3cd1bb5d8819" + "af8481316f782f8d2696ef6e70a4c23a17658500c2ee1ab5b7ef0eafb9f18112" ], - "k_0_11": ["42a567d344189430afe7d45d6854ef6e9d256d9ef4186afd31a1a5ff90a6a0dd"] + "k_0_11": ["608f1621850396138cf0ece48b20c1ecbd138d74d200c81b3640564083d117da"] }; + final Map> historyBatchArgs1 = { - "k_0_0": ["bcf7aec7c10dfba33ce80149300a7c4fe66460c1dd05503b5df5780884498186"], - "k_0_1": ["587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e"], - "k_0_2": ["fe6ad514f7427782f964b25995a90a3233589904b88f66a2d0e73e2560c9af7c"], - "k_0_3": ["6b962c5f9b4cfc004c74c5ab849304c405b02fc0e2f34ee17c185984f13c9da4"], - "k_0_4": ["720b79fab9a163ce6534828e8a673c5bf600161eba92c2b81555e79add59994c"], - "k_0_5": ["a10f4cf239abd4bcdb03dbe40b5c1d57ae3a7982adf8f177d481feb0ad3a52cd"], - "k_0_6": ["061f28e17ba1a56404b08a5899163011c7d6317e534ccd8e4d38911574f574b0"], - "k_0_7": ["ffc6297d487a13cb80689c448a3aef16cbd367a503d236d0aebd7218cc568e88"], - "k_0_8": ["f4a6c41fc432300509f97ca68db3b9d802d29f90c35a429e3886c480cdce44a2"], - "k_0_9": ["52f3bf96d02cd7e8c631b8ef36262994a3ec658427b930197ed004c8599cd7fd"], + "k_0_0": ["a41a236959ee41de770a0c2d360d62d75e4ba010294415cfb9f44eff0f731a70"], + "k_0_1": ["8ba03c2c46ed4980fa1e4c84cbceeb2d5e1371a7ccbaf5f3d69c5114161a2247"], + "k_0_2": ["540939221b59a81810398a1af45c22d1e9599e718f24870a44972fbfe55c0a39"], + "k_0_3": ["0323d2dcc60e8d9b6234be43c942f493f1039d45f47b641cd78d0860a5bc61cb"], + "k_0_4": ["c1c61eaa4e0ffa3c2bed0bb32b54281f743113c5d1fe59a4e595559ed1951a8b"], + "k_0_5": ["08dd301d83e42ded2d4ea1990389b281eaec328039b3469d3f2f25b52571be81"], + "k_0_6": ["7de683cf6ac67680166d82505b15974e4ff13caf544001479a2918157b171ccd"], + "k_0_7": ["b15515c8c6dd3eb6835086031f22fc644b490d291cd09772d414c67b5822e95b"], + "k_0_8": ["ff3ff4bc2f223169fa3317c19d399feeb84bae60f32171b1960c94fd61e72041"], + "k_0_9": ["15a21ca5cf24740944b894a9f0482abf1433ab59f156ff52d241ecc234a0dff4"], "k_0_10": [ - "7993aef51bebe79bae2d29b775c499f390e99fdb6b9accb8034f657b6e72927a" + "2037faeb3a55b1bb4545aa220578f9322ab8af8ac7af100d3c1261d25d1b1135" ], - "k_0_11": ["430214c9805d90c6a8c4489187db08157a93e60509e96b518dc8b5ba3d567206"] + "k_0_11": ["4e2051a980cb463b523df8a765e45ea18a0d08a670c38dd14f7c4457d7c86bff"] }; + final Map> historyBatchArgs2 = { - "k_0_0": ["afe5085dd514032810d5b266007557ba8a0f4bee84535cb10754c6d46ab8689b"], - "k_0_1": ["dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c"], - "k_0_2": ["e65d4274e8edc5cc1e7b676652e2e13b0b00648d15cf13caa982ecd6a67731ba"], - "k_0_3": ["6c69ca274f7d7f2fae882a87bcee93d9429328995c5bc6b326b548b4cefcaa9f"], - "k_0_4": ["86f1a5e17dc42c27cdb0dff8a41c2434575ab05ed2f3689fd7b674677e5ea446"], - "k_0_5": ["a5d9b8df5b80c56e6053497a8c89a37267010926e80e0d225a019b78673a7aa7"], - "k_0_6": ["a0030024518874720b82b38d965fb5b3083d9f42fab40e6be4797c789eeb06f2"], - "k_0_7": ["f20077f7c6a6b92a1f75bbbad8dbece9ae4609cfdfc85e40ccac7d463bdfd6e0"], - "k_0_8": ["07b7bb4020c377e0741587efe9c0b3931e2e45f667bc6f1fa81a8f15fbe86ce4"], - "k_0_9": ["ca0322fc293f6e4d8c8adac178ed4aaedbd9acd2ec84acaaf1529f9ab7bda6d2"], + "k_0_0": ["a48f8ee5dc6ff58b29eddeac1afd808b2edff10d736bdede3a2e6a95e588911c"], + "k_0_1": ["b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3"], + "k_0_2": ["aabdda195909a16141e8a3ab548fc5e8e8ba483762f94e1571cf93572bc6767e"], + "k_0_3": ["17ffed6bf6a9960b696139b6c40a1e4f2ee214a68442abdf57e9040079e62765"], + "k_0_4": ["25b58fdb4a8ea949730e138bddf6ff90c13d09123ba935efefc6f5d0e085885e"], + "k_0_5": ["952c7c54ad41bca032fa752d00a8d07e8ea5ae3e850266b45110bbc2a8969c43"], + "k_0_6": ["6b9a3a156ca83f20533ddc29c84cd1872fce4b612f738f022028ad680b77aaa3"], + "k_0_7": ["b6f0f12cc91bbb21584668146c2bfa7d07a786b8772fdd43e6daba3ff43aadff"], + "k_0_8": ["d478d5ca5e92e3a98c36136bf9712f981e7b1cb93ebe65e25f1e11151047a753"], + "k_0_9": ["f3bfe232ca898d1cb44c23586323b0fedef477208c8b4f203eebdf9ea8a2ceef"], "k_0_10": [ - "06df1d13aa43375775d7d2838595a0c4c642f8af15b06a99d5115d9236e9a79e" + "aedac6f5e8f0e96c7a53d9b0460ba9e9397efbd9d15c46a28d7b0be70ffc6dac" ], - "k_0_11": ["1a146c5a8dd5bf49faca3c6f65c9d955d361c6c00893c48d69cf7ff42c7b387b"] + "k_0_11": ["f66b687065339e2d4d567f9ea473947b8aab74c066bf00cdfdb5f918bbd159dc"] }; final Map> historyBatchArgs3 = { - "k_0_0": ["5c2c77a3671417c5831c336805770344b81e6c7ef0d873c986ba65a7bacd5f68"], - "k_0_1": ["c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b"], - "k_0_2": ["f430c440e90c48b9e4c7e5356083e7c1495b7cad53f39ebba64cca9fb3d05c82"], - "k_0_3": ["30a7ac6789383f7f6def9a927f3b6fb661cf9406fec71a1d118c7d86052382fb"], - "k_0_4": ["a797225a9155417ab18e16b9d7ce9bf4962ae5c05df572a33c60b36a0523f257"], - "k_0_5": ["24d1e3ac9e53727d943688e67eb5c000d993e9c3cf9585d630624197fb73bed3"], - "k_0_6": ["d667a44404519649cb65632d6a3be948a1f0971025c96cb4211943d301fe0d3e"], - "k_0_7": ["be8da400f004546b528fb989c14a88324b8b0c2d5680cf080ae1e1dac4401f68"], - "k_0_8": ["addfa7682c0a2461ab0e82b3c9302b38986b442a1a76c3c839b6c2f0eaa805fe"], - "k_0_9": ["98bb3aab55f4f305fd9994334b8dd3321eda50b25fad2ef3e636714b650d0bb0"], + "k_0_0": ["0664a4e19dd852c7d6fb53824198070e911dae9049aa9a6a940413cb868bbb27"], + "k_0_1": ["c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f"], + "k_0_2": ["aa34a5cd34908ed90f41ce31058552bee864b8894eec3b5b3f2583eb56eca759"], + "k_0_3": ["996cca35eb2c30699c8b28d3fff12a8fb7fbbacfbfe4aafc4e59833134cb37bb"], + "k_0_4": ["f581a49f492a0d2bc18b5c82ef999f03ff795bf5101646bed871b3efa1f34578"], + "k_0_5": ["ce5fe035e2ce47a7d5d1dc65ad4fc2d40d621f0f2fa25eb233e6d717e0b1743a"], + "k_0_6": ["51031f3710836824b48df2f33d1daa2c63b397c3c604577f09c8b4bef19302fb"], + "k_0_7": ["901f355de67d762c5a768ef19624359c8f95bc9f70d381507727a885cb46964b"], + "k_0_8": ["8ac9526d63526f498fc7c609adcb72c23a403cc271c91408288c19318357f059"], + "k_0_9": ["ca7b62c4b069ff2d4fcbc0faac32447b92d519dd726039eb7381ca5fde176e97"], "k_0_10": [ - "bee1eee20d7169d03ce68d340a17f4598f589920513ec19c458db45399639a9f" + "f07285fe3a8eac625b2c5339cf9f068fccb2278f923a38a46a60c94c7179d4aa" ], - "k_0_11": ["928a988dd65d100d1677a0478abfcd4d2a70aabb0812c58a2b1b4b51c395ed54"] + "k_0_11": ["f8f09b8fe23da8435409c3e688002dcaa87c2b9f3707e17bc668db7392039dab"] }; final Map> historyBatchArgs4 = { - "k_0_0": ["6bbfd9c1c28d6984646db4736196f67f2d1075894bb1d8990294ca7d663bece6"], - "k_0_1": ["42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3"], - "k_0_2": ["191c977174dc50a57628aea6684c428d3a5e90bbe16c4e412be51b0cfc589d38"], - "k_0_3": ["0daaf61564fd07a25ef106d958216992896f931f5bed4fbf56cc3f94443dc164"], - "k_0_4": ["ac5aca40fed2903def31c9ef1d60874247cdcc5b85238c7a1d83c67d2924d6b9"], - "k_0_5": ["c4102ff0556d863b4bab9d8232fe1f0c0fde4b6e4fe23064b4ecd0958f9726cc"], - "k_0_6": ["1c4bd1554e4992e5914dcd8f3e13927ffd46302dfdcbd2dca0cfd47c040c4256"], - "k_0_7": ["eaf5562ebef7cafa58e2c1fc4ae023e5ae8dd71ee637b08c4bc7e274e401a9a4"], - "k_0_8": ["06f7f55c221fee1b36284b5360155b8380cb9d7172b7e28eb37c61b7ebb6f227"], - "k_0_9": ["7e7ca801131ec1c5797f2c4aa46908ee50e9958cf1cbf53c2481d110800c3d6d"], + "k_0_0": ["4cff1590918be5d24d130f10627aaacc6d1e3f03872643c3afc742e6c77e3e72"], + "k_0_1": ["3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339"], + "k_0_2": ["68668ef2d53d4cb5bda66ce3adae25dbe7a8466eb3eca64ed816a59cf8362288"], + "k_0_3": ["8bb32cbd5de862d6305813e312b0caec7249692c6f41154b4855003450c58f6d"], + "k_0_4": ["d66592642c8dcbde165c04fd394ed92bcef89bbadbfd8cbe213cea0e811708ce"], + "k_0_5": ["72ac3ef3b722777e5e7cf75eaf8324cb7db0c575a6a8640609757c99a71bca91"], + "k_0_6": ["be8f9884d1655f84993572924729f52ec66b56582adf44b841cebdf42d3dcd5b"], + "k_0_7": ["c5a53feb8be5ea226da3e72bfcb522569f7956d137266e3da16ada99d0c4817b"], + "k_0_8": ["f50124f4371374e623db18f24bf01644018b0a47351dfa5624df9706c5409dca"], + "k_0_9": ["83f0334c6c57164ac6fd9c83b89f1977e2e4bf9144dd25c992e3def16242ae8c"], "k_0_10": [ - "3895e073aa034add7d2589bfdd1e54f6b9a8d7688d63fff0c3aac7950c6f9697" + "e04e7d94a880ccbd8ce473ce5e780fd86003137cef1e879e38971e4216a282e1" ], - "k_0_11": ["ec17dd7c4fe8fbcfce94e9237d3c7ed7f5c91a45b1a060406e206df7e814b006"] + "k_0_11": ["f6a7b80c32f2568bebe37d6615ebfa602ec04207cd9edf304ff7f835b03c27d2"] }; final Map> historyBatchArgs5 = { - "k_0_0": ["83b744ccb88827d544081c1a03ea782a7d00d6224ff9fddb7d0fbad399e1cae7"], - "k_0_1": ["86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874"], - "k_0_2": ["5baba32b1899d5e740838559ef39b7d8e9ba302bd24b732eeedd4c0e6ec65b51"], - "k_0_3": ["9892eb48394b0e155f63879fb89c3b068fcc071fed2e5cb11fe0729b85b53d67"], - "k_0_4": ["64192782cdaecb5e2a871a2d0fb3f541873e4750cd4e7d28e4d858ab40664a36"], - "k_0_5": ["4047ff48e96d25628acfeaec6ca75c1a668c54fd70a14414827cb59976a3b666"], - "k_0_6": ["299e8bc634ef6438c5bf99c12c2340c77c56ab974ffd767e77c17994e5cfaef8"], - "k_0_7": ["ab649fa14452563b385eb025e0b4cf2dd869c02fcdf2ec0f72725bbe2adaa3bd"], - "k_0_8": ["6be1ca4f8ee923e32137b6cdae324b841a0a60afbee4f4ae457fe31f29e001a6"], - "k_0_9": ["2a99ceea87df667135cc1801682d2c5dc7b95b7efadc48e156345ba46f4c0dc6"], + "k_0_0": ["f2547dcbe38adc0fee943dc0b0a543f96b90af587850c9df172c69134a49f4c9"], + "k_0_1": ["0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a"], + "k_0_2": ["099bdff41fbbfc3d90ea5a8510d5588e71a27509592447025ee6dee4278e13ff"], + "k_0_3": ["c1ae51351f1267bf6747c888760f25cc199747a3cc2be7dd6a899223d748508c"], + "k_0_4": ["7eba642b2889d562edc75dc2653caf1d2b864a9db8a0e64e1b6d62e014c6ed5b"], + "k_0_5": ["be2b6216b6effadfa12f4588612396daa781a40b50a7bd73c1bf722b7855d4c3"], + "k_0_6": ["ddf040fca6a4609fcb1045216fc17772b821cf560802be267bd433596c2aa897"], + "k_0_7": ["5c9c6a409240e59d731c7d87c58d701e2d99cc87d073ff07114ebf5db602e87d"], + "k_0_8": ["03b3c0dae8d561f1ab38199b5dfa4930a18fe702b14332b996c93364819aef56"], + "k_0_9": ["98bf1f26ff3e8db88a4506d476122c2b2ff7f8e9e217b351e532fb95d6c9e308"], "k_0_10": [ - "9304094916a19040d3c8f10df90dae1144d1f09ac9e676e66bb76341c70388ac" + "0c6c028ede10b0c3180e9541675c16b72f4443663dd7dbe9b45037b230d55917" ], - "k_0_11": ["01b12fb2ea2533226471dfa863133ce390e3e13a804734e8af995a45aa7c7582"] + "k_0_11": ["eb1ebeefa4bc5f754daabb0f783f3685bd839429ee0a287bd26d8717265c3d27"] }; final Map>> historyBatchResponse = { @@ -179,10 +181,10 @@ final Map>> emptyHistoryBatchResponse = { }; final List activeScriptHashes = [ - "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c", - "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e", - "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9", - "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874", - "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b", - "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" + "8ba03c2c46ed4980fa1e4c84cbceeb2d5e1371a7ccbaf5f3d69c5114161a2247", + "3fedd8a2d5fc355727afe353413dc1a0ef861ba768744d5b8193c33cbc829339", + "b6fce6c41154ccf70676c5c91acd9b6899ef0195e34b4c05c4920daa827c19a3", + "0e8b6756b404db5a381fd71ad79cb595a6c36c938cf9913c5a0494b667c2151a", + "9b56ab30c7bef0e1eaa10a632c8e2dcdd11b2158d7a917c03d62936afd0015fc", + "c4b1d9cd4edb7c13eae863b1e4f8fd5acff29f1fe153c4f859906cbea26a3f2f" ]; diff --git a/test/services/coins/particl/particl_transaction_data_samples.dart b/test/services/coins/particl/particl_transaction_data_samples.dart index fb2a2a932..e90a90263 100644 --- a/test/services/coins/particl/particl_transaction_data_samples.dart +++ b/test/services/coins/particl/particl_transaction_data_samples.dart @@ -1,251 +1,265 @@ -// TODO these test vectors are valid for Namecoin: update for Particl - import 'package:stackwallet/models/paymint/transactions_model.dart'; final transactionData = TransactionData.fromMap({ - "3ef543d0887c3e9f9924f1b2d3b21410d0238937364663ed3414a2c2ddf4ccc6": tx1, - "dffa9543852197f9fb90f8adafaab8a0b9b4925e9ada8c6bdcaf00bf2e9f60d7": tx2, - "71b56532e9e7321bd8c30d0f8b14530743049d2f3edd5623065c46eee1dda04d": tx3, - "c7e700f7e23a85bbdd9de86d502322a933607ee7ea7e16adaf02e477cdd849b9": tx4, + "a51831f09072dc9edb3130f677a484ca03bced8f6d803e8df83a1ed84bc06c0a": tx1, + "39a9c37d54d04f9ac6ed45aaa1a02b058391b5d1fc0e2e1d67e50f36b1d82896": tx2, + "e53ef367a5f9d8493825400a291136870ea24a750f63897f559851ab80ea1020": tx3, + "10e14b1d34c18a563b476c4c36688eb7caebf6658e25753074471d2adef460ba": tx4, }); final tx1 = Transaction( - txid: "3ef543d0887c3e9f9924f1b2d3b21410d0238937364663ed3414a2c2ddf4ccc6", + txid: "a51831f09072dc9edb3130f677a484ca03bced8f6d803e8df83a1ed84bc06c0a", confirmedStatus: true, - confirmations: 212, + confirmations: 15447, txType: "Received", - amount: 1000000, - fees: 23896, - height: 629633, - address: "nc1qwfda4s9qmdqpnykgpjf85n09ath983srtuxcqx", - timestamp: 1663093275, + amount: 10000000, + fees: 53600, + height: 1299909, + address: "PtQCgwUx9mLmRDWxB3J7MPnNsWDcce7a5g", + timestamp: 1667814832, worthNow: "0.00", worthAtBlockTimestamp: "0.00", inputSize: 2, outputSize: 2, inputs: [ Input( - txid: "290904699ccbebd0921c4acc4f7a10f41141ee6a07bc64ebca5674c1e5ee8dfa", + txid: "e53ef367a5f9d8493825400a291136870ea24a750f63897f559851ab80ea1020", vout: 1, ), Input( - txid: "bd84ae7e09414b0ccf5dcbf70a1f89f2fd42119a98af35dd4ecc80210fed0487", + txid: "b255bf1b4b2f1a76eab45fd69e589b655261b049f238807b0acbf304d1b8195b", vout: 0, ), ], outputs: [ Output( - scriptpubkeyAddress: "nc1qwfda4s9qmdqpnykgpjf85n09ath983srtuxcqx", - value: 1000000, + scriptpubkeyAddress: "PtQCgwUx9mLmRDWxB3J7MPnNsWDcce7a5g", + value: 10000000, ), Output( - scriptpubkeyAddress: "nc1qp7h7fxcnkqcpul202z6nh8yjy8jpt39jcpeapj", - value: 29853562, + scriptpubkeyAddress: "PsHtVuRCybcTpJQN6ckLFptPB7k9ZkqztA", + value: 9946400, ) ], ); final tx2 = Transaction( - txid: "dffa9543852197f9fb90f8adafaab8a0b9b4925e9ada8c6bdcaf00bf2e9f60d7", + txid: "39a9c37d54d04f9ac6ed45aaa1a02b058391b5d1fc0e2e1d67e50f36b1d82896", confirmedStatus: true, - confirmations: 150, + confirmations: 13927, txType: "Sent", - amount: 988567, - fees: 11433, - height: 629695, - address: "nc1qraffwaq3cxngwp609e03ynwsx8ykgjnjve9f3y", - timestamp: 1663142110, + amount: 50000000, + fees: 49500, + height: 1301433, + address: "PcKLXor8hqb3qSjtoHQThapJSbPapSDt4C", + timestamp: 1668010880, worthNow: "0.00", worthAtBlockTimestamp: "0.00", inputSize: 1, - outputSize: 1, + outputSize: 2, inputs: [ Input( - txid: "3ef543d0887c3e9f9924f1b2d3b21410d0238937364663ed3414a2c2ddf4ccc6", - vout: 0, - ), - ], - outputs: [ - Output( - scriptpubkeyAddress: "nc1qraffwaq3cxngwp609e03ynwsx8ykgjnjve9f3y", - value: 988567, - ), - ], -); - -final tx3 = Transaction( - txid: "71b56532e9e7321bd8c30d0f8b14530743049d2f3edd5623065c46eee1dda04d", - confirmedStatus: true, - confirmations: 147, - txType: "Received", - amount: 988567, - fees: 11433, - height: 629699, - address: "nc1qw4srwqq2semrxje4x6zcrg53g07q0pr3yqv5kr", - timestamp: 1663145287, - worthNow: "0.00", - worthAtBlockTimestamp: "0.00", - inputSize: 2, - outputSize: 1, - inputs: [ - Input( - txid: "dffa9543852197f9fb90f8adafaab8a0b9b4925e9ada8c6bdcaf00bf2e9f60d7", - vout: 0, - ), - Input( - txid: "80f8c6de5be2243013348219bbb7043a6d8d00ddc716baf6a69eab517f9a6fc1", + txid: "909bdf555736c272df0e1df52ca5fcce4f1090b74c0e5d9319bb40e02f4b3add", vout: 1, ), ], outputs: [ Output( - scriptpubkeyAddress: "nc1qw4srwqq2semrxje4x6zcrg53g07q0pr3yqv5kr", - value: 1000000, + scriptpubkeyAddress: "PcKLXor8hqb3qSjtoHQThapJSbPapSDt4C", + value: 50000000, ), Output( - scriptpubkeyAddress: "nc1qsgr7u4hd22rc64r9vlef69en9wzlvmjt8dzyrm", - value: 28805770, + scriptpubkeyAddress: "PjDq9kwadvgKNtQLTdGqcDsFzPmk9LMjT7", + value: 1749802000, + ), + ], +); + +final tx3 = Transaction( + txid: "e53ef367a5f9d8493825400a291136870ea24a750f63897f559851ab80ea1020", + confirmedStatus: true, + confirmations: 23103, + txType: "Received", + amount: 10000000, + fees: 34623, + height: 1292263, + address: "PhDSyHLt7ejdPXGve3HFr93pSdFLHUBwdr", + timestamp: 1666827392, + worthNow: "0.00", + worthAtBlockTimestamp: "0.00", + inputSize: 1, + outputSize: 2, + inputs: [ + Input( + txid: "8a2c6a4c0797d057f20f93b5e3b6e5f306493c67b2341626e0375f30f35a2d47", + vout: 0, + ) + ], + outputs: [ + Output( + scriptpubkeyAddress: "PYv7kk7TKQsSosWLuLveMJqAYxTiDiK5kp", + value: 39915877, + ), + Output( + scriptpubkeyAddress: "PhDSyHLt7ejdPXGve3HFr93pSdFLHUBwdr", + value: 10000000, ), ], ); final tx4 = Transaction( - txid: "c7e700f7e23a85bbdd9de86d502322a933607ee7ea7e16adaf02e477cdd849b9", + txid: "10e14b1d34c18a563b476c4c36688eb7caebf6658e25753074471d2adef460ba", confirmedStatus: true, - confirmations: 130, + confirmations: 493, txType: "Sent", - amount: 988567, - fees: 11433, - height: 629717, - address: "nc1qmdt0fxhpwx7x5ymmm9gvh229adu0kmtukfcsjk", - timestamp: 1663155739, + amount: 9945773, + fees: 27414, + height: 1314873, + address: "PpqgMahyfqfasunUKfkmVfdpyhhrHa2ibY", + timestamp: 1669740960, worthNow: "0.00", worthAtBlockTimestamp: "0.00", inputSize: 1, outputSize: 1, inputs: [ Input( - txid: "71b56532e9e7321bd8c30d0f8b14530743049d2f3edd5623065c46eee1dda04d", + txid: "aab01876c4db40b35ba00bbfb7c58aaec32cad7dc136214b7344a944606cbe73", vout: 0, ), ], outputs: [ Output( - scriptpubkeyAddress: "nc1qmdt0fxhpwx7x5ymmm9gvh229adu0kmtukfcsjk", - value: 988567, + scriptpubkeyAddress: "PpqgMahyfqfasunUKfkmVfdpyhhrHa2ibY", + value: 9945773, ), ], ); final tx1Raw = { - "txid": "3ef543d0887c3e9f9924f1b2d3b21410d0238937364663ed3414a2c2ddf4ccc6", - "hash": "40c8dd876cf111dc00d3aa2fedc93a77c18b391931939d4f99a760226cbff675", - "version": 2, - "size": 394, - "vsize": 232, - "weight": 925, - "locktime": 0, + "txid": "a51831f09072dc9edb3130f677a484ca03bced8f6d803e8df83a1ed84bc06c0a", + "hash": "46b7358ccbc018da4e144188f311657e8b694f056211d7511726c4259dca86b4", + "size": 374, + "vsize": 267, + "version": 160, + "locktime": 1299908, "vin": [ { "txid": - "290904699ccbebd0921c4acc4f7a10f41141ee6a07bc64ebca5674c1e5ee8dfa", + "e53ef367a5f9d8493825400a291136870ea24a750f63897f559851ab80ea1020", "vout": 1, - "scriptSig": { - "asm": "001466d2173325f3d379c6beb0a4949e937308edb152", - "hex": "16001466d2173325f3d379c6beb0a4949e937308edb152" - }, + "scriptSig": {"asm": "", "hex": ""}, "txinwitness": [ - "3044022062d0f32dc051ed1e91889a96070121c77d895f69d2ed5a307d8b320e0352186702206a0c2613e708e5ef8a935aba61b8fa14ddd6ca4e9a80a8b4ded126a879217dd101", - "0303cd92ed121ef22398826af055f3006769210e019f8fb43bd2f5556282d84997" + "30440220336bf0952b543314ba37b1bb8866a65b2482b499c715d778e92e90d7d59c6a39022072cae4341ca8825bee8043ae91f18de5776edd069ed228142eca55a16c887d6b01", + "026b4ca62de9e8f63abd0a6cf176536fe8e6a64d6343b6396aa9fb35232520e4a7" ], - "sequence": 4294967295 + "sequence": 4294967293 }, { "txid": - "bd84ae7e09414b0ccf5dcbf70a1f89f2fd42119a98af35dd4ecc80210fed0487", + "b255bf1b4b2f1a76eab45fd69e589b655261b049f238807b0acbf304d1b8195b", "vout": 0, "scriptSig": {"asm": "", "hex": ""}, "txinwitness": [ - "3045022100e8814706766a2d7588908c51209c3b7095241bbc681febdd6b317b7e9b6ea97502205c33c63e4d8a675c19122bfe0057afce2159e6bd86f2c9aced214de77099dc8b01", - "03c35212e3a4c0734735eccae9219987dc78d9cf6245ab247942d430d0a01d61be" + "304402205b914f31952958d54f0290d47eef6d9042259387c9493993882e24bd9acefe00022066b16f2f41885a85051c9bff4c119ecddc0209520e9a93d75866624f11b4e82d01", + "026b4ca62de9e8f63abd0a6cf176536fe8e6a64d6343b6396aa9fb35232520e4a7" ], - "sequence": 4294967295 + "sequence": 4294967293 } ], "vout": [ { - "value": 0.01, "n": 0, + "type": "standard", + "value": 0.1, + "valueSat": 10000000, "scriptPubKey": { - "asm": "0 725bdac0a0db401992c80c927a4de5eaee53c603", - "hex": "0014725bdac0a0db401992c80c927a4de5eaee53c603", + "asm": + "OP_DUP OP_HASH160 e0923d464a2c30438f0808e4af94868253b63ca0 OP_EQUALVERIFY OP_CHECKSIG", + "hex": "76a914e0923d464a2c30438f0808e4af94868253b63ca088ac", "reqSigs": 1, - "type": "witness_v0_keyhash", - "addresses": ["nc1qwfda4s9qmdqpnykgpjf85n09ath983srtuxcqx"] + "type": "pubkeyhash", + "addresses": ["PtQCgwUx9mLmRDWxB3J7MPnNsWDcce7a5g"] } }, { - "value": 0.29853562, "n": 1, + "type": "standard", + "value": 0.099464, + "valueSat": 9946400, "scriptPubKey": { - "asm": "0 0fafe49b13b0301e7d4f50b53b9c9221e415c4b2", - "hex": "00140fafe49b13b0301e7d4f50b53b9c9221e415c4b2", + "asm": + "OP_DUP OP_HASH160 d4686eee8cd127b50d28869627d61b38cc63fe4a OP_EQUALVERIFY OP_CHECKSIG", + "hex": "76a914d4686eee8cd127b50d28869627d61b38cc63fe4a88ac", "reqSigs": 1, - "type": "witness_v0_keyhash", - "addresses": ["nc1qp7h7fxcnkqcpul202z6nh8yjy8jpt39jcpeapj"] + "type": "pubkeyhash", + "addresses": ["PsHtVuRCybcTpJQN6ckLFptPB7k9ZkqztA"] } } ], - "hex": - "02000000000102fa8deee5c17456caeb64bc076aee4111f4107a4fcc4a1c92d0ebcb9c69040929010000001716001466d2173325f3d379c6beb0a4949e937308edb152ffffffff8704ed0f2180cc4edd35af989a1142fdf2891f0af7cb5dcf0c4b41097eae84bd0000000000ffffffff0240420f0000000000160014725bdac0a0db401992c80c927a4de5eaee53c6037a87c701000000001600140fafe49b13b0301e7d4f50b53b9c9221e415c4b202473044022062d0f32dc051ed1e91889a96070121c77d895f69d2ed5a307d8b320e0352186702206a0c2613e708e5ef8a935aba61b8fa14ddd6ca4e9a80a8b4ded126a879217dd101210303cd92ed121ef22398826af055f3006769210e019f8fb43bd2f5556282d8499702483045022100e8814706766a2d7588908c51209c3b7095241bbc681febdd6b317b7e9b6ea97502205c33c63e4d8a675c19122bfe0057afce2159e6bd86f2c9aced214de77099dc8b012103c35212e3a4c0734735eccae9219987dc78d9cf6245ab247942d430d0a01d61be00000000", "blockhash": - "c9f53cc7cbf654cbcc400e17b33e03a32706d6e6647ad7085c688540f980a378", - "confirmations": 212, - "time": 1663093275, - "blocktime": 1663093275 + "b7cb29eb9cb4fa73c4da32f5cf8dfd90194eb6b689d4e547fa9b3176a698a741", + "height": 1299909, + "confirmations": 15447, + "time": 1667814832, + "blocktime": 1667814832 }; final tx2Raw = { - "txid": "dffa9543852197f9fb90f8adafaab8a0b9b4925e9ada8c6bdcaf00bf2e9f60d7", - "hash": "32dbc0d21327e0cb94ec6069a8d235affd99689ffc5f68959bfb720bafc04bcf", - "version": 2, - "size": 192, - "vsize": 110, - "weight": 438, - "locktime": 0, + "txid": "39a9c37d54d04f9ac6ed45aaa1a02b058391b5d1fc0e2e1d67e50f36b1d82896", + "hash": "85130125ec9e37a48670fb5eb0a2780b94ea958cd700a1237ff75775d8a0edb0", + "size": 226, + "vsize": 173, + "version": 160, + "locktime": 1301432, "vin": [ { "txid": - "3ef543d0887c3e9f9924f1b2d3b21410d0238937364663ed3414a2c2ddf4ccc6", - "vout": 0, + "909bdf555736c272df0e1df52ca5fcce4f1090b74c0e5d9319bb40e02f4b3add", + "vout": 1, "scriptSig": {"asm": "", "hex": ""}, "txinwitness": [ - "30450221009d58ebfaab8eae297910bca93a7fd48f94ce52a1731cf27fb4c043368fa10e8d02207e88f5d868113d9567999793be0a5b752ad704d04224046839763cefe46463a501", - "02f6ca5274b59dfb014f6a0d690671964290dac7f97fe825f723204e6cb8daf086" + "30440220486c87376122e2d3ca7154f41a45fdafa2865412ec90e4b3db791915eee1d13002204cca8520a655b43c3cddc216725cc8508cd9b326a39ed99ed893be59167289af01", + "03acc7ad6e2e9560db73f7ec7ef2f55a6115d85069cf0eacfe3ab663f33415573c" ], - "sequence": 4294967295 + "sequence": 4294967293 } ], "vout": [ { - "value": 0.00988567, "n": 0, + "type": "standard", + "value": 0.5, + "valueSat": 50000000, "scriptPubKey": { - "asm": "0 1f52977411c1a687074f2e5f124dd031c9644a72", - "hex": "00141f52977411c1a687074f2e5f124dd031c9644a72", + "asm": + "OP_DUP OP_HASH160 3024b192883be45b197b548f71155829af980724 OP_EQUALVERIFY OP_CHECKSIG", + "hex": "76a9143024b192883be45b197b548f71155829af98072488ac", "reqSigs": 1, - "type": "witness_v0_keyhash", - "addresses": ["nc1qraffwaq3cxngwp609e03ynwsx8ykgjnjve9f3y"] + "type": "pubkeyhash", + "addresses": ["PcKLXor8hqb3qSjtoHQThapJSbPapSDt4C"] + } + }, + { + "n": 1, + "type": "standard", + "value": 17.49802, + "valueSat": 1749802000, + "scriptPubKey": { + "asm": + "OP_DUP OP_HASH160 7be2f80f6b9f6df740142fb34668c25c4e5c8bd5 OP_EQUALVERIFY OP_CHECKSIG", + "hex": "76a9147be2f80f6b9f6df740142fb34668c25c4e5c8bd588ac", + "reqSigs": 1, + "type": "pubkeyhash", + "addresses": ["PjDq9kwadvgKNtQLTdGqcDsFzPmk9LMjT7"] } } ], - "hex": - "02000000000101c6ccf4ddc2a21434ed634636378923d01014b2d3b2f124999f3e7c88d043f53e0000000000ffffffff0197150f00000000001600141f52977411c1a687074f2e5f124dd031c9644a72024830450221009d58ebfaab8eae297910bca93a7fd48f94ce52a1731cf27fb4c043368fa10e8d02207e88f5d868113d9567999793be0a5b752ad704d04224046839763cefe46463a5012102f6ca5274b59dfb014f6a0d690671964290dac7f97fe825f723204e6cb8daf08600000000", "blockhash": - "ae1129ee834853c45b9edbb7228497c7fa423d7d1bdec8fd155f9e3c429c84d3", - "confirmations": 150, - "time": 1663142110, - "blocktime": 1663142110 + "065c7328f1a768f3005ab7bfb322806bcc0cf88a96e89830b44991cc434c9955", + "height": 1301433, + "confirmations": 13927, + "time": 1668010880, + "blocktime": 1668010880 }; final tx3Raw = { @@ -314,44 +328,45 @@ final tx3Raw = { }; final tx4Raw = { - "txid": "c7e700f7e23a85bbdd9de86d502322a933607ee7ea7e16adaf02e477cdd849b9", - "hash": "c6b544ddd7d901fcc7218208a6cfc8e1819c403a22cc8a1f1a7029aafa427925", - "version": 2, - "size": 192, - "vsize": 110, - "weight": 438, - "locktime": 0, + "txid": "10e14b1d34c18a563b476c4c36688eb7caebf6658e25753074471d2adef460ba", + "hash": "cb0d83958db55c91fb9cd9cab65ee516e63aea68ae5650a692918779ceb46576", + "size": 191, + "vsize": 138, + "version": 160, + "locktime": 1314871, "vin": [ { "txid": - "71b56532e9e7321bd8c30d0f8b14530743049d2f3edd5623065c46eee1dda04d", + "aab01876c4db40b35ba00bbfb7c58aaec32cad7dc136214b7344a944606cbe73", "vout": 0, "scriptSig": {"asm": "", "hex": ""}, "txinwitness": [ - "3045022100c664c6ad206999e019954c5206a26c2eca1ae2572288c0f78074c279a4a210ce022017456fdf85f744d694fa2e4638acee782d809268ea4808c04d91da3ac4fe7fd401", - "035456b63e86c0a6235cb3debfb9654966a4c2362ec678ae3b9beec53d31a25eba" + "304402202e33ab9c5bb6a50c24de9ebfd1b2f398b4c9027787fb9620fda515a25b62ffcf02205e8371aeeda3b3765fa1e2a5c7ebce5dffbf18932012670c1f5266992f9ed9c901", + "039ca6c697fed4daf1697f137e7d5b113ff7b6c48ea48d707addd9cfa51889a42a" ], - "sequence": 4294967295 + "sequence": 4294967293 } ], "vout": [ { - "value": 0.00988567, "n": 0, + "type": "standard", + "value": 0.09945773, + "valueSat": 9945773, "scriptPubKey": { - "asm": "0 db56f49ae171bc6a137bd950cba945eb78fb6d7c", - "hex": "0014db56f49ae171bc6a137bd950cba945eb78fb6d7c", + "asm": + "OP_DUP OP_HASH160 b9833ad924ab05567ea2b679a5c523c66a1da6d7 OP_EQUALVERIFY OP_CHECKSIG", + "hex": "76a914b9833ad924ab05567ea2b679a5c523c66a1da6d788ac", "reqSigs": 1, - "type": "witness_v0_keyhash", - "addresses": ["nc1qmdt0fxhpwx7x5ymmm9gvh229adu0kmtukfcsjk"] + "type": "pubkeyhash", + "addresses": ["PpqgMahyfqfasunUKfkmVfdpyhhrHa2ibY"] } } ], - "hex": - "020000000001014da0dde1ee465c062356dd3e2f9d04430753148b0f0dc3d81b32e7e93265b5710000000000ffffffff0197150f0000000000160014db56f49ae171bc6a137bd950cba945eb78fb6d7c02483045022100c664c6ad206999e019954c5206a26c2eca1ae2572288c0f78074c279a4a210ce022017456fdf85f744d694fa2e4638acee782d809268ea4808c04d91da3ac4fe7fd40121035456b63e86c0a6235cb3debfb9654966a4c2362ec678ae3b9beec53d31a25eba00000000", "blockhash": - "6f60029ff3a32ca2d7e7e23c02b9cb35f61e7f9481992f9c3ded2c60c7b1de9b", - "confirmations": 130, - "time": 1663155739, - "blocktime": 1663155739 + "74e2d8acec688645120925c8a10d2fdf9ec61278534c0788d749162a6899ddaf", + "height": 1314873, + "confirmations": 493, + "time": 1669740960, + "blocktime": 1669740960 }; diff --git a/test/services/coins/particl/particl_utxo_sample_data.dart b/test/services/coins/particl/particl_utxo_sample_data.dart index 5a0dff492..57adb0357 100644 --- a/test/services/coins/particl/particl_utxo_sample_data.dart +++ b/test/services/coins/particl/particl_utxo_sample_data.dart @@ -1,22 +1,20 @@ -// TODO these test vectors are valid for Namecoin: update for Particl - import 'package:stackwallet/models/paymint/utxo_model.dart'; final Map>> batchGetUTXOResponse0 = { "some id 0": [ { "tx_pos": 0, - "value": 988567, + "value": 9973187, "tx_hash": - "32dbc0d21327e0cb94ec6069a8d235affd99689ffc5f68959bfb720bafc04bcf", - "height": 629695 + "7b932948c95cf483798011da3fc77b6d53ee26d3d2ba4d90748cd007bdce48e8", + "height": 1314869 }, { "tx_pos": 0, - "value": 1000000, + "value": 50000000, "tx_hash": - "40c8dd876cf111dc00d3aa2fedc93a77c18b391931939d4f99a760226cbff675", - "height": 629633 + "aae9e712e26e5ff77ac2258c47a845ad6e952d580c2ad805e2b5d7667f3d4e42", + "height": 1297229 }, ], "some id 1": [], @@ -24,36 +22,36 @@ final Map>> batchGetUTXOResponse0 = { final utxoList = [ UtxoObject( - txid: "dffa9543852197f9fb90f8adafaab8a0b9b4925e9ada8c6bdcaf00bf2e9f60d7", + txid: "aab01876c4db40b35ba00bbfb7c58aaec32cad7dc136214b7344a944606cbe73", vout: 0, status: Status( confirmed: true, - confirmations: 150, - blockHeight: 629695, - blockTime: 1663142110, + confirmations: 516, + blockHeight: 1314869, + blockTime: 1669740688, blockHash: - "32dbc0d21327e0cb94ec6069a8d235affd99689ffc5f68959bfb720bafc04bcf", + "6146005e4b21b72d0e2afe5b0cce3abd6e9e9e71c6cf6a1e1150d33e33ba81d4", ), - value: 988567, + value: 9973187, fiatWorth: "\$0", - txName: "nc1qraffwaq3cxngwp609e03ynwsx8ykgjnjve9f3y", + txName: "pw1qj6t0kvsmx8qd95pdh4rwxaz5qp5qtfz0xq2rja", blocked: false, isCoinbase: false, ), UtxoObject( - txid: "3ef543d0887c3e9f9924f1b2d3b21410d0238937364663ed3414a2c2ddf4ccc6", + txid: "909bdf555736c272df0e1df52ca5fcce4f1090b74c0e5d9319bb40e02f4b3add", vout: 0, status: Status( confirmed: true, - confirmations: 212, - blockHeight: 629633, - blockTime: 1663093275, + confirmations: 18173, + blockHeight: 1297229, + blockTime: 1667469296, blockHash: - "40c8dd876cf111dc00d3aa2fedc93a77c18b391931939d4f99a760226cbff675", + "5c5c1a4e2d9cc77a1df4337359f901c92bb4907cff85312599b06141fd1d96d9", ), - value: 1000000, + value: 50000000, fiatWorth: "\$0", - txName: "nc1qwfda4s9qmdqpnykgpjf85n09ath983srtuxcqx", + txName: "PhDSyHLt7ejdPXGve3HFr93pSdFLHUBwdr", blocked: false, isCoinbase: false, ), diff --git a/test/services/coins/particl/particl_wallet_test.dart b/test/services/coins/particl/particl_wallet_test.dart index 27fdaa9c7..844b61461 100644 --- a/test/services/coins/particl/particl_wallet_test.dart +++ b/test/services/coins/particl/particl_wallet_test.dart @@ -1,14 +1,18 @@ import 'package:flutter_test/flutter_test.dart'; +import 'package:hive/hive.dart'; +import 'package:hive_test/hive_test.dart'; import 'package:mockito/annotations.dart'; import 'package:mockito/mockito.dart'; import 'package:stackwallet/electrumx_rpc/cached_electrumx.dart'; import 'package:stackwallet/electrumx_rpc/electrumx.dart'; +import 'package:stackwallet/models/models.dart'; import 'package:stackwallet/services/coins/particl/particl_wallet.dart'; import 'package:stackwallet/services/price.dart'; import 'package:stackwallet/services/transaction_notification_tracker.dart'; import 'package:stackwallet/utilities/enums/coin_enum.dart'; import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart'; +import 'particl_history_sample_data.dart'; import 'particl_wallet_test.mocks.dart'; import 'particl_wallet_test_parameters.dart'; @@ -122,7 +126,7 @@ void main() { expect( mainnetWallet?.validateAddress("Pi9W46PhXkNRusar2KVMbXftYpGzEYGcSa"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(priceAPI); @@ -133,7 +137,7 @@ void main() { mainnetWallet?.addressType( address: "Pi9W46PhXkNRusar2KVMbXftYpGzEYGcSa"), DerivePathType.bip44); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); @@ -149,7 +153,7 @@ void main() { mainnetWallet ?.validateAddress("bc1qc5ymmsay89r6gr4fy2kklvrkuvzyln4shdvjhf"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(priceAPI); @@ -159,7 +163,7 @@ void main() { expect( mainnetWallet?.validateAddress("PputQYxNxMiYh3sg7vSh25wg3XxHiPHag7"), true); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(priceAPI); @@ -172,7 +176,7 @@ void main() { expect( mainnetWallet?.validateAddress("16YB85zQHjro7fqjR2hMcwdQWCX8jNVtr5"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(priceAPI); @@ -181,9 +185,9 @@ void main() { test("invalid mainnet particl p2wpkh address", () { expect( mainnetWallet - ?.validateAddress("pw1qce3dhmmle4e0833kssj7ptta3ehydjf0tsa3ju"), + ?.validateAddress("pw1qce3dhmmle4e0833mssj7ptta3ehydjf0tsa3ju"), false); - expect(secureStore?.interactions, 0); + expect(secureStore.interactions, 0); verifyNoMoreInteractions(client); verifyNoMoreInteractions(cachedClient); verifyNoMoreInteractions(tracker); @@ -487,1296 +491,1295 @@ void main() { // // }); // }); - // group("Particl service class functions that depend on shared storage", () { - // final testWalletId = "NMCtestWalletID"; - // final testWalletName = "NMCWallet"; - - // bool hiveAdaptersRegistered = false; - - // MockElectrumX? client; - // MockCachedElectrumX? cachedClient; - // MockPriceAPI? priceAPI; - // late FakeSecureStorage secureStore; - // MockTransactionNotificationTracker? tracker; - - // NamecoinWallet? nmc; - - // setUp(() async { - // await setUpTestHive(); - // if (!hiveAdaptersRegistered) { - // hiveAdaptersRegistered = true; - - // // Registering Transaction Model Adapters - // Hive.registerAdapter(TransactionDataAdapter()); - // Hive.registerAdapter(TransactionChunkAdapter()); - // Hive.registerAdapter(TransactionAdapter()); - // Hive.registerAdapter(InputAdapter()); - // Hive.registerAdapter(OutputAdapter()); - - // // Registering Utxo Model Adapters - // Hive.registerAdapter(UtxoDataAdapter()); - // Hive.registerAdapter(UtxoObjectAdapter()); - // Hive.registerAdapter(StatusAdapter()); - - // final wallets = await Hive.openBox('wallets'); - // await wallets.put('currentWalletName', testWalletName); - // } - - // client = MockElectrumX(); - // cachedClient = MockCachedElectrumX(); - // priceAPI = MockPriceAPI(); - // secureStore = FakeSecureStorage(); - // tracker = MockTransactionNotificationTracker(); - - // nmc = NamecoinWallet( - // walletId: testWalletId, - // walletName: testWalletName, - // coin: Coin.particl, - // client: client!, - // cachedClient: cachedClient!, - // tracker: tracker!, - // priceAPI: priceAPI, - // secureStore: secureStore, - // ); - // }); - - // // test("initializeWallet no network", () async { - // // when(client?.ping()).thenAnswer((_) async => false); - // // expect(await nmc?.initializeWallet(), false); - // // expect(secureStore.interactions, 0); - // // verify(client?.ping()).called(1); - // // verifyNoMoreInteractions(client); - // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); - // // }); - - // // test("initializeWallet no network exception", () async { - // // when(client?.ping()).thenThrow(Exception("Network connection failed")); - // // final wallets = await Hive.openBox(testWalletId); - // // expect(await nmc?.initializeExisting(), false); - // // expect(secureStore.interactions, 0); - // // verify(client?.ping()).called(1); - // // verifyNoMoreInteractions(client); - // // verifyNoMoreInteractions(cachedClient); - // // verifyNoMoreInteractions(priceAPI); - // // }); - - // test("initializeWallet mainnet throws bad network", () async { - // when(client?.ping()).thenAnswer((_) async => true); - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // // await nmc?.initializeNew(); - // final wallets = await Hive.openBox(testWalletId); - - // expectLater(() => nmc?.initializeExisting(), throwsA(isA())) - // .then((_) { - // expect(secureStore.interactions, 0); - // // verify(client?.ping()).called(1); - // // verify(client?.getServerFeatures()).called(1); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - // }); - - // test("initializeWallet throws mnemonic overwrite exception", () async { - // when(client?.ping()).thenAnswer((_) async => true); - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // await secureStore.write( - // key: "${testWalletId}_mnemonic", value: "some mnemonic"); - - // final wallets = await Hive.openBox(testWalletId); - // expectLater(() => nmc?.initializeExisting(), throwsA(isA())) - // .then((_) { - // expect(secureStore.interactions, 1); - // // verify(client?.ping()).called(1); - // // verify(client?.getServerFeatures()).called(1); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - // }); - - // test( - // "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", - // () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_TESTNET, - // "hash_function": "sha256", - // "services": [] - // }); - - // bool hasThrown = false; - // try { - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - // } catch (_) { - // hasThrown = true; - // } - // expect(hasThrown, true); - - // verify(client?.getServerFeatures()).called(1); - - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test( - // "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", - // () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - - // await secureStore.write( - // key: "${testWalletId}_mnemonic", value: "some mnemonic words"); - - // bool hasThrown = false; - // try { - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - // } catch (_) { - // hasThrown = true; - // } - // expect(hasThrown, true); - - // verify(client?.getServerFeatures()).called(1); - - // expect(secureStore.interactions, 2); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs1)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs2)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs3)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs4)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs5)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // await DB.instance.init(); - // final wallet = await Hive.openBox(testWalletId); - // bool hasThrown = false; - // try { - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - // } catch (_) { - // hasThrown = true; - // } - // expect(hasThrown, false); - - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - // expect(secureStore.interactions, 20); - // expect(secureStore.writes, 7); - // expect(secureStore.reads, 13); - // expect(secureStore.deletes, 0); - - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("get mnemonic list", () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs1)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs2)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs3)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs4)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs5)) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - - // final wallet = await Hive.openBox(testWalletId); - - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - - // expect(await nmc?.mnemonic, TEST_MNEMONIC.split(" ")); - - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("recoverFromMnemonic using non empty seed on mainnet succeeds", - // () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs1)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs2)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs3)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs4)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs5)) - // .thenAnswer((_) async => historyBatchResponse); - - // List dynamicArgValues = []; - - // when(client?.getBatchHistory(args: anyNamed("args"))) - // .thenAnswer((realInvocation) async { - // if (realInvocation.namedArguments.values.first.length == 1) { - // dynamicArgValues.add(realInvocation.namedArguments.values.first); - // } - - // return historyBatchResponse; - // }); - - // await Hive.openBox(testWalletId); - - // bool hasThrown = false; - // try { - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - // } catch (_) { - // hasThrown = true; - // } - // expect(hasThrown, false); - - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - // for (final arg in dynamicArgValues) { - // final map = Map>.from(arg as Map); - - // verify(client?.getBatchHistory(args: map)).called(1); - // expect(activeScriptHashes.contains(map.values.first.first as String), - // true); - // } - - // expect(secureStore.interactions, 14); - // expect(secureStore.writes, 7); - // expect(secureStore.reads, 7); - // expect(secureStore.deletes, 0); - - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("fullRescan succeeds", () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs1)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs2)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs3)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs4)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs5)) - // .thenAnswer((_) async => historyBatchResponse); - // when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - // .thenAnswer((realInvocation) async {}); - - // when(client?.getBatchHistory(args: { - // "0": [ - // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - - // when(client?.getBatchHistory(args: { - // "0": [ - // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - - // when(client?.getBatchHistory(args: { - // "0": [ - // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - - // when(client?.getBatchHistory(args: { - // "0": [ - // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // when(client?.getBatchHistory(args: { - // "0": [ - // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - // when(client?.getBatchHistory(args: { - // "0": [ - // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - - // final wallet = await Hive.openBox(testWalletId); - - // // restore so we have something to rescan - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - - // // fetch valid wallet data - // final preReceivingAddressesP2PKH = - // await wallet.get('receivingAddressesP2PKH'); - // final preReceivingAddressesP2SH = - // await wallet.get('receivingAddressesP2SH'); - // final preReceivingAddressesP2WPKH = - // await wallet.get('receivingAddressesP2WPKH'); - // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - // final preChangeAddressesP2WPKH = - // await wallet.get('changeAddressesP2WPKH'); - // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); - // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - // final preUtxoData = await wallet.get('latest_utxo_model'); - // final preReceiveDerivationsStringP2PKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2PKH"); - // final preChangeDerivationsStringP2PKH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - // final preReceiveDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - // final preChangeDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - // final preReceiveDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2WPKH"); - // final preChangeDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_changeDerivationsP2WPKH"); - - // // destroy the data that the rescan will fix - // await wallet.put( - // 'receivingAddressesP2PKH', ["some address", "some other address"]); - // await wallet.put( - // 'receivingAddressesP2SH', ["some address", "some other address"]); - // await wallet.put( - // 'receivingAddressesP2WPKH', ["some address", "some other address"]); - // await wallet - // .put('changeAddressesP2PKH', ["some address", "some other address"]); - // await wallet - // .put('changeAddressesP2SH', ["some address", "some other address"]); - // await wallet - // .put('changeAddressesP2WPKH', ["some address", "some other address"]); - // await wallet.put('receivingIndexP2PKH', 123); - // await wallet.put('receivingIndexP2SH', 123); - // await wallet.put('receivingIndexP2WPKH', 123); - // await wallet.put('changeIndexP2PKH', 123); - // await wallet.put('changeIndexP2SH', 123); - // await wallet.put('changeIndexP2WPKH', 123); - // await secureStore.write( - // key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); - // await secureStore.write( - // key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); - // await secureStore.write( - // key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); - // await secureStore.write( - // key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); - // await secureStore.write( - // key: "${testWalletId}_receiveDerivationsP2WPKH", value: "{}"); - // await secureStore.write( - // key: "${testWalletId}_changeDerivationsP2WPKH", value: "{}"); - - // bool hasThrown = false; - // try { - // await nmc?.fullRescan(2, 1000); - // } catch (_) { - // hasThrown = true; - // } - // expect(hasThrown, false); - - // // fetch wallet data again - // final receivingAddressesP2PKH = - // await wallet.get('receivingAddressesP2PKH'); - // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); - // final receivingAddressesP2WPKH = - // await wallet.get('receivingAddressesP2WPKH'); - // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); - // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); - // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - // final utxoData = await wallet.get('latest_utxo_model'); - // final receiveDerivationsStringP2PKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2PKH"); - // final changeDerivationsStringP2PKH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - // final receiveDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - // final changeDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - // final receiveDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2WPKH"); - // final changeDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_changeDerivationsP2WPKH"); - - // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); - // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); - // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - // expect(preChangeAddressesP2SH, changeAddressesP2SH); - // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); - // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - // expect(preReceivingIndexP2SH, receivingIndexP2SH); - // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); - // expect(preChangeIndexP2PKH, changeIndexP2PKH); - // expect(preChangeIndexP2SH, changeIndexP2SH); - // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); - // expect(preUtxoData, utxoData); - // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); - // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); - // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); - // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); - - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - // ] - // })).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - // ] - // })).called(2); - - // verify(client?.getBatchHistory(args: { - // "0": [ - // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - // ] - // })).called(2); - - // verify(client?.getBatchHistory(args: { - // "0": [ - // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - // ] - // })).called(2); - - // verify(client?.getBatchHistory(args: { - // "0": [ - // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - // ] - // })).called(2); - - // verify(client?.getBatchHistory(args: { - // "0": [ - // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - // ] - // })).called(2); - // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - // .called(1); - - // // for (final arg in dynamicArgValues) { - // // final map = Map>.from(arg as Map); - // // Map argCount = {}; - // // - // // // verify(client?.getBatchHistory(args: map)).called(1); - // // // expect(activeScriptHashes.contains(map.values.first.first as String), - // // // true); - // // } - - // // Map argCount = {}; - // // - // // for (final arg in dynamicArgValues) { - // // final map = Map>.from(arg as Map); - // // - // // final str = jsonEncode(map); - // // - // // if (argCount[str] == null) { - // // argCount[str] = 1; - // // } else { - // // argCount[str] = argCount[str]! + 1; - // // } - // // } - // // - // // argCount.forEach((key, value) => print("arg: $key\ncount: $value")); - - // expect(secureStore.writes, 25); - // expect(secureStore.reads, 32); - // expect(secureStore.deletes, 6); - - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("fullRescan fails", () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs1)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs2)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs3)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs4)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs5)) - // .thenAnswer((_) async => historyBatchResponse); - - // when(client?.getBatchHistory(args: { - // "0": [ - // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - - // when(client?.getBatchHistory(args: { - // "0": [ - // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - - // when(client?.getBatchHistory(args: { - // "0": [ - // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - - // when(client?.getBatchHistory(args: { - // "0": [ - // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - - // when(client?.getBatchHistory(args: { - // "0": [ - // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - - // when(client?.getBatchHistory(args: { - // "0": [ - // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - // ] - // })).thenAnswer((realInvocation) async => {"0": []}); - - // when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - // .thenAnswer((realInvocation) async {}); - - // final wallet = await Hive.openBox(testWalletId); - - // // restore so we have something to rescan - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - - // // fetch wallet data - // final preReceivingAddressesP2PKH = - // await wallet.get('receivingAddressesP2PKH'); - // final preReceivingAddressesP2SH = - // await wallet.get('receivingAddressesP2SH'); - // final preReceivingAddressesP2WPKH = - // await wallet.get('receivingAddressesP2WPKH'); - // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - // final preChangeAddressesP2WPKH = - // await wallet.get('changeAddressesP2WPKH'); - // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); - // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - // final preUtxoData = await wallet.get('latest_utxo_model'); - // final preReceiveDerivationsStringP2PKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2PKH"); - // final preChangeDerivationsStringP2PKH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - // final preReceiveDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - // final preChangeDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - // final preReceiveDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2WPKH"); - // final preChangeDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_changeDerivationsP2WPKH"); - - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenThrow(Exception("fake exception")); - - // bool hasThrown = false; - // try { - // await nmc?.fullRescan(2, 1000); - // } catch (_) { - // hasThrown = true; - // } - // expect(hasThrown, true); - - // // fetch wallet data again - // final receivingAddressesP2PKH = - // await wallet.get('receivingAddressesP2PKH'); - // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); - // final receivingAddressesP2WPKH = - // await wallet.get('receivingAddressesP2WPKH'); - // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); - // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); - // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); - // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); - // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); - // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); - // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); - // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); - // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); - // final utxoData = await wallet.get('latest_utxo_model'); - // final receiveDerivationsStringP2PKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2PKH"); - // final changeDerivationsStringP2PKH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); - // final receiveDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); - // final changeDerivationsStringP2SH = - // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); - // final receiveDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_receiveDerivationsP2WPKH"); - // final changeDerivationsStringP2WPKH = await secureStore.read( - // key: "${testWalletId}_changeDerivationsP2WPKH"); - - // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); - // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); - // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); - // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); - // expect(preChangeAddressesP2SH, changeAddressesP2SH); - // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); - // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); - // expect(preReceivingIndexP2SH, receivingIndexP2SH); - // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); - // expect(preChangeIndexP2PKH, changeIndexP2PKH); - // expect(preChangeIndexP2SH, changeIndexP2SH); - // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); - // expect(preUtxoData, utxoData); - // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); - // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); - // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); - // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); - // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); - // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); - - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); - // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); - - // verify(client?.getBatchHistory(args: { - // "0": [ - // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" - // ] - // })).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" - // ] - // })).called(1); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" - // ] - // })).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" - // ] - // })).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" - // ] - // })).called(2); - // verify(client?.getBatchHistory(args: { - // "0": [ - // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" - // ] - // })).called(2); - // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) - // .called(1); - - // expect(secureStore.writes, 19); - // expect(secureStore.reads, 32); - // expect(secureStore.deletes, 12); - - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("prepareSend fails", () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs1)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs2)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs3)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs4)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs5)) - // .thenAnswer((_) async => historyBatchResponse); - - // List dynamicArgValues = []; - - // when(client?.getBatchHistory(args: anyNamed("args"))) - // .thenAnswer((realInvocation) async { - // if (realInvocation.namedArguments.values.first.length == 1) { - // dynamicArgValues.add(realInvocation.namedArguments.values.first); - // } - - // return historyBatchResponse; - // }); - - // await Hive.openBox(testWalletId); - - // when(cachedClient?.getTransaction( - // txHash: - // "dffa9543852197f9fb90f8adafaab8a0b9b4925e9ada8c6bdcaf00bf2e9f60d7", - // coin: Coin.particl)) - // .thenAnswer((_) async => tx2Raw); - // when(cachedClient?.getTransaction( - // txHash: - // "71b56532e9e7321bd8c30d0f8b14530743049d2f3edd5623065c46eee1dda04d", - // coin: Coin.particl)) - // .thenAnswer((_) async => tx3Raw); - // when(cachedClient?.getTransaction( - // txHash: - // "c7e700f7e23a85bbdd9de86d502322a933607ee7ea7e16adaf02e477cdd849b9", - // coin: Coin.particl, - // )).thenAnswer((_) async => tx4Raw); - - // // recover to fill data - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - - // // modify addresses to properly mock data to build a tx - // final rcv44 = await secureStore.read( - // key: testWalletId + "_receiveDerivationsP2PKH"); - // await secureStore.write( - // key: testWalletId + "_receiveDerivationsP2PKH", - // value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", - // "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); - // final rcv49 = - // await secureStore.read(key: testWalletId + "_receiveDerivationsP2SH"); - // await secureStore.write( - // key: testWalletId + "_receiveDerivationsP2SH", - // value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk", - // "36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g")); - // final rcv84 = await secureStore.read( - // key: testWalletId + "_receiveDerivationsP2WPKH"); - // await secureStore.write( - // key: testWalletId + "_receiveDerivationsP2WPKH", - // value: rcv84?.replaceFirst( - // "bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0", - // "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc")); - - // nmc?.outputsList = utxoList; - - // bool didThrow = false; - // try { - // await nmc?.prepareSend( - // address: "nc1q6k4x8ye6865z3rc8zkt8gyu52na7njqt6hsk4v", - // satoshiAmount: 15000); - // } catch (_) { - // didThrow = true; - // } - - // expect(didThrow, true); - - // verify(client?.getServerFeatures()).called(1); - - // /// verify transaction no matching calls - - // // verify(cachedClient?.getTransaction( - // // txHash: - // // "2087ce09bc316877c9f10971526a2bffa3078d52ea31752639305cdcd8230703", - // // coin: Coin.particl, - // // callOutSideMainIsolate: false)) - // // .called(1); - // // verify(cachedClient?.getTransaction( - // // txHash: - // // "ed32c967a0e86d51669ac21c2bb9bc9c50f0f55fbacdd8db21d0a986fba93bd7", - // // coin: Coin.particl, - // // callOutSideMainIsolate: false)) - // // .called(1); - // // verify(cachedClient?.getTransaction( - // // txHash: - // // "3f0032f89ac44b281b50314cff3874c969c922839dddab77ced54e86a21c3fd4", - // // coin: Coin.particl, - // // callOutSideMainIsolate: false)) - // // .called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - // for (final arg in dynamicArgValues) { - // final map = Map>.from(arg as Map); - - // verify(client?.getBatchHistory(args: map)).called(1); - // expect(activeScriptHashes.contains(map.values.first.first as String), - // true); - // } - - // expect(secureStore.interactions, 20); - // expect(secureStore.writes, 10); - // expect(secureStore.reads, 10); - // expect(secureStore.deletes, 0); - - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("confirmSend no hex", () async { - // bool didThrow = false; - // try { - // await nmc?.confirmSend(txData: {"some": "strange map"}); - // } catch (_) { - // didThrow = true; - // } - - // expect(didThrow, true); - - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("confirmSend hex is not string", () async { - // bool didThrow = false; - // try { - // await nmc?.confirmSend(txData: {"hex": true}); - // } catch (_) { - // didThrow = true; - // } - - // expect(didThrow, true); - - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("confirmSend hex is string but missing other data", () async { - // bool didThrow = false; - // try { - // await nmc?.confirmSend(txData: {"hex": "a string"}); - // } catch (_) { - // didThrow = true; - // } - - // expect(didThrow, true); - - // verify(client?.broadcastTransaction( - // rawTx: "a string", requestID: anyNamed("requestID"))) - // .called(1); - - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("confirmSend fails due to vSize being greater than fee", () async { - // bool didThrow = false; - // try { - // await nmc - // ?.confirmSend(txData: {"hex": "a string", "fee": 1, "vSize": 10}); - // } catch (_) { - // didThrow = true; - // } - - // expect(didThrow, true); - - // verify(client?.broadcastTransaction( - // rawTx: "a string", requestID: anyNamed("requestID"))) - // .called(1); - - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("confirmSend fails when broadcast transactions throws", () async { - // when(client?.broadcastTransaction( - // rawTx: "a string", requestID: anyNamed("requestID"))) - // .thenThrow(Exception("some exception")); - - // bool didThrow = false; - // try { - // await nmc - // ?.confirmSend(txData: {"hex": "a string", "fee": 10, "vSize": 10}); - // } catch (_) { - // didThrow = true; - // } - - // expect(didThrow, true); - - // verify(client?.broadcastTransaction( - // rawTx: "a string", requestID: anyNamed("requestID"))) - // .called(1); - - // expect(secureStore.interactions, 0); - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(tracker); - // verifyNoMoreInteractions(priceAPI); - // }); - // // - // // // this test will create a non mocked electrumx client that will try to connect - // // // to the provided ipAddress below. This will throw a bunch of errors - // // // which what we want here as actually calling electrumx calls here is unwanted. - // // // test("listen to NodesChangedEvent", () async { - // // // nmc = NamecoinWallet( - // // // walletId: testWalletId, - // // // walletName: testWalletName, - // // // networkType: BasicNetworkType.test, - // // // client: client, - // // // cachedClient: cachedClient, - // // // priceAPI: priceAPI, - // // // secureStore: secureStore, - // // // ); - // // // - // // // // set node - // // // final wallet = await Hive.openBox(testWalletId); - // // // await wallet.put("nodes", { - // // // "default": { - // // // "id": "some nodeID", - // // // "ipAddress": "some address", - // // // "port": "9000", - // // // "useSSL": true, - // // // } - // // // }); - // // // await wallet.put("activeNodeID_Bitcoin", "default"); - // // // - // // // final a = nmc.cachedElectrumXClient; - // // // - // // // // return when refresh is called on node changed trigger - // // // nmc.longMutex = true; - // // // - // // // GlobalEventBus.instance - // // // .fire(NodesChangedEvent(NodesChangedEventType.updatedCurrentNode)); - // // // - // // // // make sure event has processed before continuing - // // // await Future.delayed(Duration(seconds: 5)); - // // // - // // // final b = nmc.cachedElectrumXClient; - // // // - // // // expect(identical(a, b), false); - // // // - // // // await nmc.exit(); - // // // - // // // expect(secureStore.interactions, 0); - // // // verifyNoMoreInteractions(client); - // // // verifyNoMoreInteractions(cachedClient); - // // // verifyNoMoreInteractions(priceAPI); - // // // }); - - // test("refresh wallet mutex locked", () async { - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.getBatchHistory(args: historyBatchArgs0)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs1)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs2)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs3)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs4)) - // .thenAnswer((_) async => historyBatchResponse); - // when(client?.getBatchHistory(args: historyBatchArgs5)) - // .thenAnswer((_) async => historyBatchResponse); - - // List dynamicArgValues = []; - - // when(client?.getBatchHistory(args: anyNamed("args"))) - // .thenAnswer((realInvocation) async { - // if (realInvocation.namedArguments.values.first.length == 1) { - // dynamicArgValues.add(realInvocation.namedArguments.values.first); - // } - - // return historyBatchResponse; - // }); - - // await Hive.openBox(testWalletId); - - // // recover to fill data - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - - // nmc?.refreshMutex = true; - - // await nmc?.refresh(); - - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); - // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); - - // for (final arg in dynamicArgValues) { - // final map = Map>.from(arg as Map); - - // verify(client?.getBatchHistory(args: map)).called(1); - // expect(activeScriptHashes.contains(map.values.first.first as String), - // true); - // } - - // expect(secureStore.interactions, 14); - // expect(secureStore.writes, 7); - // expect(secureStore.reads, 7); - // expect(secureStore.deletes, 0); - - // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(tracker); - // verifyNoMoreInteractions(priceAPI); - // }); - - // test("refresh wallet normally", () async { - // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => - // {"height": 520481, "hex": "some block hex"}); - // when(client?.getServerFeatures()).thenAnswer((_) async => { - // "hosts": {}, - // "pruning": null, - // "server_version": "Unit tests", - // "protocol_min": "1.4", - // "protocol_max": "1.4.2", - // "genesis_hash": GENESIS_HASH_MAINNET, - // "hash_function": "sha256", - // "services": [] - // }); - // when(client?.getHistory(scripthash: anyNamed("scripthash"))) - // .thenAnswer((_) async => []); - // when(client?.estimateFee(blocks: anyNamed("blocks"))) - // .thenAnswer((_) async => Decimal.one); - - // when(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")) - // .thenAnswer((_) async => {Coin.particl: Tuple2(Decimal.one, 0.3)}); - - // final List dynamicArgValues = []; - - // when(client?.getBatchHistory(args: anyNamed("args"))) - // .thenAnswer((realInvocation) async { - // dynamicArgValues.add(realInvocation.namedArguments.values.first); - // return historyBatchResponse; - // }); - - // await Hive.openBox(testWalletId); - - // // recover to fill data - // await nmc?.recoverFromMnemonic( - // mnemonic: TEST_MNEMONIC, - // maxUnusedAddressGap: 2, - // maxNumberOfIndexesToCheck: 1000, - // height: 4000); - - // when(client?.getBatchHistory(args: anyNamed("args"))) - // .thenAnswer((_) async => {}); - // when(client?.getBatchUTXOs(args: anyNamed("args"))) - // .thenAnswer((_) async => emptyHistoryBatchResponse); - - // await nmc?.refresh(); - - // verify(client?.getServerFeatures()).called(1); - // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(4); - // verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); - // verify(client?.getBlockHeadTip()).called(1); - // verify(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")).called(2); - - // for (final arg in dynamicArgValues) { - // final map = Map>.from(arg as Map); - - // verify(client?.getBatchHistory(args: map)).called(1); - // } - - // expect(secureStore.interactions, 14); - // expect(secureStore.writes, 7); - // expect(secureStore.reads, 7); - // expect(secureStore.deletes, 0); - - // // verifyNoMoreInteractions(client); - // verifyNoMoreInteractions(cachedClient); - // verifyNoMoreInteractions(priceAPI); - // }); - - // tearDown(() async { - // await tearDownTestHive(); - // }); - // }); + group("Particl service class functions that depend on shared storage", () { + const testWalletId = "ParticltestWalletID"; + const testWalletName = "ParticlWallet"; + + bool hiveAdaptersRegistered = false; + + MockElectrumX? client; + MockCachedElectrumX? cachedClient; + MockPriceAPI? priceAPI; + late FakeSecureStorage secureStore; + MockTransactionNotificationTracker? tracker; + + ParticlWallet? part; + + setUp(() async { + await setUpTestHive(); + if (!hiveAdaptersRegistered) { + hiveAdaptersRegistered = true; + + // Registering Transaction Model Adapters + Hive.registerAdapter(TransactionDataAdapter()); + Hive.registerAdapter(TransactionChunkAdapter()); + Hive.registerAdapter(TransactionAdapter()); + Hive.registerAdapter(InputAdapter()); + Hive.registerAdapter(OutputAdapter()); + + // Registering Utxo Model Adapters + Hive.registerAdapter(UtxoDataAdapter()); + Hive.registerAdapter(UtxoObjectAdapter()); + Hive.registerAdapter(StatusAdapter()); + + final wallets = await Hive.openBox('wallets'); + await wallets.put('currentWalletName', testWalletName); + } + + client = MockElectrumX(); + cachedClient = MockCachedElectrumX(); + priceAPI = MockPriceAPI(); + secureStore = FakeSecureStorage(); + tracker = MockTransactionNotificationTracker(); + + part = ParticlWallet( + walletId: testWalletId, + walletName: testWalletName, + coin: Coin.particl, + client: client!, + cachedClient: cachedClient!, + tracker: tracker!, + priceAPI: priceAPI, + secureStore: secureStore, + ); + }); + + // test("initializeWallet no network", () async { + // when(client?.ping()).thenAnswer((_) async => false); + // expect(await part?.initializeNew(), false); + // expect(secureStore.interactions, 0); + // verify(client?.ping()).called(1); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + // test("initializeWallet no network exception", () async { + // when(client?.ping()).thenThrow(Exception("Network connection failed")); + // final wallets = await Hive.openBox(testWalletId); + // expect(await nmc?.initializeExisting(), false); + // expect(secureStore.interactions, 0); + // verify(client?.ping()).called(1); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + // test("initializeWallet mainnet throws bad network", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // // await nmc?.initializeNew(); + // final wallets = await Hive.openBox(testWalletId); + // + // expectLater(() => nmc?.initializeExisting(), throwsA(isA())) + // .then((_) { + // expect(secureStore.interactions, 0); + // // verify(client?.ping()).called(1); + // // verify(client?.getServerFeatures()).called(1); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + // }); + // + // test("initializeWallet throws mnemonic overwrite exception", () async { + // when(client?.ping()).thenAnswer((_) async => true); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // await secureStore.write( + // key: "${testWalletId}_mnemonic", value: "some mnemonic"); + // + // final wallets = await Hive.openBox(testWalletId); + // expectLater(() => nmc?.initializeExisting(), throwsA(isA())) + // .then((_) { + // expect(secureStore.interactions, 1); + // // verify(client?.ping()).called(1); + // // verify(client?.getServerFeatures()).called(1); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + // }); + // + // test( + // "recoverFromMnemonic using empty seed on mainnet fails due to bad genesis hash match", + // () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_TESTNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // bool hasThrown = false; + // try { + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, true); + // + // verify(client?.getServerFeatures()).called(1); + // + // expect(secureStore.interactions, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + // + // test( + // "recoverFromMnemonic using empty seed on mainnet fails due to attempted overwrite of mnemonic", + // () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // await secureStore.write( + // key: "${testWalletId}_mnemonic", value: "some mnemonic words"); + // + // bool hasThrown = false; + // try { + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, true); + // + // verify(client?.getServerFeatures()).called(1); + // + // expect(secureStore.interactions, 2); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + // test("recoverFromMnemonic using empty seed on mainnet succeeds", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // await DB.instance.init(); + // final wallet = await Hive.openBox(testWalletId); + // bool hasThrown = false; + // try { + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // expect(secureStore.interactions, 20); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 13); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + // test("get mnemonic list", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // + // final wallet = await Hive.openBox(testWalletId); + // + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // expect(await nmc?.mnemonic, TEST_MNEMONIC.split(" ")); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + test("recoverFromMnemonic using non empty seed on mainnet succeeds", + () async { + when(client?.getServerFeatures()).thenAnswer((_) async => { + "hosts": {}, + "pruning": null, + "server_version": "Unit tests", + "protocol_min": "1.4", + "protocol_max": "1.4.2", + "genesis_hash": GENESIS_HASH_MAINNET, + "hash_function": "sha256", + "services": [] + }); + when(client?.getBatchHistory(args: historyBatchArgs0)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs1)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs2)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs3)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs4)) + .thenAnswer((_) async => historyBatchResponse); + when(client?.getBatchHistory(args: historyBatchArgs5)) + .thenAnswer((_) async => historyBatchResponse); + + List dynamicArgValues = []; + + when(client?.getBatchHistory(args: anyNamed("args"))) + .thenAnswer((realInvocation) async { + if (realInvocation.namedArguments.values.first.length == 1) { + dynamicArgValues.add(realInvocation.namedArguments.values.first); + } + + return historyBatchResponse; + }); + + await Hive.openBox(testWalletId); + + bool hasThrown = false; + try { + await part?.recoverFromMnemonic( + mnemonic: TEST_MNEMONIC, + maxUnusedAddressGap: 2, + maxNumberOfIndexesToCheck: 1000, + height: 4000); + } catch (_) { + hasThrown = true; + } + expect(hasThrown, false); + + verify(client?.getServerFeatures()).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + + for (final arg in dynamicArgValues) { + final map = Map>.from(arg as Map); + verify(client?.getBatchHistory(args: map)).called(1); + expect(activeScriptHashes.contains(map.values.first.first as String), + true); + } + + expect(secureStore.interactions, 14); + expect(secureStore.writes, 7); + expect(secureStore.reads, 7); + expect(secureStore.deletes, 0); + + verifyNoMoreInteractions(client); + verifyNoMoreInteractions(cachedClient); + verifyNoMoreInteractions(priceAPI); + }); + + // test("fullRescan succeeds", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + // .thenAnswer((realInvocation) async {}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // when(client?.getBatchHistory(args: { + // "0": [ + // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch valid wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final preReceivingAddressesP2SH = + // await wallet.get('receivingAddressesP2SH'); + // final preReceivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final preChangeAddressesP2WPKH = + // await wallet.get('changeAddressesP2WPKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final preReceiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final preChangeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final preReceiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final preChangeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // // destroy the data that the rescan will fix + // await wallet.put( + // 'receivingAddressesP2PKH', ["some address", "some other address"]); + // await wallet.put( + // 'receivingAddressesP2SH', ["some address", "some other address"]); + // await wallet.put( + // 'receivingAddressesP2WPKH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2PKH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2SH', ["some address", "some other address"]); + // await wallet + // .put('changeAddressesP2WPKH', ["some address", "some other address"]); + // await wallet.put('receivingIndexP2PKH', 123); + // await wallet.put('receivingIndexP2SH', 123); + // await wallet.put('receivingIndexP2WPKH', 123); + // await wallet.put('changeIndexP2PKH', 123); + // await wallet.put('changeIndexP2SH', 123); + // await wallet.put('changeIndexP2WPKH', 123); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2PKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2PKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2SH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2SH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_receiveDerivationsP2WPKH", value: "{}"); + // await secureStore.write( + // key: "${testWalletId}_changeDerivationsP2WPKH", value: "{}"); + // + // bool hasThrown = false; + // try { + // await nmc?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, false); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); + // final receivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final receiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final changeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final receiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final changeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); + // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preChangeAddressesP2SH, changeAddressesP2SH); + // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preReceivingIndexP2SH, receivingIndexP2SH); + // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // expect(preChangeIndexP2SH, changeIndexP2SH); + // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); + // expect(preUtxoData, utxoData); + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); + // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); + // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); + // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" + // ] + // })).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" + // ] + // })).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" + // ] + // })).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" + // ] + // })).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" + // ] + // })).called(2); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + // .called(1); + + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // Map argCount = {}; + // + // // verify(client?.getBatchHistory(args: map)).called(1); + // // expect(activeScriptHashes.contains(map.values.first.first as String), + // // true); + // } + + // Map argCount = {}; + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // final str = jsonEncode(map); + // + // if (argCount[str] == null) { + // argCount[str] = 1; + // } else { + // argCount[str] = argCount[str]! + 1; + // } + // } + // + // argCount.forEach((key, value) => print("arg: $key\ncount: $value")); + + // expect(secureStore.writes, 25); + // expect(secureStore.reads, 32); + // expect(secureStore.deletes, 6); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + // test("fullRescan fails", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(client?.getBatchHistory(args: { + // "0": [ + // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" + // ] + // })).thenAnswer((realInvocation) async => {"0": []}); + // + // when(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + // .thenAnswer((realInvocation) async {}); + // + // final wallet = await Hive.openBox(testWalletId); + // + // // restore so we have something to rescan + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // fetch wallet data + // final preReceivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final preReceivingAddressesP2SH = + // await wallet.get('receivingAddressesP2SH'); + // final preReceivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final preChangeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final preChangeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final preChangeAddressesP2WPKH = + // await wallet.get('changeAddressesP2WPKH'); + // final preReceivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final preReceivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final preReceivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final preChangeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final preChangeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final preChangeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final preUtxoData = await wallet.get('latest_utxo_model'); + // final preReceiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final preChangeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final preReceiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final preChangeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final preReceiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final preChangeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenThrow(Exception("fake exception")); + // + // bool hasThrown = false; + // try { + // await nmc?.fullRescan(2, 1000); + // } catch (_) { + // hasThrown = true; + // } + // expect(hasThrown, true); + // + // // fetch wallet data again + // final receivingAddressesP2PKH = + // await wallet.get('receivingAddressesP2PKH'); + // final receivingAddressesP2SH = await wallet.get('receivingAddressesP2SH'); + // final receivingAddressesP2WPKH = + // await wallet.get('receivingAddressesP2WPKH'); + // final changeAddressesP2PKH = await wallet.get('changeAddressesP2PKH'); + // final changeAddressesP2SH = await wallet.get('changeAddressesP2SH'); + // final changeAddressesP2WPKH = await wallet.get('changeAddressesP2WPKH'); + // final receivingIndexP2PKH = await wallet.get('receivingIndexP2PKH'); + // final receivingIndexP2SH = await wallet.get('receivingIndexP2SH'); + // final receivingIndexP2WPKH = await wallet.get('receivingIndexP2WPKH'); + // final changeIndexP2PKH = await wallet.get('changeIndexP2PKH'); + // final changeIndexP2SH = await wallet.get('changeIndexP2SH'); + // final changeIndexP2WPKH = await wallet.get('changeIndexP2WPKH'); + // final utxoData = await wallet.get('latest_utxo_model'); + // final receiveDerivationsStringP2PKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2PKH"); + // final changeDerivationsStringP2PKH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2PKH"); + // final receiveDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_receiveDerivationsP2SH"); + // final changeDerivationsStringP2SH = + // await secureStore.read(key: "${testWalletId}_changeDerivationsP2SH"); + // final receiveDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_receiveDerivationsP2WPKH"); + // final changeDerivationsStringP2WPKH = await secureStore.read( + // key: "${testWalletId}_changeDerivationsP2WPKH"); + // + // expect(preReceivingAddressesP2PKH, receivingAddressesP2PKH); + // expect(preReceivingAddressesP2SH, receivingAddressesP2SH); + // expect(preReceivingAddressesP2WPKH, receivingAddressesP2WPKH); + // expect(preChangeAddressesP2PKH, changeAddressesP2PKH); + // expect(preChangeAddressesP2SH, changeAddressesP2SH); + // expect(preChangeAddressesP2WPKH, changeAddressesP2WPKH); + // expect(preReceivingIndexP2PKH, receivingIndexP2PKH); + // expect(preReceivingIndexP2SH, receivingIndexP2SH); + // expect(preReceivingIndexP2WPKH, receivingIndexP2WPKH); + // expect(preChangeIndexP2PKH, changeIndexP2PKH); + // expect(preChangeIndexP2SH, changeIndexP2SH); + // expect(preChangeIndexP2WPKH, changeIndexP2WPKH); + // expect(preUtxoData, utxoData); + // expect(preReceiveDerivationsStringP2PKH, receiveDerivationsStringP2PKH); + // expect(preChangeDerivationsStringP2PKH, changeDerivationsStringP2PKH); + // expect(preReceiveDerivationsStringP2SH, receiveDerivationsStringP2SH); + // expect(preChangeDerivationsStringP2SH, changeDerivationsStringP2SH); + // expect(preReceiveDerivationsStringP2WPKH, receiveDerivationsStringP2WPKH); + // expect(preChangeDerivationsStringP2WPKH, changeDerivationsStringP2WPKH); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(2); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(2); + // + // verify(client?.getBatchHistory(args: { + // "0": [ + // "dd63fc12f5e6c1ada2cf3c941d1648e6d561ce4024747bb2117d72112d83287c" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "cd3dd4abe4f9efc7149ba334d2d6790020331805b0bd5c7ed89a3ac6a22f10b9" + // ] + // })).called(1); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "42d6e40636f4740f9c7f95ef0bbc2a4c17f54da2bc98a32a622e2bf73eb675c3" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "587943864cefed4f1643a5ee2ce2b3c13a0c6ad7c435373f0ac328e144a15c1e" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "86906979fc9107d06d560275d7de8305b69d7189c3206ac9070ad76e6abff874" + // ] + // })).called(2); + // verify(client?.getBatchHistory(args: { + // "0": [ + // "c068e7fa4aa0b8a63114f6d11c047ca4be6a8fa333eb0dac48506e8f150af73b" + // ] + // })).called(2); + // verify(cachedClient?.clearSharedTransactionCache(coin: Coin.particl)) + // .called(1); + // + // expect(secureStore.writes, 19); + // expect(secureStore.reads, 32); + // expect(secureStore.deletes, 12); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + // test("prepareSend fails", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // when(cachedClient?.getTransaction( + // txHash: + // "dffa9543852197f9fb90f8adafaab8a0b9b4925e9ada8c6bdcaf00bf2e9f60d7", + // coin: Coin.particl)) + // .thenAnswer((_) async => tx2Raw); + // when(cachedClient?.getTransaction( + // txHash: + // "71b56532e9e7321bd8c30d0f8b14530743049d2f3edd5623065c46eee1dda04d", + // coin: Coin.particl)) + // .thenAnswer((_) async => tx3Raw); + // when(cachedClient?.getTransaction( + // txHash: + // "c7e700f7e23a85bbdd9de86d502322a933607ee7ea7e16adaf02e477cdd849b9", + // coin: Coin.particl, + // )).thenAnswer((_) async => tx4Raw); + // + // // recover to fill data + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // // modify addresses to properly mock data to build a tx + // final rcv44 = await secureStore.read( + // key: testWalletId + "_receiveDerivationsP2PKH"); + // await secureStore.write( + // key: testWalletId + "_receiveDerivationsP2PKH", + // value: rcv44?.replaceFirst("1RMSPixoLPuaXuhR2v4HsUMcRjLncKDaw", + // "16FuTPaeRSPVxxCnwQmdyx2PQWxX6HWzhQ")); + // final rcv49 = + // await secureStore.read(key: testWalletId + "_receiveDerivationsP2SH"); + // await secureStore.write( + // key: testWalletId + "_receiveDerivationsP2SH", + // value: rcv49?.replaceFirst("3AV74rKfibWmvX34F99yEvUcG4LLQ9jZZk", + // "36NvZTcMsMowbt78wPzJaHHWaNiyR73Y4g")); + // final rcv84 = await secureStore.read( + // key: testWalletId + "_receiveDerivationsP2WPKH"); + // await secureStore.write( + // key: testWalletId + "_receiveDerivationsP2WPKH", + // value: rcv84?.replaceFirst( + // "bc1qggtj4ka8jsaj44hhd5mpamx7mp34m2d3w7k0m0", + // "bc1q42lja79elem0anu8q8s3h2n687re9jax556pcc")); + // + // nmc?.outputsList = utxoList; + // + // bool didThrow = false; + // try { + // await nmc?.prepareSend( + // address: "nc1q6k4x8ye6865z3rc8zkt8gyu52na7njqt6hsk4v", + // satoshiAmount: 15000); + // } catch (_) { + // didThrow = true; + // } + // + // expect(didThrow, true); + // + // verify(client?.getServerFeatures()).called(1); + // + // /// verify transaction no matching calls + // + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "2087ce09bc316877c9f10971526a2bffa3078d52ea31752639305cdcd8230703", + // // coin: Coin.particl, + // // callOutSideMainIsolate: false)) + // // .called(1); + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "ed32c967a0e86d51669ac21c2bb9bc9c50f0f55fbacdd8db21d0a986fba93bd7", + // // coin: Coin.particl, + // // callOutSideMainIsolate: false)) + // // .called(1); + // // verify(cachedClient?.getTransaction( + // // txHash: + // // "3f0032f89ac44b281b50314cff3874c969c922839dddab77ced54e86a21c3fd4", + // // coin: Coin.particl, + // // callOutSideMainIsolate: false)) + // // .called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 20); + // expect(secureStore.writes, 10); + // expect(secureStore.reads, 10); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + // test("confirmSend no hex", () async { + // bool didThrow = false; + // try { + // await nmc?.confirmSend(txData: {"some": "strange map"}); + // } catch (_) { + // didThrow = true; + // } + // + // expect(didThrow, true); + // + // expect(secureStore.interactions, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + // test("confirmSend hex is not string", () async { + // bool didThrow = false; + // try { + // await nmc?.confirmSend(txData: {"hex": true}); + // } catch (_) { + // didThrow = true; + // } + // + // expect(didThrow, true); + // + // expect(secureStore.interactions, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + // test("confirmSend hex is string but missing other data", () async { + // bool didThrow = false; + // try { + // await nmc?.confirmSend(txData: {"hex": "a string"}); + // } catch (_) { + // didThrow = true; + // } + // + // expect(didThrow, true); + // + // verify(client?.broadcastTransaction( + // rawTx: "a string", requestID: anyNamed("requestID"))) + // .called(1); + // + // expect(secureStore.interactions, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + // test("confirmSend fails due to vSize being greater than fee", () async { + // bool didThrow = false; + // try { + // await nmc + // ?.confirmSend(txData: {"hex": "a string", "fee": 1, "vSize": 10}); + // } catch (_) { + // didThrow = true; + // } + // + // expect(didThrow, true); + // + // verify(client?.broadcastTransaction( + // rawTx: "a string", requestID: anyNamed("requestID"))) + // .called(1); + // + // expect(secureStore.interactions, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + + // test("confirmSend fails when broadcast transactions throws", () async { + // when(client?.broadcastTransaction( + // rawTx: "a string", requestID: anyNamed("requestID"))) + // .thenThrow(Exception("some exception")); + // + // bool didThrow = false; + // try { + // await nmc + // ?.confirmSend(txData: {"hex": "a string", "fee": 10, "vSize": 10}); + // } catch (_) { + // didThrow = true; + // } + // + // expect(didThrow, true); + // + // verify(client?.broadcastTransaction( + // rawTx: "a string", requestID: anyNamed("requestID"))) + // .called(1); + // + // expect(secureStore.interactions, 0); + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // verifyNoMoreInteractions(priceAPI); + // }); + // + // // this test will create a non mocked electrumx client that will try to connect + // // to the provided ipAddress below. This will throw a bunch of errors + // // which what we want here as actually calling electrumx calls here is unwanted. + // // test("listen to NodesChangedEvent", () async { + // // nmc = NamecoinWallet( + // // walletId: testWalletId, + // // walletName: testWalletName, + // // networkType: BasicNetworkType.test, + // // client: client, + // // cachedClient: cachedClient, + // // priceAPI: priceAPI, + // // secureStore: secureStore, + // // ); + // // + // // // set node + // // final wallet = await Hive.openBox(testWalletId); + // // await wallet.put("nodes", { + // // "default": { + // // "id": "some nodeID", + // // "ipAddress": "some address", + // // "port": "9000", + // // "useSSL": true, + // // } + // // }); + // // await wallet.put("activeNodeID_Bitcoin", "default"); + // // + // // final a = nmc.cachedElectrumXClient; + // // + // // // return when refresh is called on node changed trigger + // // nmc.longMutex = true; + // // + // // GlobalEventBus.instance + // // .fire(NodesChangedEvent(NodesChangedEventType.updatedCurrentNode)); + // // + // // // make sure event has processed before continuing + // // await Future.delayed(Duration(seconds: 5)); + // // + // // final b = nmc.cachedElectrumXClient; + // // + // // expect(identical(a, b), false); + // // + // // await nmc.exit(); + // // + // // expect(secureStore.interactions, 0); + // // verifyNoMoreInteractions(client); + // // verifyNoMoreInteractions(cachedClient); + // // verifyNoMoreInteractions(priceAPI); + // // }); + + // test("refresh wallet mutex locked", () async { + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getBatchHistory(args: historyBatchArgs0)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs1)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs2)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs3)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs4)) + // .thenAnswer((_) async => historyBatchResponse); + // when(client?.getBatchHistory(args: historyBatchArgs5)) + // .thenAnswer((_) async => historyBatchResponse); + // + // List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // if (realInvocation.namedArguments.values.first.length == 1) { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // } + // + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // // recover to fill data + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // nmc?.refreshMutex = true; + // + // await nmc?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs0)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs1)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs2)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs3)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs4)).called(1); + // verify(client?.getBatchHistory(args: historyBatchArgs5)).called(1); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // expect(activeScriptHashes.contains(map.values.first.first as String), + // true); + // } + // + // expect(secureStore.interactions, 14); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 7); + // expect(secureStore.deletes, 0); + // + // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(tracker); + // verifyNoMoreInteractions(priceAPI); + // }); + // + // test("refresh wallet normally", () async { + // when(client?.getBlockHeadTip()).thenAnswer((realInvocation) async => + // {"height": 520481, "hex": "some block hex"}); + // when(client?.getServerFeatures()).thenAnswer((_) async => { + // "hosts": {}, + // "pruning": null, + // "server_version": "Unit tests", + // "protocol_min": "1.4", + // "protocol_max": "1.4.2", + // "genesis_hash": GENESIS_HASH_MAINNET, + // "hash_function": "sha256", + // "services": [] + // }); + // when(client?.getHistory(scripthash: anyNamed("scripthash"))) + // .thenAnswer((_) async => []); + // when(client?.estimateFee(blocks: anyNamed("blocks"))) + // .thenAnswer((_) async => Decimal.one); + // + // when(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")) + // .thenAnswer((_) async => {Coin.particl: Tuple2(Decimal.one, 0.3)}); + // + // final List dynamicArgValues = []; + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((realInvocation) async { + // dynamicArgValues.add(realInvocation.namedArguments.values.first); + // return historyBatchResponse; + // }); + // + // await Hive.openBox(testWalletId); + // + // // recover to fill data + // await nmc?.recoverFromMnemonic( + // mnemonic: TEST_MNEMONIC, + // maxUnusedAddressGap: 2, + // maxNumberOfIndexesToCheck: 1000, + // height: 4000); + // + // when(client?.getBatchHistory(args: anyNamed("args"))) + // .thenAnswer((_) async => {}); + // when(client?.getBatchUTXOs(args: anyNamed("args"))) + // .thenAnswer((_) async => emptyHistoryBatchResponse); + // + // await nmc?.refresh(); + // + // verify(client?.getServerFeatures()).called(1); + // verify(client?.getHistory(scripthash: anyNamed("scripthash"))).called(4); + // verify(client?.estimateFee(blocks: anyNamed("blocks"))).called(3); + // verify(client?.getBlockHeadTip()).called(1); + // verify(priceAPI?.getPricesAnd24hChange(baseCurrency: "USD")).called(2); + // + // for (final arg in dynamicArgValues) { + // final map = Map>.from(arg as Map); + // + // verify(client?.getBatchHistory(args: map)).called(1); + // } + // + // expect(secureStore.interactions, 14); + // expect(secureStore.writes, 7); + // expect(secureStore.reads, 7); + // expect(secureStore.deletes, 0); + // + // // verifyNoMoreInteractions(client); + // verifyNoMoreInteractions(cachedClient); + // verifyNoMoreInteractions(priceAPI); + // }); + // + // tearDown(() async { + // await tearDownTestHive(); + // }); + }); } diff --git a/test/services/coins/particl/particl_wallet_test.mocks.dart b/test/services/coins/particl/particl_wallet_test.mocks.dart index 91c3e5bfa..fb0f50d79 100644 --- a/test/services/coins/particl/particl_wallet_test.mocks.dart +++ b/test/services/coins/particl/particl_wallet_test.mocks.dart @@ -1,5 +1,5 @@ // Mocks generated by Mockito 5.3.2 from annotations -// in stackwallet/test/services/coins/namecoin/namecoin_wallet_test.dart. +// in stackwallet/test/services/coins/particl/particl_wallet_test.dart. // Do not manually edit this file. // ignore_for_file: no_leading_underscores_for_library_prefixes diff --git a/test/widget_tests/managed_favorite_test.mocks.dart b/test/widget_tests/managed_favorite_test.mocks.dart index 50f906c3c..117a810cf 100644 --- a/test/widget_tests/managed_favorite_test.mocks.dart +++ b/test/widget_tests/managed_favorite_test.mocks.dart @@ -165,9 +165,9 @@ class _FakeElectrumXNode_11 extends _i1.SmartFake ); } -class _FakeFlutterSecureStorageInterface_12 extends _i1.SmartFake +class _FakeSecureStorageInterface_12 extends _i1.SmartFake implements _i12.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_12( + _FakeSecureStorageInterface_12( Object parent, Invocation parentInvocation, ) : super( @@ -1400,7 +1400,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i12.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_12( + returnValue: _FakeSecureStorageInterface_12( this, Invocation.getter(#secureStorageInterface), ), diff --git a/test/widget_tests/node_card_test.mocks.dart b/test/widget_tests/node_card_test.mocks.dart index 2bb32b58d..6b85a4f5d 100644 --- a/test/widget_tests/node_card_test.mocks.dart +++ b/test/widget_tests/node_card_test.mocks.dart @@ -24,9 +24,9 @@ import 'package:stackwallet/utilities/flutter_secure_storage_interface.dart' // ignore_for_file: camel_case_types // ignore_for_file: subtype_of_sealed_class -class _FakeFlutterSecureStorageInterface_0 extends _i1.SmartFake +class _FakeSecureStorageInterface_0 extends _i1.SmartFake implements _i2.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_0( + _FakeSecureStorageInterface_0( Object parent, Invocation parentInvocation, ) : super( @@ -46,7 +46,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i2.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_0( + returnValue: _FakeSecureStorageInterface_0( this, Invocation.getter(#secureStorageInterface), ), diff --git a/test/widget_tests/node_options_sheet_test.mocks.dart b/test/widget_tests/node_options_sheet_test.mocks.dart index c9e4e2bb8..7e3e3a92d 100644 --- a/test/widget_tests/node_options_sheet_test.mocks.dart +++ b/test/widget_tests/node_options_sheet_test.mocks.dart @@ -76,9 +76,9 @@ class _FakeManager_3 extends _i1.SmartFake implements _i6.Manager { ); } -class _FakeFlutterSecureStorageInterface_4 extends _i1.SmartFake +class _FakeSecureStorageInterface_4 extends _i1.SmartFake implements _i7.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_4( + _FakeSecureStorageInterface_4( Object parent, Invocation parentInvocation, ) : super( @@ -446,6 +446,19 @@ class MockPrefs extends _i1.Mock implements _i11.Prefs { returnValueForMissingStub: null, ); @override + int get familiarity => (super.noSuchMethod( + Invocation.getter(#familiarity), + returnValue: 0, + ) as int); + @override + set familiarity(int? familiarity) => super.noSuchMethod( + Invocation.setter( + #familiarity, + familiarity, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, @@ -623,10 +636,9 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { } @override - _i7.SecureStorageInterface get secureStorageInterface => - (super.noSuchMethod( + _i7.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_4( + returnValue: _FakeSecureStorageInterface_4( this, Invocation.getter(#secureStorageInterface), ), diff --git a/test/widget_tests/transaction_card_test.mocks.dart b/test/widget_tests/transaction_card_test.mocks.dart index f258a402b..2aa2e1dcb 100644 --- a/test/widget_tests/transaction_card_test.mocks.dart +++ b/test/widget_tests/transaction_card_test.mocks.dart @@ -2213,6 +2213,19 @@ class MockPrefs extends _i1.Mock implements _i17.Prefs { returnValueForMissingStub: null, ); @override + int get familiarity => (super.noSuchMethod( + Invocation.getter(#familiarity), + returnValue: 0, + ) as int); + @override + set familiarity(int? familiarity) => super.noSuchMethod( + Invocation.setter( + #familiarity, + familiarity, + ), + returnValueForMissingStub: null, + ); + @override bool get showTestNetCoins => (super.noSuchMethod( Invocation.getter(#showTestNetCoins), returnValue: false, diff --git a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart index a249c997d..fe5e0e8a2 100644 --- a/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart +++ b/test/widget_tests/wallet_info_row/sub_widgets/wallet_info_row_balance_future_test.mocks.dart @@ -164,9 +164,9 @@ class _FakeElectrumXNode_11 extends _i1.SmartFake ); } -class _FakeFlutterSecureStorageInterface_12 extends _i1.SmartFake +class _FakeSecureStorageInterface_12 extends _i1.SmartFake implements _i12.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_12( + _FakeSecureStorageInterface_12( Object parent, Invocation parentInvocation, ) : super( @@ -1337,7 +1337,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i12.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_12( + returnValue: _FakeSecureStorageInterface_12( this, Invocation.getter(#secureStorageInterface), ), diff --git a/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart b/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart index 820fbd96d..7f370eb9a 100644 --- a/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart +++ b/test/widget_tests/wallet_info_row/wallet_info_row_test.mocks.dart @@ -164,9 +164,9 @@ class _FakeElectrumXNode_11 extends _i1.SmartFake ); } -class _FakeFlutterSecureStorageInterface_12 extends _i1.SmartFake +class _FakeSecureStorageInterface_12 extends _i1.SmartFake implements _i12.SecureStorageInterface { - _FakeFlutterSecureStorageInterface_12( + _FakeSecureStorageInterface_12( Object parent, Invocation parentInvocation, ) : super( @@ -1337,7 +1337,7 @@ class MockNodeService extends _i1.Mock implements _i3.NodeService { @override _i12.SecureStorageInterface get secureStorageInterface => (super.noSuchMethod( Invocation.getter(#secureStorageInterface), - returnValue: _FakeFlutterSecureStorageInterface_12( + returnValue: _FakeSecureStorageInterface_12( this, Invocation.getter(#secureStorageInterface), ),