123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- <?php
- namespace Test\Unit;
- use Test\TestCase;
- use Web3\Formatters\TransactionFormatter;
- class TransactionFormatterTest extends TestCase
- {
- /**
- * formatter
- *
- * @var \Web3\Formatters\TransactionFormatter
- */
- protected $formatter;
- /**
- * setUp
- *
- * @return void
- */
- public function setUp()
- {
- parent::setUp();
- $this->formatter = new TransactionFormatter;
- }
- /**
- * testFormat
- *
- * @return void
- */
- public function testFormat()
- {
- $formatter = $this->formatter;
- $transaction = $formatter->format([
- 'from' => '0xb60e8dd61c5d32be8058bb8eb970870f07233155',
- 'to' => '0xd46e8dd67c5d32be8058bb8eb970870f07244567',
- 'gas' => '0x76c0',
- 'gasPrice' => '0x9184e72a000',
- 'value' => '0x9184e72a',
- 'data' => '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675',
- 'nonce' => '0x1'
- ]);
- $this->assertEquals($transaction, [
- 'from' => '0xb60e8dd61c5d32be8058bb8eb970870f07233155',
- 'to' => '0xd46e8dd67c5d32be8058bb8eb970870f07244567',
- 'gas' => '0x76c0',
- 'gasPrice' => '0x9184e72a000',
- 'value' => '0x9184e72a',
- 'data' => '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675',
- 'nonce' => '0x1'
- ]);
- $transaction = $formatter->format([
- 'from' => '0xb60e8dd61c5d32be8058bb8eb970870f07233155',
- 'to' => '0xd46e8dd67c5d32be8058bb8eb970870f07244567',
- 'gas' => 21000,
- 'gasPrice' => 21000,
- 'value' => 100000000,
- 'data' => '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675',
- 'nonce' => '0x1'
- ]);
- $this->assertEquals($transaction, [
- 'from' => '0xb60e8dd61c5d32be8058bb8eb970870f07233155',
- 'to' => '0xd46e8dd67c5d32be8058bb8eb970870f07244567',
- 'gas' => '0x5208',
- 'gasPrice' => '0x5208',
- 'value' => '0x5f5e100',
- 'data' => '0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675',
- 'nonce' => '0x1'
- ]);
- }
- }
|