EthApiTest.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843
  1. <?php
  2. namespace Test\Unit;
  3. use RuntimeException;
  4. use InvalidArgumentException;
  5. use Test\TestCase;
  6. use phpseclib\Math\BigInteger as BigNumber;
  7. class EthApiTest extends TestCase
  8. {
  9. /**
  10. * eth
  11. *
  12. * @var \Web3\Eth
  13. */
  14. protected $eth;
  15. /**
  16. * setUp
  17. *
  18. * @return void
  19. */
  20. public function setUp()
  21. {
  22. parent::setUp();
  23. $this->eth = $this->web3->eth;
  24. }
  25. /**
  26. * testProtocolVersion
  27. *
  28. * @return void
  29. */
  30. public function testProtocolVersion()
  31. {
  32. $eth = $this->eth;
  33. $eth->protocolVersion(function ($err, $version) {
  34. if ($err !== null) {
  35. return $this->fail($err->getMessage());
  36. }
  37. $this->assertTrue($version instanceof BigNumber);
  38. });
  39. }
  40. /**
  41. * testSyncing
  42. *
  43. * @return void
  44. */
  45. public function testSyncing()
  46. {
  47. $eth = $this->eth;
  48. $eth->syncing(function ($err, $syncing) {
  49. if ($err !== null) {
  50. return $this->fail($err->getMessage());
  51. }
  52. // due to the result might be object or bool, only test is null
  53. $this->assertTrue($syncing !== null);
  54. });
  55. }
  56. /**
  57. * testCoinbase
  58. *
  59. * @return void
  60. */
  61. public function testCoinbase()
  62. {
  63. $eth = $this->eth;
  64. $eth->coinbase(function ($err, $coinbase) {
  65. if ($err !== null) {
  66. return $this->fail($err->getMessage());
  67. }
  68. $this->assertEquals($coinbase, $this->coinbase);
  69. });
  70. }
  71. /**
  72. * testMining
  73. *
  74. * @return void
  75. */
  76. public function testMining()
  77. {
  78. $eth = $this->eth;
  79. $eth->mining(function ($err, $mining) {
  80. if ($err !== null) {
  81. return $this->fail($err->getMessage());
  82. }
  83. $this->assertTrue($mining);
  84. });
  85. }
  86. /**
  87. * testHashrate
  88. *
  89. * @return void
  90. */
  91. public function testHashrate()
  92. {
  93. $eth = $this->eth;
  94. $eth->hashrate(function ($err, $hashrate) {
  95. if ($err !== null) {
  96. return $this->fail($err->getMessage());
  97. }
  98. $this->assertEquals($hashrate->toString(), '0');
  99. });
  100. }
  101. /**
  102. * testGasPrice
  103. *
  104. * @return void
  105. */
  106. public function testGasPrice()
  107. {
  108. $eth = $this->eth;
  109. $eth->gasPrice(function ($err, $gasPrice) {
  110. if ($err !== null) {
  111. return $this->fail($err->getMessage());
  112. }
  113. $this->assertTrue(is_numeric($gasPrice->toString()));
  114. });
  115. }
  116. /**
  117. * testAccounts
  118. *
  119. * @return void
  120. */
  121. public function testAccounts()
  122. {
  123. $eth = $this->eth;
  124. $eth->accounts(function ($err, $accounts) {
  125. if ($err !== null) {
  126. return $this->fail($err->getMessage());
  127. }
  128. $this->assertTrue(is_array($accounts));
  129. });
  130. }
  131. /**
  132. * testBlockNumber
  133. *
  134. * @return void
  135. */
  136. public function testBlockNumber()
  137. {
  138. $eth = $this->eth;
  139. $eth->blockNumber(function ($err, $blockNumber) {
  140. if ($err !== null) {
  141. return $this->fail($err->getMessage());
  142. }
  143. $this->assertTrue(is_numeric($blockNumber->toString()));
  144. });
  145. }
  146. /**
  147. * testGetBalance
  148. *
  149. * @return void
  150. */
  151. public function testGetBalance()
  152. {
  153. $eth = $this->eth;
  154. $eth->getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1', function ($err, $balance) {
  155. if ($err !== null) {
  156. return $this->fail($err->getMessage());
  157. }
  158. $this->assertTrue(is_numeric($balance->toString()));
  159. });
  160. }
  161. /**
  162. * testGetStorageAt
  163. *
  164. * @return void
  165. */
  166. public function testGetStorageAt()
  167. {
  168. $eth = $this->eth;
  169. $eth->getStorageAt('0x561a2aa10f9a8589c93665554c871106342f70af', '0x0', function ($err, $storage) {
  170. if ($err !== null) {
  171. return $this->fail($err->getMessage());
  172. }
  173. $this->assertTrue(is_string($storage));
  174. });
  175. }
  176. /**
  177. * testGetTransactionCount
  178. *
  179. * @return void
  180. */
  181. public function testGetTransactionCount()
  182. {
  183. $eth = $this->eth;
  184. $eth->getTransactionCount('0x561a2aa10f9a8589c93665554c871106342f70af', function ($err, $transactionCount) {
  185. if ($err !== null) {
  186. return $this->fail($err->getMessage());
  187. }
  188. $this->assertTrue(is_numeric($transactionCount->toString()));
  189. });
  190. }
  191. /**
  192. * testGetBlockTransactionCountByHash
  193. *
  194. * @return void
  195. */
  196. public function testGetBlockTransactionCountByHash()
  197. {
  198. $eth = $this->eth;
  199. $eth->getBlockTransactionCountByHash('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', function ($err, $transactionCount) {
  200. if ($err !== null) {
  201. return $this->assertTrue($err !== null);
  202. }
  203. $this->assertTrue(is_numeric($transactionCount->toString()));
  204. });
  205. }
  206. /**
  207. * testGetBlockTransactionCountByNumber
  208. *
  209. * @return void
  210. */
  211. public function testGetBlockTransactionCountByNumber()
  212. {
  213. $eth = $this->eth;
  214. $eth->getBlockTransactionCountByNumber('0x0', function ($err, $transactionCount) {
  215. if ($err !== null) {
  216. return $this->assertTrue($err !== null);
  217. }
  218. $this->assertTrue(is_numeric($transactionCount->toString()));
  219. });
  220. }
  221. /**
  222. * testGetUncleCountByBlockHash
  223. *
  224. * @return void
  225. */
  226. public function testGetUncleCountByBlockHash()
  227. {
  228. $eth = $this->eth;
  229. $eth->getUncleCountByBlockHash('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', function ($err, $uncleCount) {
  230. if ($err !== null) {
  231. return $this->assertTrue($err !== null);
  232. }
  233. $this->assertTrue(is_numeric($uncleCount->toString()));
  234. });
  235. }
  236. /**
  237. * testGetUncleCountByBlockNumber
  238. *
  239. * @return void
  240. */
  241. public function testGetUncleCountByBlockNumber()
  242. {
  243. $eth = $this->eth;
  244. $eth->getUncleCountByBlockNumber('0x0', function ($err, $uncleCount) {
  245. if ($err !== null) {
  246. return $this->assertTrue($err !== null);
  247. }
  248. $this->assertTrue(is_numeric($uncleCount->toString()));
  249. });
  250. }
  251. /**
  252. * testGetCode
  253. *
  254. * @return void
  255. */
  256. public function testGetCode()
  257. {
  258. $eth = $this->eth;
  259. $eth->getCode('0x407d73d8a49eeb85d32cf465507dd71d507100c1', function ($err, $code) {
  260. if ($err !== null) {
  261. return $this->assertTrue($err !== null);
  262. }
  263. $this->assertTrue(is_string($code));
  264. });
  265. }
  266. /**
  267. * testSign
  268. *
  269. * @return void
  270. */
  271. public function testSign()
  272. {
  273. $eth = $this->eth;
  274. $eth->sign('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '0xdeadbeaf', function ($err, $sign) {
  275. if ($err !== null) {
  276. // infura banned us to sign message
  277. return $this->assertTrue($err !== null);
  278. }
  279. $this->assertTrue(is_string($sign));
  280. });
  281. }
  282. /**
  283. * testSendTransaction
  284. *
  285. * @return void
  286. */
  287. public function testSendTransaction()
  288. {
  289. $eth = $this->eth;
  290. $eth->sendTransaction([
  291. 'from' => "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
  292. 'to' => "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
  293. 'gas' => "0x76c0",
  294. 'gasPrice' => "0x9184e72a000",
  295. 'value' => "0x9184e72a",
  296. 'data' => "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
  297. ], function ($err, $transaction) {
  298. if ($err !== null) {
  299. // infura banned us to send transaction
  300. return $this->assertTrue($err !== null);
  301. }
  302. $this->assertTrue(is_string($transaction));
  303. });
  304. }
  305. /**
  306. * testSendRawTransaction
  307. *
  308. * @return void
  309. */
  310. public function testSendRawTransaction()
  311. {
  312. $eth = $this->eth;
  313. $eth->sendRawTransaction('0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675', function ($err, $transaction) {
  314. if ($err !== null) {
  315. return $this->assertTrue($err !== null);
  316. }
  317. $this->assertTrue(is_string($transaction));
  318. });
  319. }
  320. /**
  321. * testCall
  322. *
  323. * @return void
  324. */
  325. public function testCall()
  326. {
  327. $eth = $this->eth;
  328. $eth->call([
  329. // 'from' => "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
  330. 'to' => "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
  331. 'gas' => "0x76c0",
  332. 'gasPrice' => "0x9184e72a000",
  333. 'value' => "0x9184e72a",
  334. 'data' => "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
  335. ], function ($err, $transaction) {
  336. if ($err !== null) {
  337. return $this->assertTrue($err !== null);
  338. }
  339. $this->assertTrue(is_string($transaction));
  340. });
  341. }
  342. /**
  343. * testEstimateGas
  344. *
  345. * @return void
  346. */
  347. public function testEstimateGas()
  348. {
  349. $eth = $this->eth;
  350. $eth->estimateGas([
  351. 'from' => "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
  352. 'to' => "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
  353. 'gas' => "0x76c0",
  354. 'gasPrice' => "0x9184e72a000",
  355. 'value' => "0x9184e72a",
  356. 'data' => "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
  357. ], function ($err, $gas) {
  358. if ($err !== null) {
  359. return $this->assertTrue($err !== null);
  360. }
  361. $this->assertTrue(is_numeric($gas->toString()));
  362. });
  363. }
  364. /**
  365. * testGetBlockByHash
  366. *
  367. * @return void
  368. */
  369. public function testGetBlockByHash()
  370. {
  371. $eth = $this->eth;
  372. $eth->getBlockByHash('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', false, function ($err, $block) {
  373. if ($err !== null) {
  374. return $this->assertTrue($err !== null);
  375. }
  376. $this->assertTrue($block !== null);
  377. });
  378. }
  379. /**
  380. * testGetBlockByNumber
  381. *
  382. * @return void
  383. */
  384. public function testGetBlockByNumber()
  385. {
  386. $eth = $this->eth;
  387. $eth->getBlockByNumber('latest', false, function ($err, $block) {
  388. if ($err !== null) {
  389. return $this->assertTrue($err !== null);
  390. }
  391. // weired behavior, see https://github.com/sc0Vu/web3.php/issues/16
  392. $this->assertTrue($block !== null);
  393. });
  394. }
  395. /**
  396. * testGetTransactionByHash
  397. *
  398. * @return void
  399. */
  400. public function testGetTransactionByHash()
  401. {
  402. $eth = $this->eth;
  403. $eth->getTransactionByHash('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', function ($err, $transaction) {
  404. if ($err !== null) {
  405. return $this->assertTrue($err !== null);
  406. }
  407. $this->assertTrue($transaction !== null);
  408. });
  409. }
  410. /**
  411. * testGetTransactionByBlockHashAndIndex
  412. *
  413. * @return void
  414. */
  415. public function testGetTransactionByBlockHashAndIndex()
  416. {
  417. $eth = $this->eth;
  418. $eth->getTransactionByBlockHashAndIndex('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', '0x0', function ($err, $transaction) {
  419. if ($err !== null) {
  420. return $this->assertTrue($err !== null);
  421. }
  422. $this->assertTrue($transaction !== null);
  423. });
  424. }
  425. /**
  426. * testGetTransactionByBlockNumberAndIndex
  427. *
  428. * @return void
  429. */
  430. public function testGetTransactionByBlockNumberAndIndex()
  431. {
  432. $eth = $this->eth;
  433. $eth->getTransactionByBlockNumberAndIndex('0xe8', '0x0', function ($err, $transaction) {
  434. if ($err !== null) {
  435. return $this->assertTrue($err !== null);
  436. }
  437. $this->assertTrue($transaction !== null);
  438. });
  439. }
  440. /**
  441. * testGetTransactionReceipt
  442. *
  443. * @return void
  444. */
  445. public function testGetTransactionReceipt()
  446. {
  447. $eth = $this->eth;
  448. $eth->getTransactionReceipt('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', function ($err, $transaction) {
  449. if ($err !== null) {
  450. return $this->assertTrue($err !== null);
  451. }
  452. $this->assertTrue($transaction !== null);
  453. });
  454. }
  455. /**
  456. * testGetUncleByBlockHashAndIndex
  457. *
  458. * @return void
  459. */
  460. public function testGetUncleByBlockHashAndIndex()
  461. {
  462. $eth = $this->eth;
  463. $eth->getUncleByBlockHashAndIndex('0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238', '0x0', function ($err, $uncle) {
  464. if ($err !== null) {
  465. return $this->assertTrue($err !== null);
  466. }
  467. $this->assertTrue($uncle !== null);
  468. });
  469. }
  470. /**
  471. * testGetUncleByBlockNumberAndIndex
  472. *
  473. * @return void
  474. */
  475. public function testGetUncleByBlockNumberAndIndex()
  476. {
  477. $eth = $this->eth;
  478. $eth->getUncleByBlockNumberAndIndex('0xe8', '0x0', function ($err, $uncle) {
  479. if ($err !== null) {
  480. return $this->assertTrue($err !== null);
  481. }
  482. $this->assertTrue($uncle !== null);
  483. });
  484. }
  485. /**
  486. * testGetCompilers
  487. *
  488. * @return void
  489. */
  490. public function testGetCompilers()
  491. {
  492. $eth = $this->eth;
  493. $eth->getCompilers(function ($err, $compilers) {
  494. if ($err !== null) {
  495. return $this->assertTrue($err !== null);
  496. }
  497. $this->assertTrue(is_array($compilers));
  498. $this->assertEquals($compilers[0], 'solidity');
  499. });
  500. }
  501. /**
  502. * testCompileSolidity
  503. *
  504. * @return void
  505. */
  506. public function testCompileSolidity()
  507. {
  508. $eth = $this->eth;
  509. $eth->compileSolidity('contract test { function multiply(uint a) returns(uint d) { return a * 7; } }', function ($err, $compiled) {
  510. if ($err !== null) {
  511. return $this->assertTrue($err !== null);
  512. }
  513. $this->assertTrue(is_string($compiled));
  514. });
  515. }
  516. /**
  517. * testCompileLLL
  518. *
  519. * @return void
  520. */
  521. public function testCompileLLL()
  522. {
  523. $eth = $this->eth;
  524. $eth->compileLLL('(returnlll (suicide (caller)))', function ($err, $compiled) {
  525. if ($err !== null) {
  526. return $this->assertTrue($err !== null);
  527. }
  528. $this->assertTrue(is_string($compiled));
  529. });
  530. }
  531. /**
  532. * testCompileSerpent
  533. *
  534. * @return void
  535. */
  536. public function testCompileSerpent()
  537. {
  538. $eth = $this->eth;
  539. $eth->compileSerpent('\/* some serpent *\/', function ($err, $compiled) {
  540. if ($err !== null) {
  541. return $this->assertTrue($err !== null);
  542. }
  543. $this->assertTrue(is_string($compiled));
  544. });
  545. }
  546. /**
  547. * testNewFilter
  548. *
  549. * @return void
  550. */
  551. public function testNewFilter()
  552. {
  553. $eth = $this->eth;
  554. $eth->newFilter([
  555. 'fromBlock' => '0x1',
  556. 'toBlock' => '0x2',
  557. 'address' => '0x8888f1f195afa192cfee860698584c030f4c9db1',
  558. 'topics' => ['0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b', null, ['0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b', '0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc']]
  559. ], function ($err, $filter) {
  560. if ($err !== null) {
  561. // infura banned us to new filter
  562. return $this->assertTrue($err !== null);
  563. }
  564. $this->assertTrue(is_string($filter));
  565. });
  566. }
  567. /**
  568. * testNewBlockFilter
  569. *
  570. * @return void
  571. */
  572. public function testNewBlockFilter()
  573. {
  574. $eth = $this->eth;
  575. $eth->newBlockFilter('0x01', function ($err, $filter) {
  576. if ($err !== null) {
  577. // infura banned us to new block filter
  578. return $this->assertTrue($err !== null);
  579. }
  580. $this->assertTrue(is_string($filter));
  581. });
  582. }
  583. /**
  584. * testNewPendingTransactionFilter
  585. *
  586. * @return void
  587. */
  588. public function testNewPendingTransactionFilter()
  589. {
  590. $eth = $this->eth;
  591. $eth->newPendingTransactionFilter(function ($err, $filter) {
  592. if ($err !== null) {
  593. // infura banned us to new pending transaction filter
  594. return $this->assertTrue($err !== null);
  595. }
  596. $this->assertTrue(is_string($filter));
  597. });
  598. }
  599. /**
  600. * testUninstallFilter
  601. *
  602. * @return void
  603. */
  604. public function testUninstallFilter()
  605. {
  606. $eth = $this->eth;
  607. $eth->uninstallFilter('0x01', function ($err, $filter) {
  608. if ($err !== null) {
  609. // infura banned us to uninstall filter
  610. return $this->assertTrue($err !== null);
  611. }
  612. $this->assertTrue(is_bool($filter));
  613. });
  614. }
  615. /**
  616. * testGetFilterChanges
  617. *
  618. * @return void
  619. */
  620. public function testGetFilterChanges()
  621. {
  622. $eth = $this->eth;
  623. $eth->getFilterChanges('0x01', function ($err, $changes) {
  624. if ($err !== null) {
  625. // infura banned us to get filter changes
  626. return $this->assertTrue($err !== null);
  627. }
  628. $this->assertTrue(is_array($changes));
  629. });
  630. }
  631. /**
  632. * testGetFilterLogs
  633. *
  634. * @return void
  635. */
  636. public function testGetFilterLogs()
  637. {
  638. $eth = $this->eth;
  639. $eth->getFilterLogs('0x01', function ($err, $logs) {
  640. if ($err !== null) {
  641. // infura banned us to get filter logs
  642. return $this->assertTrue($err !== null);
  643. }
  644. $this->assertTrue(is_array($logs));
  645. });
  646. }
  647. /**
  648. * testGetLogs
  649. *
  650. * @return void
  651. */
  652. public function testGetLogs()
  653. {
  654. $eth = $this->eth;
  655. $eth->getLogs([
  656. 'fromBlock' => '0x1',
  657. 'toBlock' => '0x2',
  658. 'address' => '0x8888f1f195afa192cfee860698584c030f4c9db1',
  659. 'topics' => ['0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b', null, ['0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b', '0x0000000000000000000000000aff3454fce5edbc8cca8697c15331677e6ebccc']]
  660. ], function ($err, $logs) {
  661. if ($err !== null) {
  662. return $this->assertTrue($err !== null);
  663. }
  664. $this->assertTrue(is_array($logs));
  665. });
  666. }
  667. /**
  668. * testGetWork
  669. *
  670. * @return void
  671. */
  672. public function testGetWork()
  673. {
  674. $eth = $this->eth;
  675. $eth->getWork(function ($err, $work) {
  676. if ($err !== null) {
  677. return $this->assertTrue($err !== null);
  678. }
  679. $this->assertTrue(is_array($work));
  680. });
  681. }
  682. /**
  683. * testSubmitWork
  684. *
  685. * @return void
  686. */
  687. public function testSubmitWork()
  688. {
  689. $eth = $this->eth;
  690. $eth->submitWork(
  691. '0x0000000000000001',
  692. '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
  693. '0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000'
  694. , function ($err, $work) {
  695. if ($err !== null) {
  696. return $this->assertTrue($err !== null);
  697. }
  698. $this->assertTrue(is_bool($work));
  699. });
  700. }
  701. /**
  702. * testSubmitHashrate
  703. *
  704. * @return void
  705. */
  706. public function testSubmitHashrate()
  707. {
  708. $eth = $this->eth;
  709. $eth->submitHashrate(
  710. '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef',
  711. '0xD1FE5700000000000000000000000000D1FE5700000000000000000000000000'
  712. , function ($err, $work) {
  713. if ($err !== null) {
  714. return $this->assertTrue($err !== null);
  715. }
  716. $this->assertTrue(is_bool($work));
  717. });
  718. }
  719. /**
  720. * testUnallowedMethod
  721. *
  722. * @return void
  723. */
  724. public function testUnallowedMethod()
  725. {
  726. $this->expectException(RuntimeException::class);
  727. $eth = $this->eth;
  728. $eth->hello(function ($err, $hello) {
  729. if ($err !== null) {
  730. return $this->assertTrue($err !== null);
  731. }
  732. $this->assertTrue(true);
  733. });
  734. }
  735. /**
  736. * testWrongCallback
  737. *
  738. * @return void
  739. */
  740. public function testWrongCallback()
  741. {
  742. $this->expectException(InvalidArgumentException::class);
  743. $eth = $this->eth;
  744. $eth->protocolVersion();
  745. }
  746. }