Skip to content

Commit

Permalink
Progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
Christian Mayer committed Jun 2, 2014
1 parent 0e309de commit 07fb15e
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion tests/HashcashTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,13 @@ public function testSetGet1(){
public function testSetGet2(){
#$this->assertTrue(true); return;

fwrite(STDOUT, '.');
$hashcash = new Hashcash(21, 'test1');
$this->assertEquals(1, $hashcash->getVersion());
$this->assertEquals(21, $hashcash->getBits());
$this->assertEquals(date('ymd'), $hashcash->getDate());

fwrite(STDOUT, '.');
$hashcash = new Hashcash();
$hashcash->setVersion(1);
$hashcash->setBits(21);
Expand All @@ -58,6 +60,7 @@ public function testMint1(){
#$this->markTestIncomplete('This test has not been implemented yet.');
#$this->assertTrue(true); return;

fwrite(STDOUT, '.');
$hashcash = new Hashcash();
$hashcash->setVersion(1);
$hashcash->setBits(10);
Expand All @@ -66,6 +69,7 @@ public function testMint1(){
$hashcash->setSalt('0000000c4c51ffcfc37b523');
$this->assertEquals('1:10:140422:mint2::0000000c4c51ffcfc37b523:977', $hashcash->mint());

fwrite(STDOUT, '.');
$hashcash = new Hashcash();
$hashcash->setVersion(1);
$hashcash->setBits(20);
Expand All @@ -75,6 +79,7 @@ public function testMint1(){
$hashcash->setSalt('salt2');
$this->assertEquals('1:20:140422:mint2:ext2:salt2:256507', $hashcash->mint());

fwrite(STDOUT, '.');
$hashcash = new Hashcash();
$hashcash->setVersion(1);
$hashcash->setBits(21);
Expand All @@ -83,6 +88,7 @@ public function testMint1(){
$hashcash->setSalt('2B6kv/rFiCdJRzqhH7P2eA==');
$this->assertEquals('1:21:870221:thefox::2B6kv/rFiCdJRzqhH7P2eA==:995214', $hashcash->mint());

fwrite(STDOUT, '.');
$hashcash = new Hashcash();
$hashcash->setVersion(1);
$hashcash->setBits(10);
Expand All @@ -91,6 +97,7 @@ public function testMint1(){
$hashcash->setSalt('2B6kv/rFiCdJRzqhH7P2eA==');
$this->assertEquals('1:10:8702210958:thefox::2B6kv/rFiCdJRzqhH7P2eA==:721', $hashcash->mint());

fwrite(STDOUT, '.');
$hashcash = new Hashcash();
$hashcash->setVersion(1);
$hashcash->setBits(10);
Expand All @@ -99,6 +106,7 @@ public function testMint1(){
$hashcash->setSalt('2B6kv/rFiCdJRzqhH7P2eA==');
$this->assertEquals('1:10:870221095824:thefox::2B6kv/rFiCdJRzqhH7P2eA==:47', $hashcash->mint());

fwrite(STDOUT, '.');
$hashcash = new Hashcash();
$hashcash->setVersion(1);
$hashcash->setBits(10);
Expand All @@ -107,6 +115,7 @@ public function testMint1(){
$hashcash->setSalt('P6MQOtdvyVIwmHRT3ansdQ==');
$this->assertEquals('1:10:140401:thefox::P6MQOtdvyVIwmHRT3ansdQ==:280', $hashcash->mint());

fwrite(STDOUT, '.');
$hashcash = new Hashcash();
$hashcash->setVersion(1);
$hashcash->setBits(10);
Expand Down Expand Up @@ -135,23 +144,31 @@ public function testVerify(){
$hashcash = new Hashcash();
$hashcash->setExpiration(0);

fwrite(STDOUT, '.');
$this->assertTrue( $hashcash->verify('1:20:140422:mint2::ArrRIabEj3nZrOcM:0000000000007u1E') );
fwrite(STDOUT, '.');
$this->assertTrue( $hashcash->verify('1:24:140422:mint2:ext1:Nde2ffWsRoe3DXVQ:00000001M+iu') );
fwrite(STDOUT, '.');
$this->assertTrue( $hashcash->verify('1:20:140422:mint2:ext2:salt2:256507') );
fwrite(STDOUT, '.');
$this->assertTrue( $hashcash->verify('1:28:140422:::s15xXleWocBKSA95Zw4e1Q==:245861178') );
fwrite(STDOUT, '.');
$this->assertTrue( $hashcash->verify('1:21:870221:thefox::2B6kv/rFiCdJRzqhH7P2eA==:995214') );

fwrite(STDOUT, '.');
$this->assertFalse( $hashcash->verify('1:20:140422:mint3::ArrRIabEj3nZrOcM:0000000000007u1E') );

$hashcash->setExpiration(3600 * 24 * 365);
$this->assertFalse( $hashcash->verify('1:21:870221:thefox::2B6kv/rFiCdJRzqhH7P2eA==:995214') );

fwrite(STDOUT, '.');

$hashcash1 = new Hashcash();
$hashcash1->setBits(10);
fwrite(STDOUT, '.');

$hashcash2 = new Hashcash();
$this->assertTrue($hashcash2->verify($hashcash1->mint()));
fwrite(STDOUT, '.');
}

/**
Expand Down

0 comments on commit 07fb15e

Please sign in to comment.