From 6f28fc79dcb5274fda6c667c30630a7e683f49e0 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Wed, 13 Dec 2017 23:15:57 +0800 Subject: [PATCH] eth_getCode --- src/Eth.php | 12 ++++++++++++ test/unit/EthTest.php | 21 +++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/src/Eth.php b/src/Eth.php index b47bb7d..621787e 100644 --- a/src/Eth.php +++ b/src/Eth.php @@ -106,6 +106,18 @@ class Eth ] ] ], + 'eth_getCode' => [ + 'params'=> [ + [ + 'validators' => AddressValidator::class, + ], [ + 'default' => 'latest', + 'validators' => [ + TagValidator::class, QuantityValidator::class, + ] + ], + ] + ], ]; /** diff --git a/test/unit/EthTest.php b/test/unit/EthTest.php index 0bf8f7b..a100ef7 100644 --- a/test/unit/EthTest.php +++ b/test/unit/EthTest.php @@ -362,6 +362,27 @@ class EthTest extends TestCase }); } + /** + * testGetCode + * + * @return void + */ + public function testGetCode() + { + $eth = $this->web3->eth; + + $eth->getCode('0x407d73d8a49eeb85d32cf465507dd71d507100c1', function ($err, $code) { + if ($err !== null) { + return $this->fail($err->getMessage()); + } + if (isset($code->result)) { + $this->assertTrue(is_string($code->result)); + } else { + $this->fail($code->error->message); + } + }); + } + /** * testUnallowedMethod *