Add Eth tests.

This commit is contained in:
sc0Vu 2018-02-07 11:48:37 +08:00
parent 86b70f26c6
commit 49e19415b3
2 changed files with 34 additions and 1 deletions

View File

@ -3,6 +3,7 @@
namespace Test\Unit;
use RuntimeException;
use InvalidArgumentException;
use Test\TestCase;
use phpseclib\Math\BigInteger as BigNumber;
@ -825,4 +826,18 @@ class EthApiTest extends TestCase
$this->assertTrue(true);
});
}
/**
* testWrongCallback
*
* @return void
*/
public function testWrongCallback()
{
$this->expectException(InvalidArgumentException::class);
$eth = $this->eth;
$eth->protocolVersion();
}
}

View File

@ -7,6 +7,7 @@ use Test\TestCase;
use Web3\Providers\HttpProvider;
use Web3\RequestManagers\RequestManager;
use Web3\RequestManagers\HttpRequestManager;
use Web3\Eth;
class EthTest extends TestCase
{
@ -36,7 +37,7 @@ class EthTest extends TestCase
*/
public function testInstance()
{
$eth = $this->eth;
$eth = new Eth($this->testHost);
$this->assertTrue($eth->provider instanceof HttpProvider);
$this->assertTrue($eth->provider->requestManager instanceof RequestManager);
@ -54,5 +55,22 @@ class EthTest extends TestCase
$eth->provider = new HttpProvider($requestManager);
$this->assertEquals($eth->provider->requestManager->host, 'http://localhost:8545');
$eth->provider = null;
$this->assertEquals($eth->provider->requestManager->host, 'http://localhost:8545');
}
/**
* testCallThrowRuntimeException
*
* @return void
*/
public function testCallThrowRuntimeException()
{
$this->expectException(RuntimeException::class);
$eth = new Eth(null);
$eth->protocolVersion();
}
}