From b9f37af5c1d164c180b87d44cbcca2ad0dca3080 Mon Sep 17 00:00:00 2001 From: sc0Vu Date: Wed, 7 Feb 2018 17:32:25 +0800 Subject: [PATCH] Add TransactionFormatter test. --- test/unit/TransactionFormatterTest.php | 75 ++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 test/unit/TransactionFormatterTest.php diff --git a/test/unit/TransactionFormatterTest.php b/test/unit/TransactionFormatterTest.php new file mode 100644 index 0000000..be1809f --- /dev/null +++ b/test/unit/TransactionFormatterTest.php @@ -0,0 +1,75 @@ +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' + ]); + } +} \ No newline at end of file