Passed
Push — master ( b5e885...54d7bc )
by Charles
02:34
created

UtilsTest::testKeypairGeneration()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace ncryptf\Tests;
4
5
use ncryptf\Utils;
6
use ncryptf\Keypair;
7
use PHPUnit\Framework\TestCase;
8
9
class UtilsTest extends TestCase
10
{
11
    public function testKeypairGeneration()
12
    {
13
        $keypair = Utils::generateKeypair();
14
        $this->assertEquals(\get_class($keypair), 'ncryptf\Keypair');
15
        $this->assertEquals(32, \strlen($keypair->getPublicKey()));
16
        $this->assertEquals(32, \strlen($keypair->getSecretKey()));
17
    }
18
19
    public function testSigningKeypairGeneration()
20
    {
21
        $keypair = Utils::generateSigningKeypair();
22
        $this->assertEquals(\get_class($keypair), 'ncryptf\Keypair');
23
        $this->assertEquals(32, \strlen($keypair->getPublicKey()));
24
        $this->assertEquals(64, \strlen($keypair->getSecretKey()));
25
    }
26
27
    public function testZero()
28
    {
29
        $data = \random_bytes(32);
30
        $zero = Utils::zero($data);
31
        $this->assertEquals($zero, true);
32
        $this->assertEquals($data, null);
33
    }
34
}
35