Skip to content

Commit

Permalink
Fixed missing path on async request.
Browse files Browse the repository at this point in the history
  • Loading branch information
denpamusic committed Sep 8, 2018
1 parent 333a012 commit b8f0e4e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public function requestAsync(
];

$promise = $this->client
->requestAsync('POST', '/', ['json' => $json]);
->requestAsync('POST', $this->path, ['json' => $json]);

$promise->then(
function (ResponseInterface $response) use ($onFullfiled) {
Expand Down
42 changes: 42 additions & 0 deletions tests/ClientTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,11 @@ public function testRequest()
$this->assertEquals(self::$getBlockResponse, $response->get());
}

/**
* Test multiwallet request.
*
* @return void
*/
public function testMultiWalletRequest()
{
$wallet = 'testwallet.dat';
Expand All @@ -163,6 +168,43 @@ public function testMultiWalletRequest()
$this->assertEquals($request->getUri()->getPath(), "/wallet/$wallet");
}

/**
* Test async multiwallet request.
*
* @return void
*/
public function testMultiWalletAsyncRequest()
{
$wallet = 'testwallet2.dat';
$history = [];

$guzzle = $this->mockGuzzle([
$this->getBalanceResponse(),
], $history);

$onFulfilled = $this->mockCallable([
$this->callback(function (Bitcoin\BitcoindResponse $response) {
return $response->get() == self::$balanceResponse;
}),
]);

$promise = $this->bitcoind
->setClient($guzzle)
->wallet($wallet)
->requestAsync(
'getbalance',
[],
function ($response) use ($onFulfilled) {
$onFulfilled($response);
}
);

$promise->wait();

$request = $history[0]['request'];
$this->assertEquals($request->getUri()->getPath(), "/wallet/$wallet");
}

/**
* Test async request.
*
Expand Down

0 comments on commit b8f0e4e

Please sign in to comment.