Compare commits

...

14 Commits

Author SHA1 Message Date
Peter Lai
cede0cc410
Merge pull request #264 from srdante/patch-1
Fix Test Caching
2022-03-06 20:41:49 -08:00
Dante
1d2581e78e
Update php.yml 2022-03-07 00:34:50 -03:00
Peter Lai
2eafffbbe5
Merge pull request #257 from cryptounifier/php-80-test-passing
Support PHP 8.0
2022-03-06 19:26:51 -08:00
Dante
cc7d01e7eb
Add Dockerfile-80 2022-02-26 03:44:06 -03:00
srdante
1d47285b8b Fix preg match & testings 2022-02-26 03:15:44 -03:00
srdante
7c46919e7d Bump composer dependencies 2022-02-26 02:48:12 -03:00
srdante
91f4d2c40b Set setUp() return type 2022-02-26 02:43:32 -03:00
Dante
2ae840f538
Update TestCase.php 2022-02-26 02:40:01 -03:00
Dante
217851c62d
Update php.yml 2022-02-26 02:33:59 -03:00
Dante
7eb8a46366
Update php.yml 2022-02-26 02:28:17 -03:00
Dante
dabb7262b5
Update composer.json 2022-02-26 02:27:56 -03:00
sc0Vu
bd40f1946a
Update package to web3p/web3.php 2022-01-15 00:26:41 +08:00
Peter Lai
fb94ea92c5
Merge pull request #205 from harensarma/patch-2
Removed space from versions of guzzlehttp
2021-08-14 20:28:10 -07:00
harensarma
199cb1d175
Removed space from versions of guzzlehttp
Removed space from versions of guzzlehttp, else second version was not working in laravel
2021-04-18 21:07:09 +05:30
58 changed files with 98 additions and 78 deletions

View File

@ -1,13 +1,13 @@
name: PHP name: PHP
on: ["push", "pull_request"] on: ["push", "pull_request", "workflow_dispatch"]
jobs: jobs:
build_and_test: build_and_test:
name: Build and test web3.php with ${{ matrix.php-version }} name: Build and test web3.php with ${{ matrix.php-version }}
strategy: strategy:
matrix: matrix:
php-version: ["7.3", "7.4"] php-version: ["7.3", "7.4", "8.0"]
runs-on: ubuntu-latest runs-on: ubuntu-latest
@ -37,9 +37,9 @@ jobs:
uses: actions/cache@v2 uses: actions/cache@v2
with: with:
path: vendor path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }} key: ${{ runner.os }}-php-${{ matrix.php-version }}-${{ hashFiles('**/composer.lock') }}
restore-keys: | restore-keys: |
${{ runner.os }}-php- ${{ runner.os }}-php-${{ matrix.php-version }}-
- name: Install dependencies - name: Install dependencies
if: steps.composer-cache.outputs.cache-hit != 'true' if: steps.composer-cache.outputs.cache-hit != 'true'

View File

@ -18,13 +18,13 @@ Set minimum stability to dev
Then Then
``` ```
composer require sc0vu/web3.php dev-master composer require web3p/web3.php dev-master
``` ```
Or you can add this line in composer.json Or you can add this line in composer.json
``` ```
"sc0vu/web3.php": "dev-master" "web3p/web3.php": "dev-master"
``` ```
@ -217,7 +217,7 @@ If you are using docker as development machain, you can try [ethdock](https://gi
1. Clone the repo and install packages. 1. Clone the repo and install packages.
``` ```
git clone https://github.com/sc0Vu/web3.php.git && cd web3.php && composer install git clone https://github.com/web3p/web3.php.git && cd web3.php && composer install
``` ```
2. Run test script. 2. Run test script.
@ -229,7 +229,7 @@ vendor/bin/phpunit
1. Clone the repo and run docker container. 1. Clone the repo and run docker container.
``` ```
git clone https://github.com/sc0Vu/web3.php.git git clone https://github.com/web3p/web3.php.git
``` ```
2. Copy web3.php to web3.php/docker/app directory and start container. 2. Copy web3.php to web3.php/docker/app directory and start container.

View File

@ -1,5 +1,5 @@
{ {
"name": "sc0vu/web3.php", "name": "web3p/web3.php",
"description": "Ethereum web3 interface.", "description": "Ethereum web3 interface.",
"type": "library", "type": "library",
"license": "MIT", "license": "MIT",
@ -11,13 +11,13 @@
], ],
"require": { "require": {
"guzzlehttp/guzzle": "^6.3|^7.0", "guzzlehttp/guzzle": "^6.3|^7.0",
"PHP": "^7.1", "PHP": "^7.2|^8.0",
"kornrunner/keccak": "~1.0", "kornrunner/keccak": "~1.0",
"phpseclib/phpseclib": "~2.0.11", "phpseclib/phpseclib": "~2.0.30",
"ext-mbstring": "*" "ext-mbstring": "*"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "~6.0" "phpunit/phpunit": "~8.0|~9.0"
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {

23
docker/php/Dockerfile-80 Normal file
View File

@ -0,0 +1,23 @@
FROM php:8.0-alpine
MAINTAINER Peter Lai <alk03073135@gmail.com>
COPY composer-setup.php composer-setup.php
# COPY php.ini-production $PHP_INI_DIR/php.ini
RUN apk update && \
apk add git
# Install gmp
Run apk add gmp-dev && \
docker-php-ext-install gmp
# Install nodejs
# Run apk add --update nodejs nodejs-npm
# Install composer
RUN php composer-setup.php && \
php composer-setup.php --install-dir=/usr/bin --filename=composer && \
php -r "unlink('composer-setup.php');"
WORKDIR /app

View File

@ -7,8 +7,7 @@
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="false">
syntaxCheck="false">
<testsuite name="Web3.php unit test"> <testsuite name="Web3.php unit test">
<directory suffix="Test.php">./test/unit</directory> <directory suffix="Test.php">./test/unit</directory>

View File

@ -529,7 +529,7 @@ class Utils
$number = str_replace('-', '', $number, $count); $number = str_replace('-', '', $number, $count);
$negative1 = new BigNumber(-1); $negative1 = new BigNumber(-1);
} }
if (self::isZeroPrefixed($number) || preg_match('/[a-f]+/', $number) === 1) { if (self::isZeroPrefixed($number) || preg_match('/^[0-9a-f]+$/i', $number) === 1) {
$number = self::stripZero($number); $number = self::stripZero($number);
$bn = new BigNumber($number, 16); $bn = new BigNumber($number, 16);
} elseif (empty($number)) { } elseif (empty($number)) {

View File

@ -37,10 +37,8 @@ class TestCase extends BaseTestCase
/** /**
* setUp * setUp
*
* @return void
*/ */
public function setUp() public function setUp(): void
{ {
$web3 = new Web3($this->testHost); $web3 = new Web3($this->testHost);
$this->web3 = $web3; $this->web3 = $web3;
@ -55,8 +53,6 @@ class TestCase extends BaseTestCase
/** /**
* tearDown * tearDown
*
* @return void
*/ */
public function tearDown() {} public function tearDown(): void {}
} }

View File

@ -19,7 +19,7 @@ class AddressFormatterTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->formatter = new AddressFormatter; $this->formatter = new AddressFormatter;

View File

@ -47,7 +47,7 @@ class AddressTypeTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->solidityType = new Address; $this->solidityType = new Address;

View File

@ -19,7 +19,7 @@ class AddressValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new AddressValidator; $this->validator = new AddressValidator;

View File

@ -20,7 +20,7 @@ class BigNumberFormatterTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->formatter = new BigNumberFormatter; $this->formatter = new BigNumberFormatter;

View File

@ -19,7 +19,7 @@ class BlockHashValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new BlockHashValidator; $this->validator = new BlockHashValidator;

View File

@ -20,7 +20,7 @@ class BooleanFormatterTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->formatter = new BooleanFormatter; $this->formatter = new BooleanFormatter;

View File

@ -47,7 +47,7 @@ class BooleanTypeTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->solidityType = new Boolean; $this->solidityType = new Boolean;

View File

@ -19,7 +19,7 @@ class BooleanValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new BooleanValidator; $this->validator = new BooleanValidator;

View File

@ -53,7 +53,7 @@ class BytesTypeTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->solidityType = new Bytes; $this->solidityType = new Bytes;

View File

@ -19,7 +19,7 @@ class CallValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new CallValidator; $this->validator = new CallValidator;

View File

@ -412,7 +412,7 @@ class ContractTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -53,7 +53,7 @@ class DynamicBytesTypeTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->solidityType = new DynamicBytes; $this->solidityType = new DynamicBytes;

View File

@ -21,7 +21,7 @@ class EthApiTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
@ -439,7 +439,7 @@ class EthApiTest extends TestCase
if ($err !== null) { if ($err !== null) {
return $this->assertTrue($err !== null); return $this->assertTrue($err !== null);
} }
// weired behavior, see https://github.com/sc0Vu/web3.php/issues/16 // weird behavior, see https://github.com/web3p/web3.php/issues/16
$this->assertTrue($block !== null); $this->assertTrue($block !== null);
}); });
} }

View File

@ -20,7 +20,7 @@ class EthBatchTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -23,7 +23,7 @@ class EthTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -163,7 +163,7 @@ class EthabiTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
// Error: Using $this when not in object context // Error: Using $this when not in object context
@ -298,7 +298,7 @@ class EthabiTest extends TestCase
/** /**
* testIssue71 * testIssue71
* test 33 bytes and 128 bytes string, see: https://github.com/sc0Vu/web3.php/issues/71 * test 33 bytes and 128 bytes string, see: https://github.com/web3p/web3.php/issues/71
* string generated from: https://www.lipsum.com/ * string generated from: https://www.lipsum.com/
* *
* @return void * @return void

View File

@ -19,7 +19,7 @@ class FilterValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new FilterValidator; $this->validator = new FilterValidator;

View File

@ -19,7 +19,7 @@ class HexFormatterTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->formatter = new HexFormatter; $this->formatter = new HexFormatter;

View File

@ -19,7 +19,7 @@ class HexValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new HexValidator; $this->validator = new HexValidator;

View File

@ -19,7 +19,7 @@ class IdentityValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new IdentityValidator; $this->validator = new IdentityValidator;

View File

@ -19,7 +19,7 @@ class IntegerFormatterTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->formatter = new IntegerFormatter; $this->formatter = new IntegerFormatter;

View File

@ -53,7 +53,7 @@ class IntegerTypeTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->solidityType = new Integer; $this->solidityType = new Integer;

View File

@ -21,7 +21,7 @@ class NetApiTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -20,7 +20,7 @@ class NetBatchTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -23,7 +23,7 @@ class NetTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -19,7 +19,7 @@ class NonceValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new NonceValidator; $this->validator = new NonceValidator;

View File

@ -19,7 +19,7 @@ class NumberFormatterTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->formatter = new NumberFormatter; $this->formatter = new NumberFormatter;

View File

@ -19,7 +19,7 @@ class OptionalQuantityFormatterTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->formatter = new OptionalQuantityFormatter; $this->formatter = new OptionalQuantityFormatter;
@ -55,6 +55,8 @@ class OptionalQuantityFormatterTest extends TestCase
$this->assertEquals('latest', $formatter->format('latest')); $this->assertEquals('latest', $formatter->format('latest'));
$this->assertEquals('earliest', $formatter->format('earliest')); $this->assertEquals('earliest', $formatter->format('earliest'));
$this->assertEquals('pending', $formatter->format('pending')); $this->assertEquals('pending', $formatter->format('pending'));
$this->assertEquals('0x0', $formatter->format('hello'));
$this->expectExceptionMessage('toBn number must be valid hex string.');
$formatter->format('hello');
} }
} }

View File

@ -27,7 +27,7 @@ class PersonalApiTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -19,7 +19,7 @@ class PersonalBatchTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -23,7 +23,7 @@ class PersonalTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -19,7 +19,7 @@ class PostFormatterTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->formatter = new PostFormatter; $this->formatter = new PostFormatter;

View File

@ -19,7 +19,7 @@ class PostValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new PostValidator; $this->validator = new PostValidator;

View File

@ -19,7 +19,7 @@ class QuantityFormatterTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->formatter = new QuantityFormatter; $this->formatter = new QuantityFormatter;

View File

@ -19,7 +19,7 @@ class QuantityValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new QuantityValidator; $this->validator = new QuantityValidator;

View File

@ -21,7 +21,7 @@ class ShhApiTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -19,7 +19,7 @@ class ShhBatchTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -19,7 +19,7 @@ class ShhFilterValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new ShhFilterValidator; $this->validator = new ShhFilterValidator;

View File

@ -23,7 +23,7 @@ class ShhTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();

View File

@ -20,7 +20,7 @@ class SolidityTypeTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->type = new SolidityType(); $this->type = new SolidityType();

View File

@ -47,7 +47,7 @@ class StrTypeTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->solidityType = new Str; $this->solidityType = new Str;

View File

@ -19,7 +19,7 @@ class StringFormatterTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->formatter = new StringFormatter; $this->formatter = new StringFormatter;

View File

@ -19,7 +19,7 @@ class StringValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new StringValidator; $this->validator = new StringValidator;

View File

@ -19,7 +19,7 @@ class TagValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new TagValidator; $this->validator = new TagValidator;

View File

@ -19,7 +19,7 @@ class TransactionFormatterTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->formatter = new TransactionFormatter; $this->formatter = new TransactionFormatter;

View File

@ -19,7 +19,7 @@ class TransactionValidatorTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->validator = new TransactionValidator; $this->validator = new TransactionValidator;

View File

@ -53,7 +53,7 @@ class UintegerTypeTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
$this->solidityType = new Uinteger; $this->solidityType = new Uinteger;

View File

@ -55,7 +55,7 @@ class UtilsTest extends TestCase
/** /**
* testIssue112Json * testIssue112Json
* see: https://github.com/sc0Vu/web3.php/issues/112 * see: https://github.com/web3p/web3.php/issues/112
* *
* @var string * @var string
*/ */
@ -137,7 +137,7 @@ class UtilsTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
} }

View File

@ -29,7 +29,7 @@ class Web3ApiTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
} }

View File

@ -28,7 +28,7 @@ class Web3BatchTest extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
} }

View File

@ -37,7 +37,7 @@ class Web3Test extends TestCase
* *
* @return void * @return void
*/ */
public function setUp() public function setUp(): void
{ {
parent::setUp(); parent::setUp();
} }