replace hex values with hex strings to work correct with php

This commit is contained in:
Dario Rekowski on RockPI 2021-04-14 14:10:16 +00:00
parent c10f19f2ae
commit fb19aae34a
7 changed files with 41 additions and 65 deletions

View File

@ -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)
// ''([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;
}

View File

@ -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();
}

View File

@ -44,9 +44,9 @@ 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);
parent::init();

View File

@ -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();

View File

@ -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);

View File

@ -35,35 +35,15 @@ class TransactionSignaturesFixture extends TestFixture
*/
public function init()
{
// (1, 1, 0x911b173577261c8b971b4e6ca56b5125ebd5155de8176ce35f9c95ae6929edf3f1e3095d29b37c8bc7cc2478981a41d8cdd3e5398a2c7aa7c691bd486836b705, 0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355),
// (2, 2, 0x01e76b14190fa14cb5839d1129b04c4043e691895541b16ae1b54c6b3206d7933def3c58ebf195bc67a7cd5773554636c55fe5e7ddb0c81fb247c24761f8120f, 0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355),
// (3, 3, 0x2b8c56cac8993f445a8b41ab6e86a486faa18c1e945df1c0acce2bcb342b96d36c5fcb7e687c97cc89790a386241d4b911e8f7949a2da64eef290c5380fc8602, 0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355),
// (4, 4, 0xcb0e9f83b847f630cc6831d62aca8fbfa971af458a12389d7e43abb5bb0936b8e35dbc5b1d641eb2f793e253eb0b149a809860a69897bfe86ba4bfd178da8102, 0xcccb338e003d2abb92178fc4302d1ab83f66b27d9c7e5b6b3ac91e0c23922088);
$this->records = [
[
'id' => 1,
'transaction_id' => 1,
'signature' => '0x911b173577261c8b971b4e6ca56b5125ebd5155de8176ce35f9c95ae6929edf3f1e3095d29b37c8bc7cc2478981a41d8cdd3e5398a2c7aa7c691bd486836b705',
'pubkey' => '0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355'
],
[
'id' => 2,
'transaction_id' => 2,
'signature' => '0x01e76b14190fa14cb5839d1129b04c4043e691895541b16ae1b54c6b3206d7933def3c58ebf195bc67a7cd5773554636c55fe5e7ddb0c81fb247c24761f8120f',
'pubkey' => '0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355'
],
[
'id' => 3,
'transaction_id' => 3,
'signature' => '0x2b8c56cac8993f445a8b41ab6e86a486faa18c1e945df1c0acce2bcb342b96d36c5fcb7e687c97cc89790a386241d4b911e8f7949a2da64eef290c5380fc8602',
'pubkey' => '0x80183e03535d17a54ff1fd7dbaed86939d423a19a258c26b8e338ce601338355'
],
[
'id' => 4,
'transaction_id' => 4,
'signature' => '0xcb0e9f83b847f630cc6831d62aca8fbfa971af458a12389d7e43abb5bb0936b8e35dbc5b1d641eb2f793e253eb0b149a809860a69897bfe86ba4bfd178da8102',
'pubkey' => '0xcccb338e003d2abb92178fc4302d1ab83f66b27d9c7e5b6b3ac91e0c23922088'
],
$sql = [
[1, 1, '1c5357f9438f700a5378abadd0dbd74d90e335c6b9691bb9e126520813f3218573b19226382efb89aa8444a9ca98c2e8933463335baac37baf2f4eecd990600a', 'f7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f'],
[2, 2, '5215376ae7fb989993e3466961636519d4ade77b3bde066149ade028ad54a1a88ca8a206fcf09f52839ae0ed37b99df08ec9af12f3f37197979a206489e3ff0f', 'e3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2'],
[3, 3, 'c70f124feaaea02194d22a5f597963ed3e430343122a0952877854766fe37a709f92b39510de2aae494ef11abe743cd59f08f971b1e0e36f4c333990453d8b0d', 'f7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f'],
[4, 4, 'a65b39e51ab6191c51d5629bbcefd30f85f801efbb14e1c635c519e97abe217a248820fa1fc6aef56227c9d888c1919bc92471d5d7ae3522c9c50fba9f0d8402', 'f7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f'],
[5, 5, 'a65b39e51ab6191c51d5629bbcefd30f85f801efbb14e1c635c519e97abe217a248820fa1fc6aef56227c9d888c1919bc92471d5d7ae3522c9c50fba9f0d8402', 'f7f4a49a4ac10379f8b9ddcb731c4d9ec495e6edd16075f52672cd25e3179f0f'],
[6, 6, 'c233726674bff9bfb8ccb98bf358c6bc701825d971ece915d3c3a3de98886d1d13ee2f773cd9fc4ccbe543ac17be0d780ebead23a0dbf4ec814f7bae2efb9c0e', 'e3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2'],
[7, 7, '83ab780535883ec53ee76d0f68db0e1596418c9e100c806a4d4655d4dedf589d54a6319a2795dabab301e212b52f0dafb2725b7583447f19e47cb417d188a107', 'e3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2'],
[8, 8, '83ab780535883ec53ee76d0f68db0e1596418c9e100c806a4d4655d4dedf589d54a6319a2795dabab301e212b52f0dafb2725b7583447f19e47cb417d188a107', 'e3369de3623ce8446d0424c4013e7a1d71a2671ae3d7bf1e798ebf0665d145f2']
];
parent::init();
}

View File

@ -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();