From 33d751edaa339bca5a33ee873d2f00453dd0545a Mon Sep 17 00:00:00 2001 From: Dario Rekowski on RockPI Date: Wed, 14 Apr 2021 14:10:16 +0000 Subject: [PATCH] replace hex values with hex strings to work correct with php --- .../tests/Fixture/BaseTestFixture.php | 11 +++++++-- .../tests/Fixture/StateBalancesFixture.php | 19 ++++----------- .../tests/Fixture/StateUsersFixture.php | 7 +++--- .../Fixture/TransactionCreationsFixture.php | 4 ++-- .../Fixture/TransactionSendCoinsFixture.php | 12 +++++----- .../Fixture/TransactionSignaturesFixture.php | 24 +++++++++---------- .../tests/Fixture/TransactionsFixture.php | 16 ++++++------- 7 files changed, 45 insertions(+), 48 deletions(-) diff --git a/community_server/tests/Fixture/BaseTestFixture.php b/community_server/tests/Fixture/BaseTestFixture.php index 3590a2503..1f63aa55e 100644 --- a/community_server/tests/Fixture/BaseTestFixture.php +++ b/community_server/tests/Fixture/BaseTestFixture.php @@ -12,7 +12,8 @@ use Cake\TestSuite\Fixture\TestFixture; class BaseTestFixture extends TestFixture { - + // after copy from sql export, replace all hex values to hex strings with regExp (z.B. within Netbeans) + // 0x([0-9a-f]*) => '$1' protected function sqlEntrysToRecords($sql_entries, $fields) { $field_array_keys = array_keys($fields); $records = []; @@ -20,7 +21,13 @@ class BaseTestFixture extends TestFixture $record = []; foreach($sql_entry as $i => $value) { $field = $field_array_keys[$i]; - $record[$field] = $value; + if($fields[$field]['type'] == 'binary') { + if(is_string($value)) { + $record[$field] = hex2bin($value); + } + } else { + $record[$field] = $value; + } } $records[] = $record; } diff --git a/community_server/tests/Fixture/StateBalancesFixture.php b/community_server/tests/Fixture/StateBalancesFixture.php index 64118f3ed..f4a6fd7fc 100644 --- a/community_server/tests/Fixture/StateBalancesFixture.php +++ b/community_server/tests/Fixture/StateBalancesFixture.php @@ -15,16 +15,17 @@ class StateBalancesFixture extends TestFixture */ // @codingStandardsIgnoreStart public $fields = [ - 'id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => true], - 'state_user_id' => ['type' => 'integer', 'length' => 11, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], + 'id' => ['type' => 'integer', 'length' => 10, 'unsigned' => true, 'null' => false, 'default' => null, 'comment' => '', 'autoIncrement' => true, 'precision' => null], + 'state_user_id' => ['type' => 'integer', 'length' => 10, 'unsigned' => true, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], 'modified' => ['type' => 'datetime', 'length' => null, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null], + 'record_date' => ['type' => 'datetime', 'length' => null, 'null' => true, 'default' => null, 'comment' => '', 'precision' => null], 'amount' => ['type' => 'biginteger', 'length' => 20, 'unsigned' => false, 'null' => false, 'default' => null, 'comment' => '', 'precision' => null, 'autoIncrement' => null], '_constraints' => [ 'primary' => ['type' => 'primary', 'columns' => ['id'], 'length' => []], ], '_options' => [ 'engine' => 'InnoDB', - 'collation' => 'utf8_bin' + 'collation' => 'utf8mb4_unicode_ci' ], ]; // @codingStandardsIgnoreEnd @@ -36,18 +37,6 @@ class StateBalancesFixture extends TestFixture public function init() { $this->records = [ - [ - 'id' => 1, - 'state_user_id' => 1, - 'modified' => '2019-11-05 18:02:28', - 'amount' => 1200 - ], - [ - 'id' => 10, - 'state_user_id' => 4, - 'modified' => '2019-11-11 14:58:54', - 'amount' => 1200000 - ] ]; parent::init(); } diff --git a/community_server/tests/Fixture/StateUsersFixture.php b/community_server/tests/Fixture/StateUsersFixture.php index 80da262db..344296da4 100644 --- a/community_server/tests/Fixture/StateUsersFixture.php +++ b/community_server/tests/Fixture/StateUsersFixture.php @@ -44,11 +44,12 @@ class StateUsersFixture extends BaseTestFixture public function init() { $sql_entrys = [ - [1, 0, 0, 0xf7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f, 'test1.gmail.de', 'Max', 'Mustermann', NULL, 0], - [3, 0, 0, 0x131c7f68dd94b2be4c913400ff7ff4cdc03ac2bda99c2d29edcacb3b065c67e6, 'test2.gmail.com', 'Ines', 'Mustermann', NULL, 0], - [4, 0, 0, 0xe3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2, 'test3.yahoo.com', 'Samuel', 'Schmied', NULL, 0] + [1, 0, 0, 'f7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f', 'test1.gmail.de', 'Max', 'Mustermann', NULL, 0], + [3, 0, 0, '131c7f68dd94b2be4c913400ff7ff4cdc03ac2bda99c2d29edcacb3b065c67e6', 'test2.gmail.com', 'Ines', 'Mustermann', NULL, 0], + [4, 0, 0, 'e3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2', 'test3.yahoo.com', 'Samuel', 'Schmied', NULL, 0] ]; $this->records = $this->sqlEntrysToRecords($sql_entrys, $this->fields); + echo bin2hex($this->records[0]['public_key']) . "\n"; parent::init(); } } diff --git a/community_server/tests/Fixture/TransactionCreationsFixture.php b/community_server/tests/Fixture/TransactionCreationsFixture.php index f0627d89e..1833385b4 100644 --- a/community_server/tests/Fixture/TransactionCreationsFixture.php +++ b/community_server/tests/Fixture/TransactionCreationsFixture.php @@ -38,8 +38,8 @@ class TransactionCreationsFixture extends BaseTestFixture public function init() { $sql = [ - [2, 1, 4, 10000000, 0x0000000000000000000000000000000000000000000000000000000000000000, '2021-01-01 00:00:00'], - [3, 2, 1, 10000000, 0x0000000000000000000000000000000000000000000000000000000000000000, '2021-01-01 00:00:00'] + [2, 1, 4, 10000000, '0000000000000000000000000000000000000000000000000000000000000000', '2021-01-01 00:00:00'], + [3, 2, 1, 10000000, '0000000000000000000000000000000000000000000000000000000000000000', '2021-01-01 00:00:00'] ]; $this->records = $this->sqlEntrysToRecords($sql, $this->fields); parent::init(); diff --git a/community_server/tests/Fixture/TransactionSendCoinsFixture.php b/community_server/tests/Fixture/TransactionSendCoinsFixture.php index fb9b30db3..a109dfd7f 100644 --- a/community_server/tests/Fixture/TransactionSendCoinsFixture.php +++ b/community_server/tests/Fixture/TransactionSendCoinsFixture.php @@ -40,12 +40,12 @@ class TransactionSendCoinsFixture extends BaseTestFixture public function init() { $sql = [ - [2, 3, 0x0000000000000000000000000000000000000000000000000000000000000000, 1, 0xe3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2, 4, 1000000, 6254699], - [3, 4, 0x0000000000000000000000000000000000000000000000000000000000000000, 1, 0xe3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2, 4, 100000, 7027197], - [11, 5, 0x0000000000000000000000000000000000000000000000000000000000000000, 1, 0xe3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2, 4, 100000, 6922113], - [12, 6, 0x0000000000000000000000000000000000000000000000000000000000000000, 4, 0xf7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f, 1, 100000, 9212951], - [13, 7, 0x0000000000000000000000000000000000000000000000000000000000000000, 4, 0xf7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f, 1, 100000, 9112627], - [14, 8, 0x0000000000000000000000000000000000000000000000000000000000000000, 4, 0xf7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f, 1, 100000, 8912594] + [2, 3, '0000000000000000000000000000000000000000000000000000000000000000', 1, 'e3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2', 4, 1000000, 6254699], + [3, 4, '0000000000000000000000000000000000000000000000000000000000000000', 1, 'e3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2', 4, 100000, 7027197], + [11, 5, '0000000000000000000000000000000000000000000000000000000000000000', 1, 'e3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2', 4, 100000, 6922113], + [12, 6, '0000000000000000000000000000000000000000000000000000000000000000', 4, 'f7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f', 1, 100000, 9212951], + [13, 7, '0000000000000000000000000000000000000000000000000000000000000000', 4, 'f7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f', 1, 100000, 9112627], + [14, 8, '0000000000000000000000000000000000000000000000000000000000000000', 4, 'f7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f', 1, 100000, 8912594] ]; $this->records = $this->sqlEntrysToRecords($sql, $this->fields); diff --git a/community_server/tests/Fixture/TransactionSignaturesFixture.php b/community_server/tests/Fixture/TransactionSignaturesFixture.php index c848461e1..9f7476fea 100644 --- a/community_server/tests/Fixture/TransactionSignaturesFixture.php +++ b/community_server/tests/Fixture/TransactionSignaturesFixture.php @@ -35,34 +35,34 @@ class TransactionSignaturesFixture extends TestFixture */ public function init() { - // (1, 1, 0x911b173577261c8b971b4e6ca56b5125ebd5155de8176ce35f9c95ae6929edf3f1e3095d29b37c8bc7cc2478981a41d8cdd3e5398a2c7aa7c691bd486836b705, 0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355), - // (2, 2, 0x01e76b14190fa14cb5839d1129b04c4043e691895541b16ae1b54c6b3206d7933def3c58ebf195bc67a7cd5773554636c55fe5e7ddb0c81fb247c24761f8120f, 0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355), - // (3, 3, 0x2b8c56cac8993f445a8b41ab6e86a486faa18c1e945df1c0acce2bcb342b96d36c5fcb7e687c97cc89790a386241d4b911e8f7949a2da64eef290c5380fc8602, 0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355), - // (4, 4, 0xcb0e9f83b847f630cc6831d62aca8fbfa971af458a12389d7e43abb5bb0936b8e35dbc5b1d641eb2f793e253eb0b149a809860a69897bfe86ba4bfd178da8102, 0xcccb338e003d2abb92178fc4302d1ab83f66b27d9c7e5b6b3ac91e0c23922088); + // (1, 1, '911b173577261c8b971b4e6ca56b5125ebd5155de8176ce35f9c95ae6929edf3f1e3095d29b37c8bc7cc2478981a41d8cdd3e5398a2c7aa7c691bd486836b705', '80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355'), + // (2, 2, '01e76b14190fa14cb5839d1129b04c4043e691895541b16ae1b54c6b3206d7933def3c58ebf195bc67a7cd5773554636c55fe5e7ddb0c81fb247c24761f8120f', '80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355'), + // (3, 3, '2b8c56cac8993f445a8b41ab6e86a486faa18c1e945df1c0acce2bcb342b96d36c5fcb7e687c97cc89790a386241d4b911e8f7949a2da64eef290c5380fc8602', '80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355'), + // (4, 4, 'cb0e9f83b847f630cc6831d62aca8fbfa971af458a12389d7e43abb5bb0936b8e35dbc5b1d641eb2f793e253eb0b149a809860a69897bfe86ba4bfd178da8102', 'cccb338e003d2abb92178fc4302d1ab83f66b27d9c7e5b6b3ac91e0c23922088'); $this->records = [ [ 'id' => 1, 'transaction_id' => 1, - 'signature' => '0x911b173577261c8b971b4e6ca56b5125ebd5155de8176ce35f9c95ae6929edf3f1e3095d29b37c8bc7cc2478981a41d8cdd3e5398a2c7aa7c691bd486836b705', - 'pubkey' => '0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355' + 'signature' => ''911b173577261c8b971b4e6ca56b5125ebd5155de8176ce35f9c95ae6929edf3f1e3095d29b37c8bc7cc2478981a41d8cdd3e5398a2c7aa7c691bd486836b705'', + 'pubkey' => ''80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355'' ], [ 'id' => 2, 'transaction_id' => 2, - 'signature' => '0x01e76b14190fa14cb5839d1129b04c4043e691895541b16ae1b54c6b3206d7933def3c58ebf195bc67a7cd5773554636c55fe5e7ddb0c81fb247c24761f8120f', - 'pubkey' => '0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355' + 'signature' => ''01e76b14190fa14cb5839d1129b04c4043e691895541b16ae1b54c6b3206d7933def3c58ebf195bc67a7cd5773554636c55fe5e7ddb0c81fb247c24761f8120f'', + 'pubkey' => ''80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355'' ], [ 'id' => 3, 'transaction_id' => 3, - 'signature' => '0x2b8c56cac8993f445a8b41ab6e86a486faa18c1e945df1c0acce2bcb342b96d36c5fcb7e687c97cc89790a386241d4b911e8f7949a2da64eef290c5380fc8602', - 'pubkey' => '0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355' + 'signature' => ''2b8c56cac8993f445a8b41ab6e86a486faa18c1e945df1c0acce2bcb342b96d36c5fcb7e687c97cc89790a386241d4b911e8f7949a2da64eef290c5380fc8602'', + 'pubkey' => ''80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355'' ], [ 'id' => 4, 'transaction_id' => 4, - 'signature' => '0xcb0e9f83b847f630cc6831d62aca8fbfa971af458a12389d7e43abb5bb0936b8e35dbc5b1d641eb2f793e253eb0b149a809860a69897bfe86ba4bfd178da8102', - 'pubkey' => '0xcccb338e003d2abb92178fc4302d1ab83f66b27d9c7e5b6b3ac91e0c23922088' + 'signature' => ''cb0e9f83b847f630cc6831d62aca8fbfa971af458a12389d7e43abb5bb0936b8e35dbc5b1d641eb2f793e253eb0b149a809860a69897bfe86ba4bfd178da8102'', + 'pubkey' => ''cccb338e003d2abb92178fc4302d1ab83f66b27d9c7e5b6b3ac91e0c23922088'' ], ]; parent::init(); diff --git a/community_server/tests/Fixture/TransactionsFixture.php b/community_server/tests/Fixture/TransactionsFixture.php index 041aa834b..befafc16b 100644 --- a/community_server/tests/Fixture/TransactionsFixture.php +++ b/community_server/tests/Fixture/TransactionsFixture.php @@ -39,14 +39,14 @@ class TransactionsFixture extends BaseTestFixture public function init() { $sql = [ - [1, NULL, 1, 0x15f242a7bb92a7db82678e0baf5ec1734c038ac0dc7b19e6d1ebbcf92a6cf3ad00000000000000000000000000000000, 'AGE Januar 2021', '2021-04-09 00:00:00', 1], - [2, NULL, 1, 0xf932eca7686802d1697773fea713a3c6a3e3dace8b5aa552dd8503d50ce349f500000000000000000000000000000000, 'AGE Januar 2021', '2021-04-12 00:00:00', 1], - [3, NULL, 2, 0x4e2235f208edaf5cbb285955732022a625cf1e100eb629c56896d2fbfb8b34e800000000000000000000000000000000, 'test', '2021-04-12 00:00:00', 1], - [4, NULL, 2, 0xfc6e69696beb7c56ad7c511fc3999f954411427bec810184b70c092911deae1900000000000000000000000000000000, 'test time', '2021-04-14 00:00:00', 1], - [5, NULL, 2, 0xa7149ebc0d6cd8c061906dafe05e13689b51642a41100d0ec7bb6cd2dcafdc1800000000000000000000000000000000, 'test time', '2021-04-14 09:01:07', 1], - [6, NULL, 2, 0x2e3c3ab3e42c06f2ecb12f61c970712467d8ad9ddfa16fa58dd76492e5924b7d00000000000000000000000000000000, 'test time 3', '2021-04-14 09:02:28', 1], - [7, NULL, 2, 0xc2c6354d77ff371daeee25fce9c947748b53d3d6b8398a92bd681923cfd2057100000000000000000000000000000000, 'test login crash', '2021-04-14 09:28:46', 1], - [8, NULL, 2, 0x5a8cbf1aaac06b00b2951ff39983cb2ca9a1e6710d72c8e5067278dc679a823100000000000000000000000000000000, 'test login crash', '2021-04-14 09:31:28', 1] + [1, NULL, 1, '15f242a7bb92a7db82678e0baf5ec1734c038ac0dc7b19e6d1ebbcf92a6cf3ad00000000000000000000000000000000', 'AGE Januar 2021', '2021-04-09 00:00:00', 1], + [2, NULL, 1, 'f932eca7686802d1697773fea713a3c6a3e3dace8b5aa552dd8503d50ce349f500000000000000000000000000000000', 'AGE Januar 2021', '2021-04-12 00:00:00', 1], + [3, NULL, 2, '4e2235f208edaf5cbb285955732022a625cf1e100eb629c56896d2fbfb8b34e800000000000000000000000000000000', 'test', '2021-04-12 00:00:00', 1], + [4, NULL, 2, 'fc6e69696beb7c56ad7c511fc3999f954411427bec810184b70c092911deae1900000000000000000000000000000000', 'test time', '2021-04-14 00:00:00', 1], + [5, NULL, 2, 'a7149ebc0d6cd8c061906dafe05e13689b51642a41100d0ec7bb6cd2dcafdc1800000000000000000000000000000000', 'test time', '2021-04-14 09:01:07', 1], + [6, NULL, 2, '2e3c3ab3e42c06f2ecb12f61c970712467d8ad9ddfa16fa58dd76492e5924b7d00000000000000000000000000000000', 'test time 3', '2021-04-14 09:02:28', 1], + [7, NULL, 2, 'c2c6354d77ff371daeee25fce9c947748b53d3d6b8398a92bd681923cfd2057100000000000000000000000000000000', 'test login crash', '2021-04-14 09:28:46', 1], + [8, NULL, 2, '5a8cbf1aaac06b00b2951ff39983cb2ca9a1e6710d72c8e5067278dc679a823100000000000000000000000000000000', 'test login crash', '2021-04-14 09:31:28', 1] ]; $this->records = $this->sqlEntrysToRecords($sql, $this->fields); parent::init();