Skip to content

Commit 5d8416b

Browse files
authored
Merge pull request #8 from androzd/master
fix M addresses, add tests
2 parents f8897ac + a8061b2 commit 5d8416b

File tree

6 files changed

+30
-19
lines changed

6 files changed

+30
-19
lines changed

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,10 @@
1515
"psr-4": {
1616
"Merkeleon\\PhpCryptocurrencyAddressValidation\\": "src"
1717
}
18+
},
19+
"autoload-dev": {
20+
"psr-4": {
21+
"Tests\\": "tests/"
22+
}
1823
}
1924
}

phpunit.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
stopOnFailure="false"
1111
syntaxCheck="false">
1212
<testsuites>
13-
<testsuite name="Nacho Test Suite">
14-
<directory suffix=".php">./tests/</directory>
13+
<testsuite name="Application Test Suite">
14+
<directory>./tests/</directory>
1515
</testsuite>
1616
</testsuites>
1717
</phpunit>

src/Validation/LTC.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ class LTC extends Validation
1313

1414
protected $base58PrefixToHexVersion = [
1515
'L' => '30',
16-
'M' => '31',
16+
'M' => '32',
1717
'3' => '05'
1818
];
1919

tests/BTCTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?php
22

3+
namespace Tests;
4+
5+
use Merkeleon\PhpCryptocurrencyAddressValidation\Validation;
36
use Merkeleon\PhpCryptocurrencyAddressValidation\Validation\BTC;
7+
use PHPUnit_Framework_TestCase;
48

59
class BTCTest extends PHPUnit_Framework_TestCase
610
{
@@ -14,8 +18,8 @@ public function testValidator()
1418
];
1519

1620
foreach ($testData as $row) {
17-
$validator = new BTC($row[0]);
18-
$this->assertEquals($row[1], $validator->validate());
21+
$validator = Validation::make('BTC');
22+
$this->assertEquals($row[1], $validator->validate($row[0]));
1923
}
2024

2125
}

tests/DASHTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<?php
22

3+
namespace Tests;
4+
5+
use Merkeleon\PhpCryptocurrencyAddressValidation\Validation;
36
use Merkeleon\PhpCryptocurrencyAddressValidation\Validation\DASH;
7+
use PHPUnit_Framework_TestCase;
48

59
class DASHTest extends PHPUnit_Framework_TestCase
610
{
@@ -20,8 +24,8 @@ public function testValidator()
2024
];
2125

2226
foreach ($testData as $row) {
23-
$validator = new DASH($row[0]);
24-
$this->assertEquals($row[1], $validator->validate());
27+
$validator = Validation::make('DASH');
28+
$this->assertEquals($row[1], $validator->validate($row[0]));
2529
}
2630

2731
}

tests/LTCTest.php

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,33 @@
11
<?php
22

3+
namespace Tests;
4+
5+
use Merkeleon\PhpCryptocurrencyAddressValidation\Validation;
36
use Merkeleon\PhpCryptocurrencyAddressValidation\Validation\LTC;
7+
use PHPUnit_Framework_TestCase;
48

59
class LTCTest extends PHPUnit_Framework_TestCase
610
{
711
public function testValidator()
812
{
9-
/*
10-
* There are many addresses in Litecoin blockchain which starts with 3.
11-
* However, addresses starting with 3 are deprecated.
12-
* Litecoin multisig addess should start with M.
13-
*/
14-
1513
$testData = [
1614
['1QLbGuc3WGKKKpLs4pBp9H6jiQ2MgPkXRp', false],
17-
['3CDJNfdWX8m2NwuGUV3nhXHXEeLygMXoAj', false],
15+
['3CDJNfdWX8m2NwuGUV3nhXHXEeLygMXoAj', true],
1816
['LbTjMGN7gELw4KbeyQf6cTCq859hD18guE', true],
19-
// @todo: add test case with M address
17+
['MJRSgZ3UUFcTBTBAaN38XAXvZLwRe8WVw7', true],
2018
];
2119

2220
foreach ($testData as $row) {
23-
$validator = new LTC($row[0]);
24-
$this->assertEquals($row[1], $validator->validate());
21+
$validator = Validation::make('LTC');
22+
$this->assertEquals($row[1], $validator->validate($row[0]));
2523
}
2624

2725
}
2826

2927
public function testLitecoinDeprecatedMultisigAddress()
3028
{
31-
$validator = new LTC('3CDJNfdWX8m2NwuGUV3nhXHXEeLygMXoAj');
29+
$validator = Validation::make('LTC');
3230
$validator->setDeprecatedAllowed(true);
33-
$this->assertEquals(true, $validator->validate());
31+
$this->assertEquals(true, $validator->validate('3CDJNfdWX8m2NwuGUV3nhXHXEeLygMXoAj'));
3432
}
3533
}

0 commit comments

Comments
 (0)