Ethereum PHP
PHP interface to Ethereum JSON-RPC API.
EthD32Test.php
Go to the documentation of this file.
1 <?php
2 namespace Ethereum;
4 
10 class EthD32Test extends TestStatic
11 {
16  public function testEthD32__simple()
17  {
18 
19  $x = new EthD32('0xf79e7980a566fec5caf9cf368abb227e537999998541bad324f61cf2906fbacd');
20  $this->assertSame($x->val(), 'f79e7980a566fec5caf9cf368abb227e537999998541bad324f61cf2906fbacd');
21  $this->assertSame($x->hexVal(), '0xf79e7980a566fec5caf9cf368abb227e537999998541bad324f61cf2906fbacd');
22  $this->assertSame($x->getSchemaType(), "D32");
23  }
24 
25  // Made to Fail.
27  {
28  try {
29  new EthD32('0xf79e7980a566fec5caf9cf368abb227e537999998541bad324f61cf2906fbacd86');
30  $this->fail("Expected exception '" . $exception_message_expected . "' not thrown");
31  } catch (\Exception $exception) {
32  $this->assertTrue(strpos($exception->getMessage(), "Invalid length") !== false);
33  }
34  }
35 
36  public function testEthQ__notHexPrefixed()
37  {
38  $a = new EthD32('f79e7980a566fec5caf9cf368abb227e537999998541bad324f61cf2906fbacd');
39  $this->assertEquals($a->hexVal(), '0xf79e7980a566fec5caf9cf368abb227e537999998541bad324f61cf2906fbacd');
40  }
41 
42  public function testEthQ__notHex()
43  {
44  try {
45  $val = '0xyz116b6e1a6e963efffa30c0a8541075cc51c45';
46  $exception_message_expected = 'A non well formed hex value encountered: ' . $val;
47  new EthD32($val);
48  $this->fail("Expected exception '" . $exception_message_expected . "' not thrown");
49  } catch (\Exception $exception) {
50  $this->assertEquals($exception->getMessage(), $exception_message_expected);
51  }
52  }
53 }
Definition: Abi.php:3