web3 = $web3; } /** * testProtocolVersion * * @return void */ public function testProtocolVersion() { $eth = $this->web3->eth; $eth->protocolVersion(function ($err, $version) { if ($err !== null) { return $this->fail($err->getMessage()); } if (isset($version->result)) { $this->assertTrue(is_string($version->result)); } else { $this->fail($version->error->message); } }); } /** * testSyncing * * @return void */ public function testSyncing() { $eth = $this->web3->eth; $eth->syncing(function ($err, $syncing) { if ($err !== null) { return $this->fail($err->getMessage()); } if (isset($syncing->result)) { // due to the result might be object or bool, only test is null $this->assertTrue($syncing->result !== null); } else { $this->fail($syncing->error->message); } }); } /** * testCoinbase * * @return void */ public function testCoinbase() { $eth = $this->web3->eth; $eth->coinbase(function ($err, $coinbase) { if ($err !== null) { // infura banned us to use coinbase return $this->assertTrue($err->getCode() === 405); } if (isset($coinbase->result)) { $this->assertTrue(is_string($coinbasse->result)); } else { $this->fail($coinbase->error->message); } }); } /** * testUnallowedMethod * * @return void */ public function testUnallowedMethod() { $this->expectException(RuntimeException::class); $eth = $this->web3->eth; $eth->hello(function ($err, $hello) { if ($err !== null) { return $this->fail($err->getMessage()); } if (isset($hello->result)) { $this->assertTrue(true); } else { $this->fail($hello->error->message); } }); } }