Web3 setProvider test
This commit is contained in:
parent
83ffda80c8
commit
5d19c4659c
@ -75,6 +75,29 @@ class Web3ApiTest extends TestCase
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* testUnallowedMethod
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testUnallowedMethod()
|
||||||
|
{
|
||||||
|
$this->expectException(RuntimeException::class);
|
||||||
|
|
||||||
|
$web3 = $this->web3;
|
||||||
|
|
||||||
|
$web3->hello(function ($err, $hello) {
|
||||||
|
if ($err !== null) {
|
||||||
|
return $this->fail($err->getMessage());
|
||||||
|
}
|
||||||
|
if (isset($hello->result)) {
|
||||||
|
$this->assertTrue(true);
|
||||||
|
} else {
|
||||||
|
$this->fail($hello->error->message);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testWrongParam
|
* testWrongParam
|
||||||
*
|
*
|
||||||
|
@ -9,6 +9,7 @@ use Web3\Eth;
|
|||||||
use Web3\Net;
|
use Web3\Net;
|
||||||
use Web3\Providers\HttpProvider;
|
use Web3\Providers\HttpProvider;
|
||||||
use Web3\RequestManagers\RequestManager;
|
use Web3\RequestManagers\RequestManager;
|
||||||
|
use Web3\RequestManagers\HttpRequestManager;
|
||||||
|
|
||||||
class Web3Test extends TestCase
|
class Web3Test extends TestCase
|
||||||
{
|
{
|
||||||
@ -54,25 +55,16 @@ class Web3Test extends TestCase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* testUnallowedMethod
|
* testSetProvider
|
||||||
*
|
*
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testUnallowedMethod()
|
public function testSetProvider()
|
||||||
{
|
{
|
||||||
$this->expectException(RuntimeException::class);
|
|
||||||
|
|
||||||
$web3 = $this->web3;
|
$web3 = $this->web3;
|
||||||
|
$requestManager = new HttpRequestManager('http://localhost:8545');
|
||||||
|
$web3->provider = new HttpProvider($requestManager);
|
||||||
|
|
||||||
$web3->hello(function ($err, $hello) {
|
$this->assertEquals($web3->provider->requestManager->host, 'http://localhost:8545');
|
||||||
if ($err !== null) {
|
|
||||||
return $this->fail($err->getMessage());
|
|
||||||
}
|
|
||||||
if (isset($hello->result)) {
|
|
||||||
$this->assertTrue(true);
|
|
||||||
} else {
|
|
||||||
$this->fail($hello->error->message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user