Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PHPCS + PhpStan + badges #2

Open
wants to merge 34 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
7528840
Update composer.json
alexdnepro Jan 11, 2023
246bd7f
Add PHPCS
BrianHenryIE May 17, 2023
84718d0
Autofix `phpcbf`
BrianHenryIE May 17, 2023
67cf3bc
`const` -> `public const`
BrianHenryIE May 17, 2023
f8a40a4
phpcs line-length
BrianHenryIE May 17, 2023
d011f32
Add PhpStan
BrianHenryIE May 17, 2023
3d5b1d5
phsptan: return type
BrianHenryIE May 17, 2023
f699624
Fix `Unsafe usage of new static()`
BrianHenryIE May 17, 2023
6a84bbc
property is not covariant with PHPDoc
BrianHenryIE May 17, 2023
63194e3
PhpStan level 6 fixes
BrianHenryIE May 17, 2023
be5e4f0
PhpStan level 7 fixes
BrianHenryIE May 17, 2023
1b1e9fb
fix: phpcs line length
BrianHenryIE May 17, 2023
679d473
Add PHP code coverage exclusions to linting
BrianHenryIE May 17, 2023
b64cd0d
Add README header, coverage badge, coverage workflow
BrianHenryIE May 17, 2023
5550724
Move packages to `require-dev`
BrianHenryIE Nov 15, 2023
c1945ea
Add PHPCS
BrianHenryIE May 17, 2023
232ddb8
Add PhpStan
BrianHenryIE May 17, 2023
c15714d
Add PHP code coverage exclusions to linting
BrianHenryIE May 17, 2023
bea7c6e
Add README header, coverage badge, coverage workflow
BrianHenryIE May 17, 2023
31b610d
Move packages to `require-dev`
BrianHenryIE Nov 15, 2023
4ad0b26
`phpcbf` autofix
BrianHenryIE Nov 15, 2023
1abbadb
Merge branch 'master' into updates
BrianHenryIE Nov 15, 2023
daa998a
Fix phpcs "Visibility must be declared on all constants"
BrianHenryIE Nov 15, 2023
bed661a
Fix phpcs "Line exceeds 120 characters"
BrianHenryIE Nov 15, 2023
0726eca
fix phpcs
BrianHenryIE Nov 15, 2023
f8c2d88
Fix phpstan level 2
BrianHenryIE Nov 15, 2023
aa24423
Fix phpstan level 3
BrianHenryIE Nov 15, 2023
2b5c50e
Fix phpstan level 6
BrianHenryIE Nov 15, 2023
fc88c5e
Fix phpstan level 7
BrianHenryIE Nov 15, 2023
ce73f3c
Update phpstan.neon
BrianHenryIE Nov 15, 2023
4df90b3
Add test-coverage scripts
BrianHenryIE Nov 15, 2023
15287ed
Update coverage.svg
BrianHenryIE Nov 15, 2023
fc6f927
Fix "PHP 7.1" (was .4) in README
BrianHenryIE Nov 15, 2023
f60a820
Merge remote-tracking branch 'upstream/master'
BrianHenryIE Nov 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix phpcs "Line exceeds 120 characters"
BrianHenryIE committed Nov 15, 2023
commit bed661abbfd36dfd5da75258ccd11935d6705bf1
19 changes: 16 additions & 3 deletions tests/BitcoinTest.php
Original file line number Diff line number Diff line change
@@ -52,7 +52,12 @@ public function testDecodeP2WSH(): void

public function testDecodeP2TR()
{
$this->assertInstanceOf(P2tr::class, NetworkFactory::bitcoin()->decodeAddress('bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr'));
$this->assertInstanceOf(
P2tr::class,
NetworkFactory::bitcoin()->decodeAddress(
'bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr'
)
);
}

public function testValidateAddress()
@@ -72,11 +77,19 @@ public function testValidateAddressP2SH()

public function testValidateAddressP2WSH()
{
$this->assertTrue(NetworkFactory::bitcoin()->validateAddress('bc1q9qs9xv7mjghkd69fgx62xttxmeww5q7eekjxu0nxtzf4yu4ekf8s4plngs'));
$this->assertTrue(
NetworkFactory::bitcoin()->validateAddress(
'bc1q9qs9xv7mjghkd69fgx62xttxmeww5q7eekjxu0nxtzf4yu4ekf8s4plngs'
)
);
}

public function testValidateAddressP2TR()
{
$this->assertTrue(NetworkFactory::bitcoin()->validateAddress('bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr'));
$this->assertTrue(
NetworkFactory::bitcoin()->validateAddress(
'bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr'
)
);
}
}
20 changes: 16 additions & 4 deletions tests/OutputFactoryTest.php
Original file line number Diff line number Diff line change
@@ -28,7 +28,10 @@ public function testFromHexP2PK(): void
{
$output = OutputFactory::fromHex('210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798ac');
$this->assertInstanceOf(P2pk::class, $output);
$this->assertEquals($output->getPubKey(), hex2bin('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798'));
$this->assertEquals(
$output->getPubKey(),
hex2bin('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798')
);
$this->assertEquals($output->type(), 'p2pk');
}

@@ -50,7 +53,10 @@ public function testFromHexP2MS(): void
{
$output = OutputFactory::fromHex('51210279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f8179851ae');
$this->assertInstanceOf(P2ms::class, $output);
$this->assertEquals($output->getPubKeys(), [hex2bin('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798')]);
$this->assertEquals(
$output->getPubKeys(),
[hex2bin('0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798')]
);
$this->assertEquals($output->getSigCount(), 1);
$this->assertEquals($output->type(), 'p2ms');
}
@@ -84,7 +90,10 @@ public function testFromHexP2WSH(): void
{
$output = OutputFactory::fromHex('002028205333db922f66e8a941b4a32d66de5cea03d9cda46e3e6658935272b9b24f');
$this->assertInstanceOf(P2wsh::class, $output);
$this->assertEquals($output->getWitnessHash(), hex2bin('28205333db922f66e8a941b4a32d66de5cea03d9cda46e3e6658935272b9b24f'));
$this->assertEquals(
$output->getWitnessHash(),
hex2bin('28205333db922f66e8a941b4a32d66de5cea03d9cda46e3e6658935272b9b24f')
);
$this->assertEquals($output->type(), 'p2wsh');
}

@@ -95,7 +104,10 @@ public function testFromHexP2TR()
{
$output = OutputFactory::fromHex('5120a60869f0dbcf1dc659c9cecbaf8050135ea9e8cdc487053f1dc6880949dc684c');
$this->assertInstanceOf(P2tr::class, $output);
$this->assertEquals($output->getTaprootPubKey(), hex2bin('a60869f0dbcf1dc659c9cecbaf8050135ea9e8cdc487053f1dc6880949dc684c'));
$this->assertEquals(
$output->getTaprootPubKey(),
hex2bin('a60869f0dbcf1dc659c9cecbaf8050135ea9e8cdc487053f1dc6880949dc684c')
);
$this->assertEquals($output->type(), 'p2tr');
}
}
5 changes: 4 additions & 1 deletion tests/P2shTest.php
Original file line number Diff line number Diff line change
@@ -88,7 +88,10 @@ public function testAddressBitcoinCash(): void
*/
public function testAddressBitcoinGold(): void
{
$this->assertEquals('AToUA3ZK5p6qsEPR85qopyPTKdGPaUNd9V', $this->getOutput()->address(NetworkFactory::bitcoinGold()));
$this->assertEquals(
'AToUA3ZK5p6qsEPR85qopyPTKdGPaUNd9V',
$this->getOutput()->address(NetworkFactory::bitcoinGold())
);
}

/**
34 changes: 27 additions & 7 deletions tests/P2trTest.php
Original file line number Diff line number Diff line change
@@ -24,7 +24,9 @@ class P2trTest extends TestCase
*/
protected function getOutput(): OutputInterface
{
$taprootPubKey = Taproot::construct(hex2bin('03cc8a4bc64d897bddc5fbc2f670f7a8ba0b386779106cf1223c6fc5d7cd6fc115'));
$taprootPubKey = Taproot::construct(
hex2bin('03cc8a4bc64d897bddc5fbc2f670f7a8ba0b386779106cf1223c6fc5d7cd6fc115')
);
return OutputFactory::p2tr($taprootPubKey);
}

@@ -33,47 +35,65 @@ protected function getOutput(): OutputInterface
*/
public function testHex()
{
$this->assertEquals('5120a60869f0dbcf1dc659c9cecbaf8050135ea9e8cdc487053f1dc6880949dc684c', $this->getOutput()->hex());
$this->assertEquals(
'5120a60869f0dbcf1dc659c9cecbaf8050135ea9e8cdc487053f1dc6880949dc684c',
$this->getOutput()->hex()
);
}

/**
* @throws Exception
*/
public function testAsm()
{
$this->assertEquals('1 PUSHDATA(32)[a60869f0dbcf1dc659c9cecbaf8050135ea9e8cdc487053f1dc6880949dc684c]', $this->getOutput()->asm());
$this->assertEquals(
'1 PUSHDATA(32)[a60869f0dbcf1dc659c9cecbaf8050135ea9e8cdc487053f1dc6880949dc684c]',
$this->getOutput()->asm()
);
}

/**
* @throws Exception
*/
public function testAddressBitcoin()
{
$this->assertEquals('bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr', $this->getOutput()->address());
$this->assertEquals(
'bc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqkedrcr',
$this->getOutput()->address()
);
}

/**
* @throws Exception
*/
public function testAddressBitcoinTestnet()
{
$this->assertEquals('tb1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqp3mvzv', $this->getOutput()->address(NetworkFactory::bitcoinTestnet()));
$this->assertEquals(
'tb1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxqp3mvzv',
$this->getOutput()->address(NetworkFactory::bitcoinTestnet())
);
}

/**
* @throws Exception
*/
public function testAddressLitecoin()
{
$this->assertEquals('ltc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxq4arnzx', $this->getOutput()->address(NetworkFactory::litecoin()));
$this->assertEquals(
'ltc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxq4arnzx',
$this->getOutput()->address(NetworkFactory::litecoin())
);
}

/**
* @throws Exception
*/
public function testAddressLitecoinTestnet()
{
$this->assertEquals('tltc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxq7j8dan', $this->getOutput()->address(NetworkFactory::litecoinTestnet()));
$this->assertEquals(
'tltc1p5cyxnuxmeuwuvkwfem96lqzszd02n6xdcjrs20cac6yqjjwudpxq7j8dan',
$this->getOutput()->address(NetworkFactory::litecoinTestnet())
);
}

/**