-
Notifications
You must be signed in to change notification settings - Fork 123
/
address_test.dart
52 lines (51 loc) · 1.78 KB
/
address_test.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import 'package:test/test.dart';
import '../lib/src/address.dart' show Address;
import '../lib/src/models/networks.dart' as NETWORKS;
main() {
group('Address', () {
group('validateAddress', () {
test('base58 addresses and valid network', () {
expect(
Address.validateAddress(
'mhv6wtF2xzEqMNd3TbXx9TjLLo6mp2MUuT', NETWORKS.testnet),
true);
expect(Address.validateAddress('1K6kARGhcX9nJpJeirgcYdGAgUsXD59nHZ'),
true);
});
test('base58 addresses and invalid network', () {
expect(
Address.validateAddress(
'mhv6wtF2xzEqMNd3TbXx9TjLLo6mp2MUuT', NETWORKS.bitcoin),
false);
expect(
Address.validateAddress(
'1K6kARGhcX9nJpJeirgcYdGAgUsXD59nHZ', NETWORKS.testnet),
false);
});
test('bech32 addresses and valid network', () {
expect(
Address.validateAddress(
'tb1qgmp0h7lvexdxx9y05pmdukx09xcteu9sx2h4ya', NETWORKS.testnet),
true);
expect(
Address.validateAddress(
'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4'),
true);
// expect(Address.validateAddress('tb1qqqqqp399et2xygdj5xreqhjjvcmzhxw4aywxecjdzew6hylgvsesrxh6hy'), true); TODO
});
test('bech32 addresses and invalid network', () {
expect(
Address.validateAddress(
'tb1qgmp0h7lvexdxx9y05pmdukx09xcteu9sx2h4ya'),
false);
expect(
Address.validateAddress(
'bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4', NETWORKS.testnet),
false);
});
test('invalid addresses', () {
expect(Address.validateAddress('3333333casca'), false);
});
});
});
}