From 746b4f192b65428382a845fbe254bb82bab3b144 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Sun, 27 Aug 2023 13:48:42 +0800 Subject: [PATCH] Add testPeerCountAsync --- test/unit/NetApiTest.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/unit/NetApiTest.php b/test/unit/NetApiTest.php index 49142352..0c96d571 100644 --- a/test/unit/NetApiTest.php +++ b/test/unit/NetApiTest.php @@ -79,6 +79,27 @@ public function testListening() }); } + /** + * testPeerCountAsync + * + * @return void + */ + public function testPeerCountAsync() + { + $net = $this->net; + $net->provider = $this->asyncHttpProvider; + + // should return reactphp promise + $promise = $net->peerCount(function ($err, $count) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + $this->assertTrue($count instanceof BigNumber); + }); + $this->assertTrue($promise instanceof \React\Promise\PromiseInterface); + \React\Async\await($promise); + } + /** * testUnallowedMethod *