commit
8bb149a2e3
@ -1,9 +1,15 @@
|
||||
sudo: required
|
||||
|
||||
language: php
|
||||
|
||||
php:
|
||||
- 7.1
|
||||
|
||||
before_install:
|
||||
- nvm install 8
|
||||
|
||||
install:
|
||||
- npm install -g ganache-cli
|
||||
- composer install
|
||||
|
||||
notifications:
|
||||
@ -14,7 +20,7 @@ notifications:
|
||||
on_failure: always
|
||||
|
||||
script:
|
||||
- vendor/bin/phpunit --coverage-clover=coverage.xml
|
||||
- scripts/test.sh
|
||||
|
||||
after_success:
|
||||
- bash <(curl -s https://codecov.io/bash) -t 8436848f-9a99-4b49-be60-629d7ff9a62c
|
10
scripts/test.sh
Executable file
10
scripts/test.sh
Executable file
@ -0,0 +1,10 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
ganache-cli -g 0 -l 0 > /dev/null &
|
||||
ganachecli_pid=$!
|
||||
echo "Start ganache-cli pid: $ganachecli_pid"
|
||||
|
||||
vendor/bin/phpunit --coverage-clover=coverage.xml
|
||||
|
||||
kill -9 $ganachecli_pid
|
||||
echo "Kill ganache-cli"
|
@ -243,7 +243,7 @@ class Contract
|
||||
}
|
||||
|
||||
/**
|
||||
* getAbr
|
||||
* getAbi
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
@ -252,6 +252,16 @@ class Contract
|
||||
return $this->abi;
|
||||
}
|
||||
|
||||
/**
|
||||
* getEthabi
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getEthabi()
|
||||
{
|
||||
return $this->ethabi;
|
||||
}
|
||||
|
||||
/**
|
||||
* getEth
|
||||
*
|
||||
|
@ -13,6 +13,7 @@ namespace Web3\Methods\Eth;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Web3\Methods\EthMethod;
|
||||
use Web3\Formatters\BigNumberFormatter;
|
||||
|
||||
class BlockNumber extends EthMethod
|
||||
{
|
||||
@ -35,7 +36,9 @@ class BlockNumber extends EthMethod
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $outputFormatters = [];
|
||||
protected $outputFormatters = [
|
||||
BigNumberFormatter::class
|
||||
];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
|
@ -13,6 +13,7 @@ namespace Web3\Methods\Eth;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Web3\Methods\EthMethod;
|
||||
use Web3\Formatters\BigNumberFormatter;
|
||||
|
||||
class GasPrice extends EthMethod
|
||||
{
|
||||
@ -35,7 +36,9 @@ class GasPrice extends EthMethod
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $outputFormatters = [];
|
||||
protected $outputFormatters = [
|
||||
BigNumberFormatter::class
|
||||
];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
|
@ -18,6 +18,7 @@ use Web3\Validators\QuantityValidator;
|
||||
use Web3\Validators\AddressValidator;
|
||||
use Web3\Formatters\AddressFormatter;
|
||||
use Web3\Formatters\OptionalQuantityFormatter;
|
||||
use Web3\Formatters\BigNumberFormatter;
|
||||
|
||||
class GetBalance extends EthMethod
|
||||
{
|
||||
@ -46,7 +47,9 @@ class GetBalance extends EthMethod
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $outputFormatters = [];
|
||||
protected $outputFormatters = [
|
||||
BigNumberFormatter::class
|
||||
];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
|
@ -15,6 +15,7 @@ use InvalidArgumentException;
|
||||
use Web3\Methods\EthMethod;
|
||||
use Web3\Validators\BlockHashValidator;
|
||||
use Web3\Formatters\HexFormatter;
|
||||
use Web3\Formatters\BigNumberFormatter;
|
||||
|
||||
class GetBlockTransactionCountByHash extends EthMethod
|
||||
{
|
||||
@ -41,7 +42,9 @@ class GetBlockTransactionCountByHash extends EthMethod
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $outputFormatters = [];
|
||||
protected $outputFormatters = [
|
||||
BignumberFormatter::class
|
||||
];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
|
@ -15,6 +15,7 @@ use InvalidArgumentException;
|
||||
use Web3\Methods\EthMethod;
|
||||
use Web3\Validators\QuantityValidator;
|
||||
use Web3\Formatters\OptionalQuantityFormatter;
|
||||
use Web3\Formatters\BigNumberFormatter;
|
||||
|
||||
class GetBlockTransactionCountByNumber extends EthMethod
|
||||
{
|
||||
@ -41,7 +42,9 @@ class GetBlockTransactionCountByNumber extends EthMethod
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $outputFormatters = [];
|
||||
protected $outputFormatters = [
|
||||
BigNumberFormatter::class
|
||||
];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
|
@ -18,6 +18,7 @@ use Web3\Validators\QuantityValidator;
|
||||
use Web3\Validators\AddressValidator;
|
||||
use Web3\Formatters\AddressFormatter;
|
||||
use Web3\Formatters\OptionalQuantityFormatter;
|
||||
use Web3\Formatters\BigNumberFormatter;
|
||||
|
||||
class GetTransactionCount extends EthMethod
|
||||
{
|
||||
@ -46,7 +47,9 @@ class GetTransactionCount extends EthMethod
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $outputFormatters = [];
|
||||
protected $outputFormatters = [
|
||||
BigNumberFormatter::class
|
||||
];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
|
@ -15,6 +15,7 @@ use InvalidArgumentException;
|
||||
use Web3\Methods\EthMethod;
|
||||
use Web3\Validators\BlockHashValidator;
|
||||
use Web3\Formatters\HexFormatter;
|
||||
use Web3\Formatters\BigNumberFormatter;
|
||||
|
||||
class GetUncleCountByBlockHash extends EthMethod
|
||||
{
|
||||
@ -41,7 +42,9 @@ class GetUncleCountByBlockHash extends EthMethod
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $outputFormatters = [];
|
||||
protected $outputFormatters = [
|
||||
BigNumberFormatter::class
|
||||
];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
|
@ -16,6 +16,7 @@ use Web3\Methods\EthMethod;
|
||||
use Web3\Validators\TagValidator;
|
||||
use Web3\Validators\QuantityValidator;
|
||||
use Web3\Formatters\OptionalQuantityFormatter;
|
||||
use Web3\Formatters\BigNumberFormatter;
|
||||
|
||||
class GetUncleCountByBlockNumber extends EthMethod
|
||||
{
|
||||
@ -44,7 +45,9 @@ class GetUncleCountByBlockNumber extends EthMethod
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $outputFormatters = [];
|
||||
protected $outputFormatters = [
|
||||
BigNumberFormatter::class
|
||||
];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
|
@ -13,6 +13,7 @@ namespace Web3\Methods\Eth;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use Web3\Methods\EthMethod;
|
||||
use Web3\Formatters\BigNumberFormatter;
|
||||
|
||||
class Hashrate extends EthMethod
|
||||
{
|
||||
@ -35,7 +36,9 @@ class Hashrate extends EthMethod
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $outputFormatters = [];
|
||||
protected $outputFormatters = [
|
||||
BigNumberFormatter::class
|
||||
];
|
||||
|
||||
/**
|
||||
* defaultValues
|
||||
|
@ -21,6 +21,20 @@ class TestCase extends BaseTestCase
|
||||
*/
|
||||
protected $testRinkebyHost = 'https://rinkeby.infura.io/vuethexplore';
|
||||
|
||||
/**
|
||||
* testHost
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $testHost = 'http://localhost:8545';
|
||||
|
||||
/**
|
||||
* coinbase
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $coinbase;
|
||||
|
||||
/**
|
||||
* setUp
|
||||
*
|
||||
@ -28,8 +42,15 @@ class TestCase extends BaseTestCase
|
||||
*/
|
||||
public function setUp()
|
||||
{
|
||||
$web3 = new Web3($this->testRinkebyHost);
|
||||
$web3 = new Web3($this->testHost);
|
||||
$this->web3 = $web3;
|
||||
|
||||
$web3->eth->coinbase(function ($err, $coinbase) {
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->coinbase = $coinbase;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -304,7 +304,6 @@ class ContractTest extends TestCase
|
||||
{
|
||||
parent::setUp();
|
||||
|
||||
// $this->contract = new Contract('http://localhost:8545', $this->testAbi);
|
||||
$this->contract = new Contract($this->web3->provider, $this->testAbi);
|
||||
$this->contract->eth->accounts(function ($err, $accounts) {
|
||||
if ($err === null) {
|
||||
@ -417,7 +416,7 @@ class ContractTest extends TestCase
|
||||
$transactionId = $result;
|
||||
$this->assertTrue((preg_match('/^0x[a-f0-9]{64}$/', $transactionId) === 1));
|
||||
|
||||
$contract->eth->getTransactionReceipt($transactionId, function ($err, $transaction) use ($fromAccount, $toAccount) {
|
||||
$contract->eth->getTransactionReceipt($transactionId, function ($err, $transaction) use ($fromAccount, $toAccount, $contract) {
|
||||
if ($err !== null) {
|
||||
return $this->fail($err);
|
||||
}
|
||||
@ -426,7 +425,7 @@ class ContractTest extends TestCase
|
||||
echo "\nTransaction has mind:) block number: " . $transaction->blockNumber . "\n";
|
||||
|
||||
// validate topics
|
||||
$this->assertEquals(Ethabi::encodeEventSignature($this->contract->events['Transfer']), $topics[0]);
|
||||
$this->assertEquals($contract->ethabi->encodeEventSignature($this->contract->events['Transfer']), $topics[0]);
|
||||
$this->assertEquals('0x' . IntegerFormatter::format($fromAccount), $topics[1]);
|
||||
$this->assertEquals('0x' . IntegerFormatter::format($toAccount), $topics[2]);
|
||||
}
|
||||
|
@ -73,10 +73,9 @@ class EthApiTest extends TestCase
|
||||
|
||||
$eth->coinbase(function ($err, $coinbase) {
|
||||
if ($err !== null) {
|
||||
// infura banned us to use coinbase
|
||||
return $this->assertTrue($err->getCode() === 405);
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->assertTrue(is_string($coinbass));
|
||||
$this->assertEquals($coinbase, $this->coinbase);
|
||||
});
|
||||
}
|
||||
|
||||
@ -93,7 +92,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->assertTrue($mining !== null);
|
||||
$this->assertTrue($mining);
|
||||
});
|
||||
}
|
||||
|
||||
@ -110,7 +109,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->assertTrue(is_string($hashrate));
|
||||
$this->assertEquals($hashrate->toString(), '0');
|
||||
});
|
||||
}
|
||||
|
||||
@ -127,7 +126,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->assertTrue(is_string($gasPrice));
|
||||
$this->assertTrue(is_numeric($gasPrice->toString()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -161,7 +160,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->assertTrue(is_string($blockNumber));
|
||||
$this->assertTrue(is_numeric($blockNumber->toString()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -178,7 +177,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->assertTrue(is_string($balance));
|
||||
$this->assertTrue(is_numeric($balance->toString()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -191,7 +190,7 @@ class EthApiTest extends TestCase
|
||||
{
|
||||
$eth = $this->eth;
|
||||
|
||||
$eth->getStorageAt('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '0x0', function ($err, $storage) {
|
||||
$eth->getStorageAt('0x561a2aa10f9a8589c93665554c871106342f70af', '0x0', function ($err, $storage) {
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
@ -208,11 +207,11 @@ class EthApiTest extends TestCase
|
||||
{
|
||||
$eth = $this->eth;
|
||||
|
||||
$eth->getTransactionCount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', function ($err, $transactionCount) {
|
||||
$eth->getTransactionCount('0x561a2aa10f9a8589c93665554c871106342f70af', function ($err, $transactionCount) {
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->assertTrue(is_string($transactionCount));
|
||||
$this->assertTrue(is_numeric($transactionCount->toString()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -229,7 +228,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($transactionCount));
|
||||
$this->assertTrue(is_numeric($transactionCount->toString()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -246,7 +245,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($transactionCount));
|
||||
$this->assertTrue(is_numeric($transactionCount->toString()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -263,7 +262,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($uncleCount));
|
||||
$this->assertTrue(is_numeric($uncleCount->toString()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -280,7 +279,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($uncleCount));
|
||||
$this->assertTrue(is_numeric($uncleCount->toString()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -405,7 +404,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($gas));
|
||||
$this->assertTrue(is_numeric($gas->toString()));
|
||||
});
|
||||
}
|
||||
|
||||
@ -422,7 +421,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($block));
|
||||
$this->assertTrue($block !== null);
|
||||
});
|
||||
}
|
||||
|
||||
@ -457,7 +456,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($transaction));
|
||||
$this->assertTrue($transaction !== null);
|
||||
});
|
||||
}
|
||||
|
||||
@ -474,7 +473,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($transaction));
|
||||
$this->assertTrue($transaction !== null);
|
||||
});
|
||||
}
|
||||
|
||||
@ -491,7 +490,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($transaction));
|
||||
$this->assertTrue($transaction !== null);
|
||||
});
|
||||
}
|
||||
|
||||
@ -508,7 +507,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($transaction));
|
||||
$this->assertTrue($transaction !== null);
|
||||
});
|
||||
}
|
||||
|
||||
@ -525,7 +524,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($uncle));
|
||||
$this->assertTrue($uncle !== null);
|
||||
});
|
||||
}
|
||||
|
||||
@ -542,7 +541,7 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($uncle));
|
||||
$this->assertTrue($uncle !== null);
|
||||
});
|
||||
}
|
||||
|
||||
@ -559,7 +558,8 @@ class EthApiTest extends TestCase
|
||||
if ($err !== null) {
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($compilers));
|
||||
$this->assertTrue(is_array($compilers));
|
||||
$this->assertEquals($compilers[0], 'solidity');
|
||||
});
|
||||
}
|
||||
|
||||
@ -687,7 +687,7 @@ class EthApiTest extends TestCase
|
||||
// infura banned us to uninstall filter
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($filter));
|
||||
$this->assertTrue(is_bool($filter));
|
||||
});
|
||||
}
|
||||
|
||||
@ -700,12 +700,12 @@ class EthApiTest extends TestCase
|
||||
{
|
||||
$eth = $this->eth;
|
||||
|
||||
$eth->getFilterChanges('0x01', function ($err, $filter) {
|
||||
$eth->getFilterChanges('0x01', function ($err, $changes) {
|
||||
if ($err !== null) {
|
||||
// infura banned us to get filter changes
|
||||
return $this->assertTrue($err !== null);
|
||||
}
|
||||
$this->assertTrue(is_string($filter));
|
||||
$this->assertTrue(is_array($changes));
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -14,6 +14,13 @@ class PersonalApiTest extends TestCase
|
||||
*/
|
||||
protected $personal;
|
||||
|
||||
/**
|
||||
* newAccount
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $newAccount;
|
||||
|
||||
/**
|
||||
* setUp
|
||||
*
|
||||
@ -55,8 +62,7 @@ class PersonalApiTest extends TestCase
|
||||
|
||||
$personal->newAccount('123456', function ($err, $account) {
|
||||
if ($err !== null) {
|
||||
// infura banned us to use new account
|
||||
return $this->assertTrue($err->getCode() === 405);
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
$this->assertTrue(is_string($account));
|
||||
});
|
||||
@ -71,12 +77,21 @@ class PersonalApiTest extends TestCase
|
||||
{
|
||||
$personal = $this->personal;
|
||||
|
||||
$personal->unlockAccount('0x407d73d8a49eeb85d32cf465507dd71d507100c1', '123456', function ($err, $account) {
|
||||
// create account
|
||||
$personal->newAccount('123456', function ($err, $account) {
|
||||
if ($err !== null) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
$this->newAccount = $account;
|
||||
$this->assertTrue(is_string($account));
|
||||
});
|
||||
|
||||
$personal->unlockAccount($this->newAccount, '123456', function ($err, $unlocked) {
|
||||
if ($err !== null) {
|
||||
// infura banned us to use unlock account
|
||||
return $this->assertTrue($err->getCode() === 405);
|
||||
}
|
||||
$this->assertTrue(is_bool($account));
|
||||
$this->assertTrue($unlocked);
|
||||
});
|
||||
}
|
||||
|
||||
@ -89,19 +104,37 @@ class PersonalApiTest extends TestCase
|
||||
{
|
||||
$personal = $this->personal;
|
||||
|
||||
$personal->sendTransaction([
|
||||
'from' => "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
|
||||
'to' => "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
|
||||
'gas' => "0x76c0",
|
||||
'gasPrice' => "0x9184e72a000",
|
||||
'value' => "0x9184e72a",
|
||||
'data' => "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"
|
||||
], '123456', function ($err, $transaction) {
|
||||
// create account
|
||||
$personal->newAccount('123456', function ($err, $account) {
|
||||
if ($err !== null) {
|
||||
// infura banned us to use send transaction
|
||||
return $this->assertTrue($err->getCode() === 405);
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
$this->newAccount = $account;
|
||||
$this->assertTrue(is_string($account));
|
||||
});
|
||||
|
||||
$this->web3->eth->sendTransaction([
|
||||
'from' => $this->coinbase,
|
||||
'to' => $this->newAccount,
|
||||
'value' => '0xfffffffff',
|
||||
], function ($err, $transaction) {
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->assertTrue(is_string($transaction));
|
||||
$this->assertTrue(mb_strlen($transaction) === 66);
|
||||
});
|
||||
|
||||
$personal->sendTransaction([
|
||||
'from' => $this->newAccount,
|
||||
'to' => $this->coinbase,
|
||||
'value' => '0x01',
|
||||
], '123456', function ($err, $transaction) {
|
||||
if ($err !== null) {
|
||||
return $this->fail($err->getMessage());
|
||||
}
|
||||
$this->assertTrue(is_string($transaction));
|
||||
$this->assertTrue(mb_strlen($transaction) === 66);
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user