diff --git a/src/SolanaRpcClient.php b/src/SolanaRpcClient.php index 1f00935..d975f9a 100644 --- a/src/SolanaRpcClient.php +++ b/src/SolanaRpcClient.php @@ -2,8 +2,8 @@ namespace Tighten\SolanaPhpSdk; +use Illuminate\Http\Client\Factory as HttpFactory; use Illuminate\Http\Client\Response; -use Illuminate\Support\Facades\Http; use Tighten\SolanaPhpSdk\Exceptions\GenericException; use Tighten\SolanaPhpSdk\Exceptions\InvalidIdResponseException; use Tighten\SolanaPhpSdk\Exceptions\MethodNotFoundException; @@ -58,7 +58,7 @@ public function __construct(string $endpoint) */ public function call(string $method, array $params = []) { - $response = Http::acceptJson()->post( + $response = (new HttpFactory())->acceptJson()->post( $this->endpoint, $this->buildRpc($method, $params) )->throw(); diff --git a/tests/Unit/SolanaTest.php b/tests/Unit/SolanaTest.php index ee1bdf9..f7f86f6 100644 --- a/tests/Unit/SolanaTest.php +++ b/tests/Unit/SolanaTest.php @@ -2,41 +2,14 @@ namespace Tighten\SolanaPhpSdk\Tests\Unit; -use Illuminate\Http\Client\Request; use Illuminate\Support\Facades\Http; -use Tighten\SolanaPhpSdk\Exceptions\AccountNotFoundException; +use Tighten\SolanaPhpSdk\Exceptions\GenericException; use Tighten\SolanaPhpSdk\Programs\SystemProgram; use Tighten\SolanaPhpSdk\SolanaRpcClient; use Tighten\SolanaPhpSdk\Tests\TestCase; class SolanaTest extends TestCase { - /** @test */ - public function it_passes_undefined_calls_through_magically() - { - $client = new SolanaRpcClient(SolanaRpcClient::DEVNET_ENDPOINT); - $expectedIdInHttpResponse = $client->getRandomKey(); - $solana = new SystemProgram($client); - - Http::fake([ - SolanaRpcClient::DEVNET_ENDPOINT => Http::response([ - 'jsonrpc' => '2.0', - 'result' => [], // not important - 'id' => $expectedIdInHttpResponse, - ]), - ]); - - $solana->abcdefg([ - 'param1' => 123, - ]); - - Http::assertSent(function (Request $request) { - return $request->url() == SolanaRpcClient::DEVNET_ENDPOINT && - $request['method'] == 'abcdefg' && - $request['params'] == ['param1' => 123]; - }); - } - /** @test */ public function it_will_throw_exception_when_rpc_account_response_is_null() { @@ -56,7 +29,7 @@ public function it_will_throw_exception_when_rpc_account_response_is_null() ]), ]); - $this->expectException(AccountNotFoundException::class); + $this->expectException(GenericException::class); $solana->getAccountInfo('abc123'); } }