Comment tests.

Because ganache-cli only support shh_version, comment tests.
This commit is contained in:
sc0Vu 2018-01-26 17:57:35 +08:00
parent 078f2b1d80
commit f83a9c6c90
2 changed files with 112 additions and 109 deletions

View File

@ -45,54 +45,56 @@ class ShhApiTest extends TestCase
/** /**
* testNewIdentity * testNewIdentity
* Comment because ganache-cli only implement shh_version.
* *
* @return void * @return void
*/ */
public function testNewIdentity() // public function testNewIdentity()
{ // {
$shh = $this->shh; // $shh = $this->shh;
$shh->newIdentity(function ($err, $identity) { // $shh->newIdentity(function ($err, $identity) {
if ($err !== null) { // if ($err !== null) {
return $this->fail($err->getMessage()); // return $this->fail($err->getMessage());
} // }
$this->assertEquals(mb_strlen($identity), 132); // $this->assertEquals(mb_strlen($identity), 132);
}); // });
} // }
/** /**
* testHasIdentity * testHasIdentity
* Comment because ganache-cli only implement shh_version.
* *
* @return void * @return void
*/ */
public function testHasIdentity() // public function testHasIdentity()
{ // {
$shh = $this->shh; // $shh = $this->shh;
$newIdentity = '0x' . implode('', array_fill(0, 120, '0')); // $newIdentity = '0x' . implode('', array_fill(0, 120, '0'));
$shh->hasIdentity($newIdentity, function ($err, $hasIdentity) { // $shh->hasIdentity($newIdentity, function ($err, $hasIdentity) {
if ($err !== null) { // if ($err !== null) {
return $this->fail($err->getMessage()); // return $this->fail($err->getMessage());
} // }
$this->assertFalse($hasIdentity); // $this->assertFalse($hasIdentity);
}); // });
$shh->newIdentity(function ($err, $identity) use (&$newIdentity) { // $shh->newIdentity(function ($err, $identity) use (&$newIdentity) {
if ($err !== null) { // if ($err !== null) {
return $this->fail($err->getMessage()); // return $this->fail($err->getMessage());
} // }
$newIdentity = $identity; // $newIdentity = $identity;
$this->assertEquals(mb_strlen($identity), 132); // $this->assertEquals(mb_strlen($identity), 132);
}); // });
$shh->hasIdentity($newIdentity, function ($err, $hasIdentity) { // $shh->hasIdentity($newIdentity, function ($err, $hasIdentity) {
if ($err !== null) { // if ($err !== null) {
return $this->fail($err->getMessage()); // return $this->fail($err->getMessage());
} // }
$this->assertTrue($hasIdentity); // $this->assertTrue($hasIdentity);
}); // });
} // }
/** /**
* testNewGroup * testNewGroup
@ -140,61 +142,62 @@ class ShhApiTest extends TestCase
/** /**
* testPost * testPost
* Comment because ganache-cli only implement shh_version.
* *
* @return void * @return void
*/ */
public function testPost() // public function testPost()
{ // {
$shh = $this->shh; // $shh = $this->shh;
$fromIdentity = ''; // $fromIdentity = '';
$toIdentity = ''; // $toIdentity = '';
// create fromIdentity and toIdentity to prevent unknown identity error // // create fromIdentity and toIdentity to prevent unknown identity error
$shh->newIdentity(function ($err, $identity) use (&$fromIdentity) { // $shh->newIdentity(function ($err, $identity) use (&$fromIdentity) {
if ($err !== null) { // if ($err !== null) {
return $this->fail($err->getMessage()); // return $this->fail($err->getMessage());
} // }
$fromIdentity = $identity; // $fromIdentity = $identity;
$this->assertEquals(mb_strlen($identity), 132); // $this->assertEquals(mb_strlen($identity), 132);
}); // });
$shh->newIdentity(function ($err, $identity) use (&$toIdentity) { // $shh->newIdentity(function ($err, $identity) use (&$toIdentity) {
if ($err !== null) { // if ($err !== null) {
return $this->fail($err->getMessage()); // return $this->fail($err->getMessage());
} // }
$toIdentity = $identity; // $toIdentity = $identity;
$this->assertEquals(mb_strlen($identity), 132); // $this->assertEquals(mb_strlen($identity), 132);
}); // });
$shh->post([ // $shh->post([
'from' => $fromIdentity, // 'from' => $fromIdentity,
'to' => $toIdentity, // 'to' => $toIdentity,
'topics' => ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"], // 'topics' => ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"],
'payload' => "0x7b2274797065223a226d6", // 'payload' => "0x7b2274797065223a226d6",
'priority' => "0x64", // 'priority' => "0x64",
'ttl' => "0x64", // 'ttl' => "0x64",
], function ($err, $isSent) { // ], function ($err, $isSent) {
if ($err !== null) { // if ($err !== null) {
return $this->fail($err->getMessage()); // return $this->fail($err->getMessage());
} // }
$this->assertTrue($isSent); // $this->assertTrue($isSent);
}); // });
$shh->post([ // $shh->post([
'from' => $fromIdentity, // 'from' => $fromIdentity,
'to' => $toIdentity, // 'to' => $toIdentity,
'topics' => ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"], // 'topics' => ["0x776869737065722d636861742d636c69656e74", "0x4d5a695276454c39425154466b61693532"],
'payload' => "0x7b2274797065223a226d6", // 'payload' => "0x7b2274797065223a226d6",
'priority' => 123, // 'priority' => 123,
'ttl' => 123, // 'ttl' => 123,
], function ($err, $isSent) { // ], function ($err, $isSent) {
if ($err !== null) { // if ($err !== null) {
return $this->fail($err->getMessage()); // return $this->fail($err->getMessage());
} // }
$this->assertTrue($isSent); // $this->assertTrue($isSent);
}); // });
} // }
/** /**
* testWrongParam * testWrongParam
@ -203,17 +206,17 @@ class ShhApiTest extends TestCase
* *
* @return void * @return void
*/ */
public function testWrongParam() // public function testWrongParam()
{ // {
$this->expectException(RuntimeException::class); // $this->expectException(RuntimeException::class);
$shh = $this->shh; // $shh = $this->shh;
$shh->hasIdentity('0', function ($err, $hasIdentity) { // $shh->hasIdentity('0', function ($err, $hasIdentity) {
if ($err !== null) { // if ($err !== null) {
return $this->fail($err->getMessage()); // return $this->fail($err->getMessage());
} // }
$this->assertTrue(true); // $this->assertTrue(true);
}); // });
} // }
} }

View File

@ -37,14 +37,14 @@ class ShhBatchTest extends TestCase
$shh->batch(true); $shh->batch(true);
$shh->version(); $shh->version();
$shh->newIdentity(); $shh->version();
$shh->provider->execute(function ($err, $data) { $shh->provider->execute(function ($err, $data) {
if ($err !== null) { if ($err !== null) {
return $this->fail('Got error!'); return $this->fail('Got error!');
} }
$this->assertTrue(is_string($data[0])); $this->assertTrue(is_string($data[0]));
$this->assertEquals(mb_strlen($data[1]), 132); $this->assertTrue(is_string($data[1]));
}); });
} }
@ -53,22 +53,22 @@ class ShhBatchTest extends TestCase
* *
* @return void * @return void
*/ */
public function testWrongParam() // public function testWrongParam()
{ // {
$this->expectException(RuntimeException::class); // $this->expectException(RuntimeException::class);
$shh = $this->shh; // $shh = $this->shh;
$shh->batch(true); // $shh->batch(true);
$shh->version(); // $shh->version();
$shh->hasIdentity('0'); // $shh->hasIdentity('0');
$shh->provider->execute(function ($err, $data) { // $shh->provider->execute(function ($err, $data) {
if ($err !== null) { // if ($err !== null) {
return $this->fail('Got error!'); // return $this->fail('Got error!');
} // }
$this->assertTrue(is_string($data[0])); // $this->assertTrue(is_string($data[0]));
$this->assertFalse($data[1]); // $this->assertFalse($data[1]);
}); // });
} // }
} }