diff --git a/tests/unit/CryptonoteTest.php b/tests/unit/CryptonoteTest.php new file mode 100644 index 0000000..53acd1c --- /dev/null +++ b/tests/unit/CryptonoteTest.php @@ -0,0 +1,95 @@ +cr = new Cryptonote(MoneroNetwork::mainnet); + } + + public function testKeccak256(): void + { + $result = $this->cr->keccak_256($this->testDecodedKeccak); + $this->assertEquals($this->testEncodedKeccak, $result); + } + + public function testGenNewHexSeed(): void + { + $result = $this->cr->gen_new_hex_seed(); + $this->assertIsString($result); + $this->assertEquals(64, strlen($result)); + } + + public function testDeriveViewKey(): void + { + $result = $this->cr->derive_viewKey($this->testPrivateSpendKey); + $this->assertEquals($this->testPrivateViewKey, $result); + } + + public function testPkFromSk(): void + { + $result = $this->cr->pk_from_sk($this->testPrivateSpendKey); + $this->assertEquals($this->testPubSpendKey, $result); + } + + public function testEncodeAddress(): void + { + $result = $this->cr->encode_address($this->testPubSpendKey, $this->testPubViewKey); + $this->assertEquals($this->testAddress, $result); + } + + public function testVerifyChecksum(): void + { + $result = $this->cr->verify_checksum($this->testAddress); + $this->assertTrue($result); + + $result = $this->cr->verify_checksum($this->testAddressBad); + $this->assertFalse($result); + } + + public function testDecodeAddress(): void + { + $result = $this->cr->decode_address($this->testAddress); + $this->assertIsArray($result); + + $this->assertEquals($this->testAddressNetByte, $result["networkByte"]); + $this->assertEquals($this->testPubSpendKey, $result["spendKey"]); + $this->assertEquals($this->testPubViewKey, $result["viewKey"]); + } + + public function testIntegratedAddrFromKeys(): void + { + $result = $this->cr->integrated_addr_from_keys($this->testPubSpendKey, $this->testPubViewKey, $this->testPaymentId); + $this->assertEquals($this->testIntegratedAddress, $result); + } + + public function testAddressFromSeed(): void + { + $result = $this->cr->address_from_seed($this->testHexSeed); + $this->assertEquals($this->testAddress, $result); + } +} \ No newline at end of file