mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-16 17:27:39 +00:00
add generation tests and update flutter_libmonero ref
change seedWords to SeedWordsLength to match rest of codebase
This commit is contained in:
parent
77aa3bc8e4
commit
7c3d40782c
3 changed files with 147 additions and 47 deletions
|
@ -1 +1 @@
|
|||
Subproject commit e95c19662ccf17d83109ab7b651cfbc0521deb47
|
||||
Subproject commit afdee4b880202f39a2375afc320f0642e98a1827
|
|
@ -647,7 +647,7 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
}
|
||||
|
||||
//TODO: take in the default language when creating wallet.
|
||||
Future<void> _generateNewWallet() async {
|
||||
Future<void> _generateNewWallet({int seedWordsLength = 14}) async {
|
||||
Logging.instance
|
||||
.log("IS_INTEGRATION_TEST: $integrationTestFlag", level: LogLevel.Info);
|
||||
// TODO: ping wownero server and make sure the genesis hash matches
|
||||
|
@ -687,6 +687,7 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
credentials = wownero.createWowneroNewWalletCredentials(
|
||||
name: name,
|
||||
language: "English",
|
||||
seedWordsLength: seedWordsLength
|
||||
);
|
||||
|
||||
walletInfo = WalletInfo.external(
|
||||
|
@ -713,12 +714,12 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
final wallet = await _walletCreationService?.create(credentials);
|
||||
|
||||
// subtract a couple days to ensure we have a buffer for SWB
|
||||
// 14 words
|
||||
//final bufferedCreateHeight = getSeedHeightSync(wallet?.seed.trim() as String);
|
||||
|
||||
// 25 words
|
||||
if (seedWordsLength == 14) {
|
||||
final bufferedCreateHeight = getSeedHeightSync(wallet?.seed.trim() as String);
|
||||
} else {
|
||||
final bufferedCreateHeight = 0;
|
||||
// TODO use an alternative to wow_seed's get_seed_height
|
||||
}
|
||||
|
||||
await DB.instance.put<dynamic>(
|
||||
boxName: walletId, key: "restoreHeight", value: bufferedCreateHeight);
|
||||
|
@ -726,6 +727,7 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
|
||||
await _secureStore.write(
|
||||
key: '${_walletId}_mnemonic', value: wallet?.seed.trim());
|
||||
|
||||
walletInfo.address = wallet?.walletAddresses.address;
|
||||
await DB.instance
|
||||
.add<WalletInfo>(boxName: WalletInfo.boxName, value: walletInfo);
|
||||
|
@ -782,7 +784,7 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
|
||||
@override
|
||||
// TODO: implement initializeWallet
|
||||
Future<bool> initializeNew() async {
|
||||
Future<bool> initializeNew({int seedWordsLength = 14}) async {
|
||||
await _prefs.init();
|
||||
// TODO: ping actual wownero network
|
||||
// try {
|
||||
|
@ -800,7 +802,7 @@ class WowneroWallet extends CoinServiceAPI {
|
|||
prefs = await SharedPreferences.getInstance();
|
||||
keysStorage = KeyService(storage!);
|
||||
|
||||
await _generateNewWallet();
|
||||
await _generateNewWallet(seedWordsLength: seedWordsLength);
|
||||
// var password;
|
||||
// try {
|
||||
// password =
|
||||
|
|
|
@ -46,7 +46,7 @@ dynamic _walletInfoSource;
|
|||
|
||||
String path = '';
|
||||
|
||||
String name = 'namee${Random().nextInt(10000000)}';
|
||||
String name = '';
|
||||
int nettype = 0;
|
||||
WalletType type = WalletType.wownero;
|
||||
|
||||
|
@ -83,10 +83,75 @@ void main() async {
|
|||
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
|
||||
walletService = wownero.createWowneroWalletService(_walletInfoSource);
|
||||
|
||||
group("Wownero 14 word tests", () {
|
||||
group("Wownero 14 word seed generation", () {
|
||||
setUp(() async {
|
||||
bool hasThrown = false;
|
||||
try {
|
||||
name = 'namee${Random().nextInt(10000000)}';
|
||||
final dirPath = await pathForWalletDir(name: name, type: type);
|
||||
path = await pathForWallet(name: name, type: type);
|
||||
credentials = wownero.createWowneroNewWalletCredentials(
|
||||
name: name,
|
||||
language: "English",
|
||||
seedWordsLength: 14); // TODO catch failure
|
||||
|
||||
walletInfo = WalletInfo.external(
|
||||
id: WalletBase.idFor(name, type),
|
||||
name: name,
|
||||
type: type,
|
||||
isRecovery: false,
|
||||
restoreHeight: credentials.height ?? 0,
|
||||
date: DateTime.now(),
|
||||
path: path,
|
||||
address: "",
|
||||
dirPath: dirPath);
|
||||
credentials.walletInfo = walletInfo;
|
||||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: storage,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
_walletCreationService.changeWalletType();
|
||||
} catch (e, s) {
|
||||
print(e);
|
||||
print(s);
|
||||
hasThrown = true;
|
||||
}
|
||||
expect(hasThrown, false);
|
||||
});
|
||||
|
||||
test("Wownero 14 word seed address generation", () async {
|
||||
final wallet = await _walletCreationService.create(credentials);
|
||||
// TODO validate mnemonic
|
||||
walletInfo.address = wallet.walletAddresses.address;
|
||||
|
||||
bool hasThrown = false;
|
||||
try {
|
||||
await _walletInfoSource.add(walletInfo);
|
||||
walletBase?.close();
|
||||
walletBase = wallet as WowneroWalletBase;
|
||||
|
||||
// TODO validate
|
||||
//expect(walletInfo.address, mainnetTestData14[0][0]);
|
||||
} catch (_) {
|
||||
hasThrown = true;
|
||||
}
|
||||
expect(hasThrown, false);
|
||||
|
||||
walletBase?.close();
|
||||
walletBase = wallet as WowneroWalletBase;
|
||||
});
|
||||
|
||||
// TODO delete left over wallet file with name: name
|
||||
});
|
||||
|
||||
group("Wownero 14 word seed restoration", () {
|
||||
setUp(() async {
|
||||
bool hasThrown = false;
|
||||
try {
|
||||
name = 'namee${Random().nextInt(10000000)}';
|
||||
final dirPath = await pathForWalletDir(name: name, type: type);
|
||||
path = await pathForWallet(name: name, type: type);
|
||||
credentials = wownero.createWowneroRestoreWalletFromSeedCredentials(
|
||||
|
@ -121,7 +186,7 @@ void main() async {
|
|||
expect(hasThrown, false);
|
||||
});
|
||||
|
||||
test("Test mainnet address generation from 14 word seed", () async {
|
||||
test("Wownero 14 word seed address generation", () async {
|
||||
final wallet = await _walletCreationService.restoreFromSeed(credentials);
|
||||
walletInfo.address = wallet.walletAddresses.address;
|
||||
|
||||
|
@ -156,7 +221,71 @@ void main() async {
|
|||
// TODO delete left over wallet file with name: name
|
||||
});
|
||||
|
||||
group("Wownero 25 word tests", () {
|
||||
group("Wownero 25 word seed generation", () {
|
||||
setUp(() async {
|
||||
bool hasThrown = false;
|
||||
try {
|
||||
name = 'namee${Random().nextInt(10000000)}';
|
||||
final dirPath = await pathForWalletDir(name: name, type: type);
|
||||
path = await pathForWallet(name: name, type: type);
|
||||
credentials = wownero.createWowneroNewWalletCredentials(
|
||||
name: name,
|
||||
language: "English",
|
||||
seedWordsLength: 25); // TODO catch failure
|
||||
|
||||
walletInfo = WalletInfo.external(
|
||||
id: WalletBase.idFor(name, type),
|
||||
name: name,
|
||||
type: type,
|
||||
isRecovery: false,
|
||||
restoreHeight: credentials.height ?? 0,
|
||||
date: DateTime.now(),
|
||||
path: path,
|
||||
address: "",
|
||||
dirPath: dirPath);
|
||||
credentials.walletInfo = walletInfo;
|
||||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: storage,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
_walletCreationService.changeWalletType();
|
||||
} catch (e, s) {
|
||||
print(e);
|
||||
print(s);
|
||||
hasThrown = true;
|
||||
}
|
||||
expect(hasThrown, false);
|
||||
});
|
||||
|
||||
test("Wownero 25 word seed address generation", () async {
|
||||
final wallet = await _walletCreationService.create(credentials);
|
||||
// TODO validate mnemonic
|
||||
walletInfo.address = wallet.walletAddresses.address;
|
||||
|
||||
bool hasThrown = false;
|
||||
try {
|
||||
await _walletInfoSource.add(walletInfo);
|
||||
walletBase?.close();
|
||||
walletBase = wallet as WowneroWalletBase;
|
||||
|
||||
// TODO validate
|
||||
//expect(walletInfo.address, mainnetTestData14[0][0]);
|
||||
} catch (_) {
|
||||
hasThrown = true;
|
||||
}
|
||||
expect(hasThrown, false);
|
||||
|
||||
walletBase?.close();
|
||||
walletBase = wallet as WowneroWalletBase;
|
||||
});
|
||||
|
||||
// TODO delete left over wallet file with name: name
|
||||
});
|
||||
|
||||
group("Wownero 25 word seed restoration", () {
|
||||
setUp(() async {
|
||||
bool hasThrown = false;
|
||||
try {
|
||||
|
@ -195,42 +324,11 @@ void main() async {
|
|||
expect(hasThrown, false);
|
||||
});
|
||||
|
||||
test("Test mainnet address generation from 25 word seed", () async {
|
||||
bool hasThrown = false;
|
||||
try {
|
||||
final dirPath = await pathForWalletDir(name: name, type: type);
|
||||
path = await pathForWallet(name: name, type: type);
|
||||
|
||||
walletInfo = WalletInfo.external(
|
||||
id: WalletBase.idFor(name, type),
|
||||
name: name,
|
||||
type: type,
|
||||
isRecovery: false,
|
||||
restoreHeight: credentials.height ?? 0,
|
||||
date: DateTime.now(),
|
||||
path: path,
|
||||
address: "",
|
||||
dirPath: dirPath);
|
||||
credentials.walletInfo = walletInfo;
|
||||
|
||||
_walletCreationService = WalletCreationService(
|
||||
secureStorage: storage,
|
||||
sharedPreferences: prefs,
|
||||
walletService: walletService,
|
||||
keyService: keysStorage,
|
||||
);
|
||||
_walletCreationService.changeWalletType();
|
||||
} catch (e, s) {
|
||||
print(e);
|
||||
print(s);
|
||||
hasThrown = true;
|
||||
}
|
||||
expect(hasThrown, false);
|
||||
|
||||
test("Wownero 25 word seed address generation", () async {
|
||||
final wallet = await _walletCreationService.restoreFromSeed(credentials);
|
||||
walletInfo.address = wallet.walletAddresses.address;
|
||||
|
||||
hasThrown = false;
|
||||
bool hasThrown = false;
|
||||
try {
|
||||
await _walletInfoSource.add(walletInfo);
|
||||
walletBase?.close();
|
||||
|
|
Loading…
Reference in a new issue