78 lines
1.6 KiB
PHP
78 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace Test\Unit;
|
|
|
|
use RuntimeException;
|
|
use Test\TestCase;
|
|
use Web3\Web3;
|
|
use Web3\Eth;
|
|
use Web3\Net;
|
|
use Web3\Providers\HttpProvider;
|
|
use Web3\RequestManagers\RequestManager;
|
|
|
|
class Web3Test extends TestCase
|
|
{
|
|
/**
|
|
* testHex
|
|
* 'hello world'
|
|
* you can check by call pack('H*', $hex)
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $testHex = '0x68656c6c6f20776f726c64';
|
|
|
|
/**
|
|
* testHash
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $testHash = '0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad';
|
|
|
|
/**
|
|
* setUp
|
|
*
|
|
* @return void
|
|
*/
|
|
public function setUp()
|
|
{
|
|
parent::setUp();
|
|
}
|
|
|
|
/**
|
|
* testInstance
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testInstance()
|
|
{
|
|
$web3 = $this->web3;
|
|
|
|
$this->assertTrue($web3->provider instanceof HttpProvider);
|
|
$this->assertTrue($web3->provider->requestManager instanceof RequestManager);
|
|
$this->assertTrue($web3->eth instanceof Eth);
|
|
$this->assertTrue($web3->net instanceof Net);
|
|
}
|
|
|
|
/**
|
|
* testUnallowedMethod
|
|
*
|
|
* @return void
|
|
*/
|
|
public function testUnallowedMethod()
|
|
{
|
|
$this->expectException(RuntimeException::class);
|
|
|
|
$web3 = $this->web3;
|
|
|
|
$web3->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);
|
|
}
|
|
});
|
|
}
|
|
} |