NetBatchTest.php 964 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. namespace Test\Unit;
  3. use RuntimeException;
  4. use Test\TestCase;
  5. use phpseclib\Math\BigInteger as BigNumber;
  6. class NetBatchTest extends TestCase
  7. {
  8. /**
  9. * net
  10. *
  11. * @var Web3\Net
  12. */
  13. protected $net;
  14. /**
  15. * setUp
  16. *
  17. * @return void
  18. */
  19. public function setUp()
  20. {
  21. parent::setUp();
  22. $this->net = $this->web3->net;
  23. }
  24. /**
  25. * testBatch
  26. *
  27. * @return void
  28. */
  29. public function testBatch()
  30. {
  31. $net = $this->net;
  32. $net->batch(true);
  33. $net->version();
  34. $net->listening();
  35. $net->peerCount();
  36. $net->provider->execute(function ($err, $data) {
  37. if ($err !== null) {
  38. return $this->fail('Got error!');
  39. }
  40. $this->assertTrue(is_string($data[0]));
  41. $this->assertTrue(is_bool($data[1]));
  42. $this->assertTrue($data[2] instanceof BigNumber);
  43. });
  44. }
  45. }