public function testToRequest()
 {
     $height = 123123;
     $note = new NumBlocksNotification($height);
     $request = $note->toRequest();
     $this->assertEquals(null, $request->getId());
     $this->assertEquals(ElectrumClient::NUMBLOCKS_SUBSCRIBE, $request->getMethod());
     $this->assertEquals([$height], $request->getParams());
 }
Exemple #2
0
 public function testNotify()
 {
     $note = new NumBlocksNotification(392312);
     $serialized = new Deferred();
     $serialized->promise()->then(function () use($note) {
         $this->assertEquals($note->toRequest()->write(), func_get_args()[0]);
     }, function () {
         $this->fail();
     });
     $stream = $this->getMockStream();
     $stream->expects($this->once())->method('write')->willReturnCallback(function () use($note, &$serialized) {
         $args = func_get_args();
         if (isset($args[0])) {
             $serialized->resolve($args[0]);
         } else {
             $serialized->reject();
         }
     });
     $factory = new RequestFactory();
     $connection = new Connection($stream, $factory);
     $connection->sendNotify($note);
 }