mirror of
https://github.com/cypherstack/stack_wallet.git
synced 2024-11-17 09:47:37 +00:00
add more address validation to tests
This commit is contained in:
parent
02f5162b53
commit
f61b3857e6
2 changed files with 43 additions and 61 deletions
|
@ -60,19 +60,11 @@ void main() async {
|
||||||
dirPath: '');
|
dirPath: '');
|
||||||
late WalletCredentials credentials;
|
late WalletCredentials credentials;
|
||||||
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
|
||||||
Directory appDir = (await getApplicationDocumentsDirectory());
|
|
||||||
if (Platform.isIOS) {
|
|
||||||
appDir = (await getLibraryDirectory());
|
|
||||||
}
|
|
||||||
|
|
||||||
monero.onStartup();
|
monero.onStartup();
|
||||||
|
|
||||||
bool hiveAdaptersRegistered = false;
|
bool hiveAdaptersRegistered = false;
|
||||||
|
|
||||||
bool hiveAdaptersRegistered = false;
|
group("Mainnet tests", () {
|
||||||
|
|
||||||
group("Mnemonic recovery", () {
|
|
||||||
setUp(() async {
|
setUp(() async {
|
||||||
await setUpTestHive();
|
await setUpTestHive();
|
||||||
if (!hiveAdaptersRegistered) {
|
if (!hiveAdaptersRegistered) {
|
||||||
|
@ -87,7 +79,8 @@ void main() async {
|
||||||
await wallets.put('currentWalletName', name);
|
await wallets.put('currentWalletName', name);
|
||||||
|
|
||||||
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
|
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
|
||||||
walletService = monero.createMoneroWalletService(_walletInfoSource);
|
walletService = monero
|
||||||
|
.createMoneroWalletService(_walletInfoSource as Box<WalletInfo>);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -129,26 +122,6 @@ void main() async {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Test address validation", () async { // TODO I'd like to refactor/separate this out so I can test addresses alone, without having to first create a wallet.
|
|
||||||
final wallet = await _walletCreationService.restoreFromSeed(credentials);
|
|
||||||
walletBase = wallet as MoneroWalletBase;
|
|
||||||
|
|
||||||
expect(
|
|
||||||
await walletBase!.validateAddress(''), false);
|
|
||||||
expect(
|
|
||||||
await walletBase!.validateAddress('4AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'), true);
|
|
||||||
expect(
|
|
||||||
await walletBase!.validateAddress('4asdfkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gpjkl'), false);
|
|
||||||
expect(
|
|
||||||
await walletBase!.validateAddress('8AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'), false);
|
|
||||||
expect(
|
|
||||||
await walletBase!.validateAddress('84kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'), true);
|
|
||||||
expect(
|
|
||||||
await walletBase!.validateAddress('8asdfuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenjkl'), false);
|
|
||||||
expect(
|
|
||||||
await walletBase!.validateAddress('44kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'), false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Test mainnet address generation from seed", () async {
|
test("Test mainnet address generation from seed", () async {
|
||||||
final wallet = await
|
final wallet = await
|
||||||
// _walletCreationService.create(credentials);
|
// _walletCreationService.create(credentials);
|
||||||
|
@ -161,6 +134,9 @@ void main() async {
|
||||||
walletBase = wallet as MoneroWalletBase;
|
walletBase = wallet as MoneroWalletBase;
|
||||||
//print("${walletBase?.seed}");
|
//print("${walletBase?.seed}");
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await walletBase!.validateAddress(walletInfo.address ?? ''), true);
|
||||||
|
|
||||||
// print(walletBase);
|
// print(walletBase);
|
||||||
// loggerPrint(walletBase.toString());
|
// loggerPrint(walletBase.toString());
|
||||||
// loggerPrint("name: ${walletBase!.name} seed: ${walletBase!.seed} id: "
|
// loggerPrint("name: ${walletBase!.name} seed: ${walletBase!.seed} id: "
|
||||||
|
@ -180,6 +156,21 @@ void main() async {
|
||||||
await walletBase!.getTransactionAddress(1, 1), mainnetTestData[1][1]);
|
await walletBase!.getTransactionAddress(1, 1), mainnetTestData[1][1]);
|
||||||
expect(
|
expect(
|
||||||
await walletBase!.getTransactionAddress(1, 2), mainnetTestData[1][2]);
|
await walletBase!.getTransactionAddress(1, 2), mainnetTestData[1][2]);
|
||||||
|
|
||||||
|
expect(
|
||||||
|
await walletBase!.validateAddress(''), false);
|
||||||
|
expect(
|
||||||
|
await walletBase!.validateAddress('4AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'), true);
|
||||||
|
expect(
|
||||||
|
await walletBase!.validateAddress('4asdfkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gpjkl'), false);
|
||||||
|
expect(
|
||||||
|
await walletBase!.validateAddress('8AeRgkWZsMJhAWKMeCZ3h4ZSPnAcW5VBtRFyLd6gBEf6GgJU2FHXDA6i1DnQTd6h8R3VU5AkbGcWSNhtSwNNPgaD48gp4nn'), false);
|
||||||
|
expect(
|
||||||
|
await walletBase!.validateAddress('84kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'), true);
|
||||||
|
expect(
|
||||||
|
await walletBase!.validateAddress('8asdfuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenjkl'), false);
|
||||||
|
expect(
|
||||||
|
await walletBase!.validateAddress('44kYPuZ1eaVKGQhf26QPNWbSLQG16BywXdLYYShVrPNMLAUAWce5vcpRc78FxwRphrG6Cda7faCKdUMr8fUCH3peHPenvHy'), false);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -55,12 +55,6 @@ void main() async {
|
||||||
dirPath: '');
|
dirPath: '');
|
||||||
late WalletCredentials credentials;
|
late WalletCredentials credentials;
|
||||||
|
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
|
||||||
Directory appDir = (await getApplicationDocumentsDirectory());
|
|
||||||
if (Platform.isIOS) {
|
|
||||||
appDir = (await getLibraryDirectory());
|
|
||||||
}
|
|
||||||
|
|
||||||
wownero.onStartup();
|
wownero.onStartup();
|
||||||
|
|
||||||
bool hiveAdaptersRegistered = false;
|
bool hiveAdaptersRegistered = false;
|
||||||
|
@ -80,7 +74,8 @@ void main() async {
|
||||||
await wallets.put('currentWalletName', name);
|
await wallets.put('currentWalletName', name);
|
||||||
|
|
||||||
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
|
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
|
||||||
walletService = wownero.createWowneroWalletService(_walletInfoSource);
|
walletService = wownero
|
||||||
|
.createWowneroWalletService(_walletInfoSource as Box<WalletInfo>);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hasThrown = false;
|
bool hasThrown = false;
|
||||||
|
@ -120,18 +115,6 @@ void main() async {
|
||||||
expect(hasThrown, false);
|
expect(hasThrown, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Test address validation", () async { // TODO I'd like to refactor/separate this out so I can test addresses alone, without having to first create a wallet.
|
|
||||||
final wallet = await _walletCreationService.restoreFromSeed(credentials);
|
|
||||||
walletBase = wallet as WowneroWalletBase;
|
|
||||||
|
|
||||||
expect(
|
|
||||||
await walletBase!.validateAddress(''), false);
|
|
||||||
expect(
|
|
||||||
await walletBase!.validateAddress('Wo3jmHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmsEi'), true);
|
|
||||||
expect(
|
|
||||||
await walletBase!.validateAddress('WasdfHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmjkl'), false);
|
|
||||||
});
|
|
||||||
|
|
||||||
test("Wownero 14 word seed address generation", () async {
|
test("Wownero 14 word seed address generation", () async {
|
||||||
final wallet = await _walletCreationService.create(credentials);
|
final wallet = await _walletCreationService.create(credentials);
|
||||||
// TODO validate mnemonic
|
// TODO validate mnemonic
|
||||||
|
@ -143,13 +126,21 @@ void main() async {
|
||||||
walletBase?.close();
|
walletBase?.close();
|
||||||
walletBase = wallet as WowneroWalletBase;
|
walletBase = wallet as WowneroWalletBase;
|
||||||
|
|
||||||
// TODO validate
|
expect(
|
||||||
//expect(walletInfo.address, mainnetTestData14[0][0]);
|
await walletBase!.validateAddress(wallet.walletAddresses.address ?? ''), true);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
hasThrown = true;
|
hasThrown = true;
|
||||||
}
|
}
|
||||||
expect(hasThrown, false);
|
expect(hasThrown, false);
|
||||||
|
|
||||||
|
// Address validation
|
||||||
|
expect(
|
||||||
|
await walletBase!.validateAddress(''), false);
|
||||||
|
expect(
|
||||||
|
await walletBase!.validateAddress('Wo3jmHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmsEi'), true);
|
||||||
|
expect(
|
||||||
|
await walletBase!.validateAddress('WasdfHvTMLwE6h29fpgcb8PbJSpaKuqM7XTXVfiiu8bLCZsJvrQCbQSJR48Vo3BWNQKsMsXZ4VixndXTH25QtorC27NCjmjkl'), false);
|
||||||
|
|
||||||
walletBase?.close();
|
walletBase?.close();
|
||||||
walletBase = wallet as WowneroWalletBase;
|
walletBase = wallet as WowneroWalletBase;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue