Add TransactionFormatter test.
This commit is contained in:
parent
200f8cbb78
commit
b9f37af5c1
75
test/unit/TransactionFormatterTest.php
Normal file
75
test/unit/TransactionFormatterTest.php
Normal file
@ -0,0 +1,75 @@
|
||||
<?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'
|
||||
]);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user