mirror of
https://github.com/planetmint/planetmint.git
synced 2025-03-30 15:08:31 +00:00

* assets changes * fixed init db code Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed some other test cases Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * Fixed 1/3 from test_queries.py * test_queries.py ALL PASSED * removed junk comment * test_schema.py fixed * added funcationilty to init a DB in case it hasn't been initialized before Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed test_schema.py * last commit * fixed some minor bugs Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * test_schema.py ALL PASSING + changes in TarantoolDB Class * test_schema.py ALL PASSING + changes in TarantoolDB Class * commit err * fixed asset issues Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed assets handling Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed missing Config().get() migrations Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed unit test error in case tx id is not defined Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed some minor bugs Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * simplified return of metadata Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * reconnect function added to reset_database if statement * removed some print * fixed TX compose bug about threshold information Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed usage of from_db part 1 Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed tarantool/tendermint status management Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed some backend init issues and error handling Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed output public_keys order bug Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed deepcopy bug and another small assignment bug Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * s * fixed last asset bug Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * merge * fixed another set of tests Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed test_core.py by converting dict transaction to Transaction Object * fixed delete_transaction function Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * commit * pre_commit_state singledispatch issue * fixed global variable of backend * fixed backend problem with command make tests * args_reset_db added, fixed error with incorrect handling of kwargs * test_validator passing * fixed test_core.py by adding HDict in saved_key_orders function * fixed pre_commiT-state bug * init chain recoginez function fixed . * fixed last error from tendermint/test_core.py * tendermint/test_core.py all passing * fixed function from fast_query.py, problem was in deleteting functions * fixed error from test_fastquery.py, by chaning the algorithm of verifying returnred transactions id * fixed test_core.py by adding HDict in saved_key_orders function Signed-off-by: Sangat Das <sangatdas5@gmail.com> * Fix make test issue - unhealthy planetmint container because non-init of tarantool spaces Signed-off-by: Sangat Das <sangatdas5@gmail.com> * Fix tarantool connection issues in test Signed-off-by: Sangat Das <sangatdas5@gmail.com> * _save_keys_order, changes behaviour * hash problem fixed * separated asset test fixed * Removed all Errors in Make Test Signed-off-by: Sangat Das <sangatdas5@gmail.com> * mock error solved * mock solved * problem with stdout from Popen * fixed output from calling subprocess * Now planetmint drop and planemint init, is working throught schema.py file. * Fixed some lib and web issues Signed-off-by: Sangat Das <sangatdas5@gmail.com> * test_lib test_update_utxoset passing * test_commands.py -> all tests are passing * test_queries.py -> fixed * rollback my changes * fixed test_quries.py -> problem with assets * test_quries.py -> metadata error fixed * test_bigchain_api -> fixed by adding ErrorHandling for Tarantool operation * test_bigchain_api * test_integration.py -> fixed issue with block object * test_lib.py -> fixed * store and get utxo fixed * NoneType error, fixed in test_lib.py * test_lib.py fixed error, adopting verification for tarantool * test_lib.py fixed one more function * test_store_bulk_transaction -> adopted for tarantool * test_store_transaction -> changed to work with tarantool * test_asset_is_separated_from_transaciton -> skipped for Tarantool connection type * Fixed 4 issues in test/tendermint Signed-off-by: Sangat Das <sangatdas5@gmail.com> * fixed merge issues Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed last misspelling of backend config Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * test_block_tendermint.py -> solved by returning empty list if not found * readded test_core tests, fixed some linter issues Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * last changes * removed test fixture * removed planetmint_env folder Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * .idea/ added to gitignore file * removed .idea/ folder from project * create 3 files. init: indexes, schema, tables(spaces). this is used for initializing space,index and schema separately, and getting an output for specific command * added to schema all execute commands in dictionary format * Added create_tables function for tarantool connection * 'create_database' function from schema file, is ignored using TarantoolDB Class. * Implemented planetmint init via schema.py ! * added execute drop commands for spaces * drop_databases improved * Removed .lua files that was created temporarily. * replaced TarantoolDB with TarantoolDBConnection Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * Added output to console for creating indexes. * fixed connection instantiation Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * Added exception for NetworkError, to get specific error from connection class. * _setup_database fixture restored.(STILL NOT WORKING in this commit) * added 'universe' name as database name for tarantool * created flush_db for tarantool connection type * function create_database will call create_tables only for tarantool connection * _bdb, setup_database restored as it was before * Fixed flush_dbtarantool * Fixed fatal crashing at beginning of starting planetmint. problem was solved by returning None value if where is no space. * adding try except to some queries from tarantool/query.py. * implemented decorator for running queries in try catch * removed import of interface * Removed print + removed import of interface directly * removed importing of interface * fixed some imports, refactored TarantoolDBConnection.conn handling Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added new requirement to setup.py * added query() method, that will return Lazy Object * removed unecessary comments from connection class * get_space method is the same as old space method. * Added run() method to TarantoolDBConnection Class. * tarantool/query.py changed for using Lazy() implementation + little changes * queries from tarantool/query.py was adjusted to not get NonType error * adjusted some function calls, and connection calls Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixes for error NoneType * fix for flush function (freezing of pytest) + NoneType error * store_transactions changed to use new format of query * Changed from .space() method to .get_space() * putted from new line * fixed Lazy() has no len * adjusted _group_transaction_by_ids and store_transactions for connection.run Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * removed .data from select queries Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed run_command_without_output config and removed faulty error handling Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * made rollback db agnostic * Added assign for pre_commit * resolved comments and clean-up of unused code * Fixed no attribute .run(). Fixed | Fixed no attribute .data * Fixed no atribute .data * Fixed list has no attribute .data * Removed comments * Fixed flush_db_tarantool, not it removes also from blocks spaces * Fixed test_queries.py PASSED * Fixed SystemExit error by inversing sorting of array * Cleaned up test_core.py * fixed upsert() functions, incorrect behaviour * removed unused print * removed unused print (2) * Fixed test_txlist.py by improving flush_db_tarantool * Small fixes in .upsert() functions for tarantool_db * Fixes some test cases in tendermint/test_lib.py * Fixed flush_tarantool_db Function. * added utxos to SPACE_NAMES to delete data from utxo space * fixed this module by restoring original function instructions. * added hash generation to create primary key for abci_chain tuple. * Added field 'id' to abci_chains * changed flush function to delete abci_chains tuples * added indexed_pattern_search to basic lua, implemented text_search Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * adjusted some queries, wip print statements to be removed Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed get_metadata Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added some prints and simplified code Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed __asset_check Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * removed print statements Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added limit to text_Search Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * Planetmint tarantool (#152) * added indexed_pattern_search to basic lua, implemented text_search Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * adjusted some queries, wip print statements to be removed Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed get_metadata Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added some prints and simplified code Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed __asset_check Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * removed print statements Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added limit to text_Search Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * adjusted store_asset behaviour to match mongodb implementation Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed test_write_metadata test case Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed pattern search for meta_data Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed text_search result conversion Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * adjusted connect config error handling and test case for new signature Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * Resolved issues related to key error * Added convert.py for storing interfaces * Added convert.py implementation for tarantool * Implemented to lib.py, functions from converted.py * Added initializing for convert.py * init of convert.py for mongodb implementation * implemented convert.py for mongodatabase [NOT TESTED] * adjusted get_assets and from_db for tarantool Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added comment Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fix get_assets issue (#160) * adjusted get_assets and from_db for tarantool Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added comment Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * resolve conflicts * docker all in one now install tarantool Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added user to integration init.lua Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * updated integration test setup for tarantool Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * removed print statements Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * updated changelog Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed error messaging Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed exception verification Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed printing of testdata Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * Planetmint tarantool (#169) * 31 restructue documentation (#138) * removed korean documentation Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed CN and KOR readme Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * changed to the press theme Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * first changes Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixe H3 vs H1 issues Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added missing png Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added missing file Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed warnings Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * moved documents Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed obsolete files Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed obsolete folder Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed obs. file Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added some final changes Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed obs. reference Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * moved chain migration to election types (#109) Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * Final zenroom (#147) * zenroom fixes Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * expl. defined the aiohttp package Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * increased version number and fixed a zenroom runtime bug Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added fialing zenroom tx signing test Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * extended test to pass zenrooom validation, but to fail planetmint validation. Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added manual tx crafting Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added zenroom fulfillment verification Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * the last mile before integration Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * zenroom unit tests are passing Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * simplified zenroom unit tests Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed obsolte lines from the zenroom tests Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed acceptance tests Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * adjusted zenroom integraiton tests Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed linting errors Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * simplified zenroom unit test Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * increased version number Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * using cryptoconditions without print message Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * increased cc usage to 0.9.9 readded daemon proceses Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * increased version to 0.9.6 Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed deployment issue for 0.9.6 Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * adjusted get_assets and from_db for tarantool Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added comment Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * improve usability of zenroom (#159) * improve usability of zenroom * * increased version * fixed test cases * added changelog Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com> * migrated to AGPLv3 Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * 150 add cryptoconditions documentation (#166) * added smaller logos fixed reference issue Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed some erros and typos Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added cryptoconditions reference to the subproject Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * docker all in one now install tarantool Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added user to integration init.lua Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * updated integration test setup for tarantool Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * removed print statements Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * updated changelog Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed error messaging Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed exception verification Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed printing of testdata Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> Co-authored-by: Jürgen Eckel <eckelj@users.noreply.github.com> Co-authored-by: Lorenz Herzberger <64837895+LaurentDeMontBlanc@users.noreply.github.com> Co-authored-by: Alberto Lerda <30939098+albertolerda@users.noreply.github.com> Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com> * Removing naughty strings test cases * updated quickstart with tarantool installation Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * updated all-in-one-planetmint with tarantool port and data persistence Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed typo Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * update documentation about tarantool (#174) * 31 restructue documentation (#138) * removed korean documentation Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed CN and KOR readme Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * changed to the press theme Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * first changes Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixe H3 vs H1 issues Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added missing png Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added missing file Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed warnings Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * moved documents Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed obsolete files Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed obsolete folder Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed obs. file Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added some final changes Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed obs. reference Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * moved chain migration to election types (#109) Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * Final zenroom (#147) * zenroom fixes Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * expl. defined the aiohttp package Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * increased version number and fixed a zenroom runtime bug Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added fialing zenroom tx signing test Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * extended test to pass zenrooom validation, but to fail planetmint validation. Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added manual tx crafting Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added zenroom fulfillment verification Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * the last mile before integration Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * zenroom unit tests are passing Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * simplified zenroom unit tests Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * removed obsolte lines from the zenroom tests Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed acceptance tests Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * adjusted zenroom integraiton tests Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed linting errors Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * simplified zenroom unit test Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * increased version number Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * using cryptoconditions without print message Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * increased cc usage to 0.9.9 readded daemon proceses Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * increased version to 0.9.6 Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed deployment issue for 0.9.6 Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * adjusted get_assets and from_db for tarantool Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added comment Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * improve usability of zenroom (#159) * improve usability of zenroom * * increased version * fixed test cases * added changelog Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com> * migrated to AGPLv3 Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * 150 add cryptoconditions documentation (#166) * added smaller logos fixed reference issue Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed some erros and typos Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * added cryptoconditions reference to the subproject Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * docker all in one now install tarantool Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * added user to integration init.lua Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * updated integration test setup for tarantool Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * removed print statements Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * updated changelog Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed error messaging Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed exception verification Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * fixed printing of testdata Signed-off-by: Jürgen Eckel <juergen@riddleandcode.com> * updated quickstart with tarantool installation Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * updated all-in-one-planetmint with tarantool port and data persistence Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> * fixed typo Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com> Co-authored-by: Jürgen Eckel <eckelj@users.noreply.github.com> Co-authored-by: Lorenz Herzberger <64837895+LaurentDeMontBlanc@users.noreply.github.com> Co-authored-by: Alberto Lerda <30939098+albertolerda@users.noreply.github.com> Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com> * Fixes lint issues (#176) * Resolved lint issues * resolved other lint issues Co-authored-by: Jürgen Eckel <juergen@riddleandcode.com> Co-authored-by: andrei <deffuls@debian-BULLSEYE-live-builder-AMD64> Co-authored-by: Sangat Das <sangatdas5@gmail.com> Co-authored-by: liviu-lesan <31960632+liviu-lesan@users.noreply.github.com> Co-authored-by: Lorenz Herzberger <64837895+LaurentDeMontBlanc@users.noreply.github.com> Co-authored-by: andreitricolici <97448537+andreitricolici@users.noreply.github.com> Co-authored-by: ArpitShukla007 <arpitnshukla@gmail.com> Co-authored-by: Jürgen Eckel <eckelj@users.noreply.github.com> Co-authored-by: Alberto Lerda <30939098+albertolerda@users.noreply.github.com>
485 lines
18 KiB
Python
485 lines
18 KiB
Python
# # # Copyright © 2020 Interplanetary Database Association e.V.,
|
|
# # # Planetmint and IPDB software contributors.
|
|
# # # SPDX-License-Identifier: (Apache-2.0 AND CC-BY-4.0)
|
|
# # # Code is Apache-2.0 and docs are CC-BY-4.0
|
|
#
|
|
# from copy import deepcopy
|
|
# from planetmint.transactions.types.assets.create import Create
|
|
# from planetmint.transactions.types.assets.transfer import Transfer
|
|
#
|
|
# # import pytest
|
|
# # import pymongo
|
|
#
|
|
# # from planetmint.backend import Connection, query
|
|
#
|
|
#
|
|
# # pytestmark = pytest.mark.bdb
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_get_txids_filtered(signed_create_tx, signed_transfer_tx):
|
|
# from planetmint.backend import connect, query
|
|
# from planetmint.models import Transaction
|
|
# conn = connect()
|
|
#
|
|
# # create and insert two blocks, one for the create and one for the
|
|
# # transfer transaction
|
|
# conn.db.transactions.insert_one(signed_create_tx.to_dict())
|
|
# conn.db.transactions.insert_one(signed_transfer_tx.to_dict())
|
|
#
|
|
# asset_id = Transaction.get_asset_id([signed_create_tx, signed_transfer_tx])
|
|
#
|
|
# # Test get by just asset id
|
|
# txids = set(query.get_txids_filtered(conn, asset_id))
|
|
# assert txids == {signed_create_tx.id, signed_transfer_tx.id}
|
|
#
|
|
# # Test get by asset and CREATE
|
|
# txids = set(query.get_txids_filtered(conn, asset_id, Transaction.CREATE))
|
|
# assert txids == {signed_create_tx.id}
|
|
#
|
|
# # Test get by asset and TRANSFER
|
|
# txids = set(query.get_txids_filtered(conn, asset_id, Transaction.TRANSFER))
|
|
# assert txids == {signed_transfer_tx.id}
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_write_assets():
|
|
# from planetmint.backend import connect, query
|
|
# conn = connect()
|
|
#
|
|
# assets = [
|
|
# {'id': 1, 'data': '1'},
|
|
# {'id': 2, 'data': '2'},
|
|
# {'id': 3, 'data': '3'},
|
|
# # Duplicated id. Should not be written to the database
|
|
# {'id': 1, 'data': '1'},
|
|
# ]
|
|
#
|
|
# # write the assets
|
|
# for asset in assets:
|
|
# query.store_asset(conn, deepcopy(asset))
|
|
#
|
|
# # check that 3 assets were written to the database
|
|
# cursor = conn.db.assets.find({}, projection={'_id': False})\
|
|
# .sort('id', pymongo.ASCENDING)
|
|
#
|
|
# assert cursor.collection.count_documents({}) == 3
|
|
# assert list(cursor) == assets[:-1]
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_get_assets():
|
|
# from planetmint.backend import connect, query
|
|
# conn = connect()
|
|
#
|
|
# assets = [
|
|
# {'id': 1, 'data': '1'},
|
|
# {'id': 2, 'data': '2'},
|
|
# {'id': 3, 'data': '3'},
|
|
# ]
|
|
#
|
|
# conn.db.assets.insert_many(deepcopy(assets), ordered=False)
|
|
#
|
|
# for asset in assets:
|
|
# assert query.get_asset(conn, asset['id'])
|
|
#
|
|
# @pytest.mark.skip
|
|
# @pytest.mark.parametrize('table', ['assets', 'metadata'])
|
|
# def test_text_search(table):
|
|
# from planetmint.backend import connect, query
|
|
# conn = connect()
|
|
#
|
|
# # Example data and tests cases taken from the mongodb documentation
|
|
# # https://docs.mongodb.com/manual/reference/operator/query/text/
|
|
# objects = [
|
|
# {'id': 1, 'subject': 'coffee', 'author': 'xyz', 'views': 50},
|
|
# {'id': 2, 'subject': 'Coffee Shopping', 'author': 'efg', 'views': 5},
|
|
# {'id': 3, 'subject': 'Baking a cake', 'author': 'abc', 'views': 90},
|
|
# {'id': 4, 'subject': 'baking', 'author': 'xyz', 'views': 100},
|
|
# {'id': 5, 'subject': 'Café Con Leche', 'author': 'abc', 'views': 200},
|
|
# {'id': 6, 'subject': 'Сырники', 'author': 'jkl', 'views': 80},
|
|
# {'id': 7, 'subject': 'coffee and cream', 'author': 'efg', 'views': 10},
|
|
# {'id': 8, 'subject': 'Cafe con Leche', 'author': 'xyz', 'views': 10}
|
|
# ]
|
|
#
|
|
# # insert the assets
|
|
# conn.db[table].insert_many(deepcopy(objects), ordered=False)
|
|
#
|
|
# # test search single word
|
|
# assert list(query.text_search(conn, 'coffee', table=table)) == [
|
|
# {'id': 1, 'subject': 'coffee', 'author': 'xyz', 'views': 50},
|
|
# {'id': 2, 'subject': 'Coffee Shopping', 'author': 'efg', 'views': 5},
|
|
# {'id': 7, 'subject': 'coffee and cream', 'author': 'efg', 'views': 10},
|
|
# ]
|
|
#
|
|
# # match any of the search terms
|
|
# assert list(query.text_search(conn, 'bake coffee cake', table=table)) == [
|
|
# {'author': 'abc', 'id': 3, 'subject': 'Baking a cake', 'views': 90},
|
|
# {'author': 'xyz', 'id': 1, 'subject': 'coffee', 'views': 50},
|
|
# {'author': 'xyz', 'id': 4, 'subject': 'baking', 'views': 100},
|
|
# {'author': 'efg', 'id': 2, 'subject': 'Coffee Shopping', 'views': 5},
|
|
# {'author': 'efg', 'id': 7, 'subject': 'coffee and cream', 'views': 10}
|
|
# ]
|
|
#
|
|
# # search for a phrase
|
|
# assert list(query.text_search(conn, '\"coffee shop\"', table=table)) == [
|
|
# {'id': 2, 'subject': 'Coffee Shopping', 'author': 'efg', 'views': 5},
|
|
# ]
|
|
#
|
|
# # exclude documents that contain a term
|
|
# assert list(query.text_search(conn, 'coffee -shop', table=table)) == [
|
|
# {'id': 1, 'subject': 'coffee', 'author': 'xyz', 'views': 50},
|
|
# {'id': 7, 'subject': 'coffee and cream', 'author': 'efg', 'views': 10},
|
|
# ]
|
|
#
|
|
# # search different language
|
|
# assert list(query.text_search(conn, 'leche', language='es', table=table)) == [
|
|
# {'id': 5, 'subject': 'Café Con Leche', 'author': 'abc', 'views': 200},
|
|
# {'id': 8, 'subject': 'Cafe con Leche', 'author': 'xyz', 'views': 10}
|
|
# ]
|
|
#
|
|
# # case and diacritic insensitive search
|
|
# assert list(query.text_search(conn, 'сы́рники CAFÉS', table=table)) == [
|
|
# {'id': 6, 'subject': 'Сырники', 'author': 'jkl', 'views': 80},
|
|
# {'id': 5, 'subject': 'Café Con Leche', 'author': 'abc', 'views': 200},
|
|
# {'id': 8, 'subject': 'Cafe con Leche', 'author': 'xyz', 'views': 10}
|
|
# ]
|
|
#
|
|
# # case sensitive search
|
|
# assert list(query.text_search(conn, 'Coffee', case_sensitive=True, table=table)) == [
|
|
# {'id': 2, 'subject': 'Coffee Shopping', 'author': 'efg', 'views': 5},
|
|
# ]
|
|
#
|
|
# # diacritic sensitive search
|
|
# assert list(query.text_search(conn, 'CAFÉ', diacritic_sensitive=True, table=table)) == [
|
|
# {'id': 5, 'subject': 'Café Con Leche', 'author': 'abc', 'views': 200},
|
|
# ]
|
|
#
|
|
# # return text score
|
|
# assert list(query.text_search(conn, 'coffee', text_score=True, table=table)) == [
|
|
# {'id': 1, 'subject': 'coffee', 'author': 'xyz', 'views': 50, 'score': 1.0},
|
|
# {'id': 2, 'subject': 'Coffee Shopping', 'author': 'efg', 'views': 5, 'score': 0.75},
|
|
# {'id': 7, 'subject': 'coffee and cream', 'author': 'efg', 'views': 10, 'score': 0.75},
|
|
# ]
|
|
#
|
|
# # limit search result
|
|
# assert list(query.text_search(conn, 'coffee', limit=2, table=table)) == [
|
|
# {'id': 1, 'subject': 'coffee', 'author': 'xyz', 'views': 50},
|
|
# {'id': 2, 'subject': 'Coffee Shopping', 'author': 'efg', 'views': 5},
|
|
# ]
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_write_metadata():
|
|
# from planetmint.backend import connect, query
|
|
# conn = connect()
|
|
#
|
|
# metadata = [
|
|
# {'id': 1, 'data': '1'},
|
|
# {'id': 2, 'data': '2'},
|
|
# {'id': 3, 'data': '3'}
|
|
# ]
|
|
#
|
|
# # write the assets
|
|
# query.store_metadatas(conn, deepcopy(metadata))
|
|
#
|
|
# # check that 3 assets were written to the database
|
|
# cursor = conn.db.metadata.find({}, projection={'_id': False})\
|
|
# .sort('id', pymongo.ASCENDING)
|
|
#
|
|
# assert cursor.collection.count_documents({}) == 3
|
|
# assert list(cursor) == metadata
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_get_metadata():
|
|
# from planetmint.backend import connect, query
|
|
# conn = connect()
|
|
#
|
|
# metadata = [
|
|
# {'id': 1, 'metadata': None},
|
|
# {'id': 2, 'metadata': {'key': 'value'}},
|
|
# {'id': 3, 'metadata': '3'},
|
|
# ]
|
|
#
|
|
# conn.db.metadata.insert_many(deepcopy(metadata), ordered=False)
|
|
#
|
|
# for meta in metadata:
|
|
# assert query.get_metadata(conn, [meta['id']])
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_get_owned_ids(signed_create_tx, user_pk):
|
|
# from planetmint.backend import connect, query
|
|
# conn = connect()
|
|
#
|
|
# # insert a transaction
|
|
# conn.db.transactions.insert_one(deepcopy(signed_create_tx.to_dict()))
|
|
#
|
|
# txns = list(query.get_owned_ids(conn, user_pk))
|
|
#
|
|
# assert txns[0] == signed_create_tx.to_dict()
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_get_spending_transactions(user_pk, user_sk):
|
|
# from planetmint.backend import connect, query
|
|
# conn = connect()
|
|
#
|
|
# out = [([user_pk], 1)]
|
|
# tx1 = Create.generate([user_pk], out * 3)
|
|
# tx1.sign([user_sk])
|
|
# inputs = tx1.to_inputs()
|
|
# tx2 = Transfer.generate([inputs[0]], out, tx1.id).sign([user_sk])
|
|
# tx3 = Transfer.generate([inputs[1]], out, tx1.id).sign([user_sk])
|
|
# tx4 = Transfer.generate([inputs[2]], out, tx1.id).sign([user_sk])
|
|
# txns = [deepcopy(tx.to_dict()) for tx in [tx1, tx2, tx3, tx4]]
|
|
# conn.db.transactions.insert_many(txns)
|
|
#
|
|
# links = [inputs[0].fulfills.to_dict(), inputs[2].fulfills.to_dict()]
|
|
# txns = list(query.get_spending_transactions(conn, links))
|
|
#
|
|
# # tx3 not a member because input 1 not asked for
|
|
# assert txns == [tx2.to_dict(), tx4.to_dict()]
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_get_spending_transactions_multiple_inputs():
|
|
# from planetmint.backend import connect, query
|
|
# from planetmint.transactions.common.crypto import generate_key_pair
|
|
# conn = connect()
|
|
# (alice_sk, alice_pk) = generate_key_pair()
|
|
# (bob_sk, bob_pk) = generate_key_pair()
|
|
# (carol_sk, carol_pk) = generate_key_pair()
|
|
#
|
|
# out = [([alice_pk], 9)]
|
|
# tx1 = Create.generate([alice_pk], out).sign([alice_sk])
|
|
#
|
|
# inputs1 = tx1.to_inputs()
|
|
# tx2 = Transfer.generate([inputs1[0]],
|
|
# [([alice_pk], 6), ([bob_pk], 3)],
|
|
# tx1.id).sign([alice_sk])
|
|
#
|
|
# inputs2 = tx2.to_inputs()
|
|
# tx3 = Transfer.generate([inputs2[0]],
|
|
# [([bob_pk], 3), ([carol_pk], 3)],
|
|
# tx1.id).sign([alice_sk])
|
|
#
|
|
# inputs3 = tx3.to_inputs()
|
|
# tx4 = Transfer.generate([inputs2[1], inputs3[0]],
|
|
# [([carol_pk], 6)],
|
|
# tx1.id).sign([bob_sk])
|
|
#
|
|
# txns = [deepcopy(tx.to_dict()) for tx in [tx1, tx2, tx3, tx4]]
|
|
# conn.db.transactions.insert_many(txns)
|
|
#
|
|
# links = [
|
|
# ({'transaction_id': tx2.id, 'output_index': 0}, 1, [tx3.id]),
|
|
# ({'transaction_id': tx2.id, 'output_index': 1}, 1, [tx4.id]),
|
|
# ({'transaction_id': tx3.id, 'output_index': 0}, 1, [tx4.id]),
|
|
# ({'transaction_id': tx3.id, 'output_index': 1}, 0, None),
|
|
# ]
|
|
# for li, num, match in links:
|
|
# txns = list(query.get_spending_transactions(conn, [li]))
|
|
# assert len(txns) == num
|
|
# if len(txns):
|
|
# assert [tx['id'] for tx in txns] == match
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_store_block():
|
|
# from planetmint.backend import connect, query
|
|
# from planetmint.lib import Block
|
|
# conn = connect()
|
|
#
|
|
# block = Block(app_hash='random_utxo',
|
|
# height=3,
|
|
# transactions=[])
|
|
# query.store_block(conn, block._asdict())
|
|
# cursor = conn.db.blocks.find({}, projection={'_id': False})
|
|
# assert cursor.collection.count_documents({}) == 1
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_get_block():
|
|
# from planetmint.backend import connect, query
|
|
# from planetmint.lib import Block
|
|
# conn = connect()
|
|
#
|
|
# block = Block(app_hash='random_utxo',
|
|
# height=3,
|
|
# transactions=[])
|
|
#
|
|
# conn.db.blocks.insert_one(block._asdict())
|
|
#
|
|
# block = dict(query.get_block(conn, 3))
|
|
# assert block['height'] == 3
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_delete_zero_unspent_outputs(db_context, utxoset):
|
|
# from planetmint.backend import query
|
|
# unspent_outputs, utxo_collection = utxoset
|
|
# delete_res = query.delete_unspent_outputs(db_context.conn)
|
|
# assert delete_res is None
|
|
# assert utxo_collection.count_documents({}) == 3
|
|
# assert utxo_collection.count_documents(
|
|
# {'$or': [
|
|
# {'transaction_id': 'a', 'output_index': 0},
|
|
# {'transaction_id': 'b', 'output_index': 0},
|
|
# {'transaction_id': 'a', 'output_index': 1},
|
|
# ]}
|
|
# ) == 3
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_delete_one_unspent_outputs(db_context, utxoset):
|
|
# from planetmint.backend import query
|
|
# unspent_outputs, utxo_collection = utxoset
|
|
# delete_res = query.delete_unspent_outputs(db_context.conn,
|
|
# unspent_outputs[0])
|
|
# assert delete_res.raw_result['n'] == 1
|
|
# assert utxo_collection.count_documents(
|
|
# {'$or': [
|
|
# {'transaction_id': 'a', 'output_index': 1},
|
|
# {'transaction_id': 'b', 'output_index': 0},
|
|
# ]}
|
|
# ) == 2
|
|
# assert utxo_collection.count_documents(
|
|
# {'transaction_id': 'a', 'output_index': 0}) == 0
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_delete_many_unspent_outputs(db_context, utxoset):
|
|
# from planetmint.backend import query
|
|
# unspent_outputs, utxo_collection = utxoset
|
|
# delete_res = query.delete_unspent_outputs(db_context.conn,
|
|
# *unspent_outputs[::2])
|
|
# assert delete_res.raw_result['n'] == 2
|
|
# assert utxo_collection.count_documents(
|
|
# {'$or': [
|
|
# {'transaction_id': 'a', 'output_index': 0},
|
|
# {'transaction_id': 'b', 'output_index': 0},
|
|
# ]}
|
|
# ) == 0
|
|
# assert utxo_collection.count_documents(
|
|
# {'transaction_id': 'a', 'output_index': 1}) == 1
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_store_zero_unspent_output(db_context, utxo_collection):
|
|
# from planetmint.backend import query
|
|
# res = query.store_unspent_outputs(db_context.conn)
|
|
# assert res is None
|
|
# assert utxo_collection.count_documents({}) == 0
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_store_one_unspent_output(db_context,
|
|
# unspent_output_1, utxo_collection):
|
|
# from planetmint.backend import query
|
|
# res = query.store_unspent_outputs(db_context.conn, unspent_output_1)
|
|
# assert res.acknowledged
|
|
# assert len(res.inserted_ids) == 1
|
|
# assert utxo_collection.count_documents(
|
|
# {'transaction_id': unspent_output_1['transaction_id'],
|
|
# 'output_index': unspent_output_1['output_index']}
|
|
# ) == 1
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_store_many_unspent_outputs(db_context,
|
|
# unspent_outputs, utxo_collection):
|
|
# from planetmint.backend import query
|
|
# res = query.store_unspent_outputs(db_context.conn, *unspent_outputs)
|
|
# assert res.acknowledged
|
|
# assert len(res.inserted_ids) == 3
|
|
# assert utxo_collection.count_documents(
|
|
# {'transaction_id': unspent_outputs[0]['transaction_id']}
|
|
# ) == 3
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_get_unspent_outputs(db_context, utxoset):
|
|
# from planetmint.backend import query
|
|
# cursor = query.get_unspent_outputs(db_context.conn)
|
|
# assert cursor.collection.count_documents({}) == 3
|
|
# retrieved_utxoset = list(cursor)
|
|
# unspent_outputs, utxo_collection = utxoset
|
|
# assert retrieved_utxoset == list(
|
|
# utxo_collection.find(projection={'_id': False}))
|
|
# assert retrieved_utxoset == unspent_outputs
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_store_pre_commit_state(db_context):
|
|
# from planetmint.backend import query
|
|
#
|
|
# state = dict(height=3, transactions=[])
|
|
#
|
|
# query.store_pre_commit_state(db_context.conn, state)
|
|
# cursor = db_context.conn.db.pre_commit.find({'commit_id': 'test'},
|
|
# projection={'_id': False})
|
|
# assert cursor.collection.count_documents({}) == 1
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_get_pre_commit_state(db_context):
|
|
# from planetmint.backend import query
|
|
#
|
|
# state = dict(height=3, transactions=[])
|
|
# db_context.conn.db.pre_commit.insert_one(state)
|
|
# resp = query.get_pre_commit_state(db_context.conn)
|
|
# assert resp == state
|
|
#
|
|
# @pytest.mark.skip
|
|
# def test_validator_update():
|
|
# from planetmint.backend import connect, query
|
|
#
|
|
# conn = connect()
|
|
#
|
|
# def gen_validator_update(height):
|
|
# return {'data': 'somedata', 'height': height, 'election_id': f'election_id_at_height_{height}'}
|
|
#
|
|
# for i in range(1, 100, 10):
|
|
# value = gen_validator_update(i)
|
|
# query.store_validator_set(conn, value)
|
|
#
|
|
# v1 = query.get_validator_set(conn, 8)
|
|
# assert v1['height'] == 1
|
|
#
|
|
# v41 = query.get_validator_set(conn, 50)
|
|
# assert v41['height'] == 41
|
|
#
|
|
# v91 = query.get_validator_set(conn)
|
|
# assert v91['height'] == 91
|
|
#
|
|
# @pytest.mark.skip
|
|
# @pytest.mark.parametrize('description,stores,expected', [
|
|
# (
|
|
# 'Query empty database.',
|
|
# [],
|
|
# None,
|
|
# ),
|
|
# (
|
|
# 'Store one chain with the default value for `is_synced`.',
|
|
# [
|
|
# {'height': 0, 'chain_id': 'some-id'},
|
|
# ],
|
|
# {'height': 0, 'chain_id': 'some-id', 'is_synced': True},
|
|
# ),
|
|
# (
|
|
# 'Store one chain with a custom value for `is_synced`.',
|
|
# [
|
|
# {'height': 0, 'chain_id': 'some-id', 'is_synced': False},
|
|
# ],
|
|
# {'height': 0, 'chain_id': 'some-id', 'is_synced': False},
|
|
# ),
|
|
# (
|
|
# 'Store one chain, then update it.',
|
|
# [
|
|
# {'height': 0, 'chain_id': 'some-id', 'is_synced': True},
|
|
# {'height': 0, 'chain_id': 'new-id', 'is_synced': False},
|
|
# ],
|
|
# {'height': 0, 'chain_id': 'new-id', 'is_synced': False},
|
|
# ),
|
|
# (
|
|
# 'Store a chain, update it, store another chain.',
|
|
# [
|
|
# {'height': 0, 'chain_id': 'some-id', 'is_synced': True},
|
|
# {'height': 0, 'chain_id': 'some-id', 'is_synced': False},
|
|
# {'height': 10, 'chain_id': 'another-id', 'is_synced': True},
|
|
# ],
|
|
# {'height': 10, 'chain_id': 'another-id', 'is_synced': True},
|
|
# ),
|
|
# ])
|
|
# def test_store_abci_chain(description, stores, expected):
|
|
# conn = connect()
|
|
#
|
|
# for store in stores:
|
|
# query.store_abci_chain(conn, **store)
|
|
#
|
|
# actual = query.get_latest_abci_chain(conn)
|
|
# assert expected == actual, description
|