add address validation tests

This commit is contained in:
sneurlax 2022-11-10 15:49:19 -06:00
parent 15dc2512db
commit 24bdc100fb
3 changed files with 34 additions and 2 deletions

@ -1 +1 @@
Subproject commit 8a8c88cdade6fe18529deea410f862b125167a3b
Subproject commit 2da77438527732dfaa5398aa391eab5253dabe19

View file

@ -92,7 +92,7 @@ void main() async {
_walletInfoSource = await Hive.openBox<WalletInfo>(WalletInfo.boxName);
walletService = monero.createMoneroWalletService(_walletInfoSource);
group("Mainnet tests", () {
group("Mnemonic recovery", () {
setUp(() async {
try {
// if (name?.isEmpty ?? true) {
@ -133,6 +133,26 @@ 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 {
final wallet = await
// _walletCreationService.create(credentials);

View file

@ -122,6 +122,18 @@ void main() async {
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 {
final wallet = await _walletCreationService.create(credentials);
// TODO validate mnemonic