Eth hashrate output formatter.

This commit is contained in:
sc0Vu 2018-01-12 15:42:43 +08:00
parent 7b5543138b
commit 04c5ac24f6
2 changed files with 8 additions and 6 deletions

View File

@ -13,6 +13,7 @@ namespace Web3\Methods\Eth;
use InvalidArgumentException; use InvalidArgumentException;
use Web3\Methods\EthMethod; use Web3\Methods\EthMethod;
use Web3\Formatters\BigNumberFormatter;
class Hashrate extends EthMethod class Hashrate extends EthMethod
{ {
@ -35,7 +36,9 @@ class Hashrate extends EthMethod
* *
* @var array * @var array
*/ */
protected $outputFormatters = []; protected $outputFormatters = [
BigNumberFormatter::class
];
/** /**
* defaultValues * defaultValues

View File

@ -73,10 +73,9 @@ class EthApiTest extends TestCase
$eth->coinbase(function ($err, $coinbase) { $eth->coinbase(function ($err, $coinbase) {
if ($err !== null) { if ($err !== null) {
// infura banned us to use coinbase return $this->fail($err->getMessage());
return $this->assertTrue($err->getCode() === 405);
} }
$this->assertTrue(is_string($coinbass)); $this->assertEquals($coinbase, '0x561a2aa10f9a8589c93665554c871106342f70af');
}); });
} }
@ -93,7 +92,7 @@ class EthApiTest extends TestCase
if ($err !== null) { if ($err !== null) {
return $this->fail($err->getMessage()); return $this->fail($err->getMessage());
} }
$this->assertTrue($mining !== null); $this->assertTrue($mining);
}); });
} }
@ -110,7 +109,7 @@ class EthApiTest extends TestCase
if ($err !== null) { if ($err !== null) {
return $this->fail($err->getMessage()); return $this->fail($err->getMessage());
} }
$this->assertTrue(is_string($hashrate)); $this->assertEquals($hashrate->toString(), '0');
}); });
} }