From fa9565043781dc8100f22c084a2ac322cda1dd9b Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Wed, 25 Apr 2018 10:06:30 +0800 Subject: [PATCH 1/2] Update composer.json --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index e503022..6e26cd3 100644 --- a/composer.json +++ b/composer.json @@ -13,7 +13,7 @@ "guzzlehttp/guzzle": "~6.0", "PHP": "^7.1", "kornrunner/keccak": "~1.0", - "phpseclib/phpseclib": "~2.0" + "phpseclib/phpseclib": "~2.0.11" }, "require-dev": { "phpunit/phpunit": "~6.0" From a87010fc4c97bed82e4fdecf965cbd7fad7d64d8 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Wed, 25 Apr 2018 10:07:06 +0800 Subject: [PATCH 2/2] Add test Add test for toHex(48), thanks @refear99 --- test/unit/HttpProviderTest.php | 4 ++-- test/unit/IntegerFormatterTest.php | 6 ++++++ test/unit/UtilsTest.php | 10 ++++++++++ 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/test/unit/HttpProviderTest.php b/test/unit/HttpProviderTest.php index 3a28bf2..f1ef4bf 100644 --- a/test/unit/HttpProviderTest.php +++ b/test/unit/HttpProviderTest.php @@ -17,7 +17,7 @@ class HttpProviderTest extends TestCase */ public function testSend() { - $requestManager = new HttpRequestManager('http://localhost:8545'); + $requestManager = new HttpRequestManager($this->testHost); $provider = new HttpProvider($requestManager); $method = new ClientVersion('web3_clientVersion', []); @@ -36,7 +36,7 @@ class HttpProviderTest extends TestCase */ public function testBatch() { - $requestManager = new HttpRequestManager('http://localhost:8545'); + $requestManager = new HttpRequestManager($this->testHost); $provider = new HttpProvider($requestManager); $method = new ClientVersion('web3_clientVersion', []); $callback = function ($err, $data) { diff --git a/test/unit/IntegerFormatterTest.php b/test/unit/IntegerFormatterTest.php index 193e19d..1476f64 100644 --- a/test/unit/IntegerFormatterTest.php +++ b/test/unit/IntegerFormatterTest.php @@ -45,5 +45,11 @@ class IntegerFormatterTest extends TestCase $hex = $formatter->format('1', 20); $this->assertEquals($hex, implode('', array_fill(0, 19, '0')) . '1'); + + $hex = $formatter->format(48); + $this->assertEquals($hex, implode('', array_fill(0, 62, '0')) . '30'); + + $hex = $formatter->format('48'); + $this->assertEquals($hex, implode('', array_fill(0, 62, '0')) . '30'); } } \ No newline at end of file diff --git a/test/unit/UtilsTest.php b/test/unit/UtilsTest.php index 50b3f0e..5856b22 100644 --- a/test/unit/UtilsTest.php +++ b/test/unit/UtilsTest.php @@ -87,6 +87,16 @@ class UtilsTest extends TestCase $this->assertEquals('0x', Utils::toHex(0, true)); $this->assertEquals('0x', Utils::toHex(new BigNumber(0), true)); + $this->assertEquals('0x30', Utils::toHex(48, true)); + $this->assertEquals('0x30', Utils::toHex('48', true)); + $this->assertEquals('30', Utils::toHex(48)); + $this->assertEquals('30', Utils::toHex('48')); + + $this->assertEquals('0x30', Utils::toHex(new BigNumber(48), true)); + $this->assertEquals('0x30', Utils::toHex(new BigNumber('48'), true)); + $this->assertEquals('30', Utils::toHex(new BigNumber(48))); + $this->assertEquals('30', Utils::toHex(new BigNumber('48'))); + $this->expectException(InvalidArgumentException::class); $hex = Utils::toHex(new stdClass); }