diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml
index 627a90580..0be1525a0 100644
--- a/.github/workflows/main.yml
+++ b/.github/workflows/main.yml
@@ -223,16 +223,16 @@ jobs:
run: |
npx ganache --miner.blockGasLimit 12000000 --logging.quiet --chain.allowUnlimitedContractSize --wallet.defaultBalance 2000000 --wallet.accountKeysPath ../test/accounts.json &
- - name: Prepare test (PY part)
- working-directory: ./test
- run: |
- python3 ../scripts/config_from_accounts.py accounts.json config.json
- pip3 install -r requirements.txt
-
- - name: Run test (PY part)
- working-directory: ./test
- run: |
- python3 test.py
+ # - name: Prepare test (PY part)
+ # working-directory: ./test
+ # run: |
+ # python3 ../scripts/config_from_accounts.py accounts.json config.json
+ # pip3 install -r requirements.txt
+
+ # - name: Run test (PY part)
+ # working-directory: ./test
+ # run: |
+ # python3 test.py
- name: Prepare test (JS part)
working-directory: ./test
diff --git a/package.json b/package.json
index 73ca84d25..9c973e494 100644
--- a/package.json
+++ b/package.json
@@ -4,8 +4,8 @@
"license": "AGPL-3.0",
"author": "SKALE Labs and contributors",
"scripts": {
- "lint-check": "eslint ./agent/*.*js ./npms/skale-*/*.*js ./test/*.*js ./agent/test/*.*js",
- "lint-fix": "eslint ./agent/*.*js ./npms/skale-*/*.*js ./test/*.*js ./agent/test/*.*js --fix",
+ "lint-check": "eslint ./test/*.*js",
+ "lint-fix": "eslint ./test/*.*js --fix",
"postinstall": "./postinstall.sh",
"check-outdated": "yarn outdated",
"upgrade-to-latest": "yarn upgrade --latest"
diff --git a/test/proxy/deployer.py b/test/proxy/deployer.py
deleted file mode 100644
index b99b5d82f..000000000
--- a/test/proxy/deployer.py
+++ /dev/null
@@ -1,65 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from tools.utils import execute
-from os import chdir
-
-class Deployer:
- def __init__(self, config):
- self.config = config
-
- def deploy(self):
- chdir(self.config.proxy_root)
- self._prepare_env_file()
- execute('yarn deploy-skale-manager-components')
- execute('yarn deploy-to-both-chains')
-
- def deploy_mainnet(self):
- chdir(self.config.proxy_root)
- self._prepare_env_file()
- execute('yarn deploy-skale-manager-components')
- execute('yarn deploy-to-mainnet')
-
- def deploy_schain(self, schain_name):
- chdir(self.config.proxy_root)
- self._prepare_env_file(schain_name)
- execute('yarn deploy-to-schain')
-
- def deploy_second_schain(self):
- self.deploy()
- self.deploy_schain(self.config.schain_name_2)
-
-
- # private
-
- def _prepare_env_file(self, schain_name=''):
- if schain_name == '' : schain_name = self.config.schain_name
- env_file = [f'NETWORK_FOR_ETHEREUM="{self.config.network_for_mainnet}"',
- f'NETWORK_FOR_SCHAIN="{self.config.network_for_schain}"',
- f'PRIVATE_KEY_FOR_ETHEREUM="{self.config.mainnet_key}"',
- f'URL_W3_ETHEREUM="{self.config.mainnet_rpc_url}"',
- f'PRIVATE_KEY_FOR_SCHAIN="{self.config.schain_key}"',
- f'URL_W3_S_CHAIN="{self.config.schain_rpc_url}"',
- f'CHAIN_NAME_SCHAIN="{schain_name}"',
- 'NO_SIGNATURES=true']
-
- with open('.env', 'w') as dot_env:
- dot_env.write('\n'.join(env_file))
-
diff --git a/test/proxy/proxy_environment.py b/test/proxy/proxy_environment.py
deleted file mode 100644
index a25cd2abe..000000000
--- a/test/proxy/proxy_environment.py
+++ /dev/null
@@ -1,33 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from os import chdir
-from tools.environment import Environment
-from tools.utils import execute
-
-class ProxyEnvironment(Environment):
- config = None
-
- def __init__(self, config):
- self.config = config
-
- def prepare(self):
- chdir(self.config.proxy_root)
- execute('yarn install')
diff --git a/test/requirements.txt b/test/requirements.txt
deleted file mode 100644
index b2de950ea..000000000
--- a/test/requirements.txt
+++ /dev/null
@@ -1 +0,0 @@
-web3==5.24.0
\ No newline at end of file
diff --git a/test/test.py b/test/test.py
deleted file mode 100644
index 930d15daf..000000000
--- a/test/test.py
+++ /dev/null
@@ -1,49 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-import sys
-import os
-import logging
-
-from tools.test_runner import TestRunner
-
-
-def main():
- argv, tests, prefix = [], None, 'tests='
- for argument in sys.argv:
- if argument.startswith(prefix):
- tests = argument[len(prefix):].split(',')
- else:
- argv.append(argument)
-
- if len(argv) < 2:
- src_root = os.path.abspath(os.pardir)
- else:
- src_root = argv[1]
-
- test_runner = TestRunner(src_root, 'config.json', tests)
- test_runner.run()
-
-
-if __name__ == '__main__':
- level = logging.INFO
- # level = logging.DEBUG
- logging.basicConfig(format='%(asctime)s - %(levelname)s - %(message)s', level=level)
- main()
diff --git a/test/test_cases/__init__.py b/test/test_cases/__init__.py
deleted file mode 100644
index 6183891e6..000000000
--- a/test/test_cases/__init__.py
+++ /dev/null
@@ -1,6 +0,0 @@
-# from os.path import dirname, basename, isfile, join
-from os import path
-#
-import glob
-modules = glob.glob(path.join(path.dirname(__file__), "*.py"))
-__all__ = [ path.basename(f)[:-3] for f in modules if path.isfile(f) and not f.endswith('__init__.py')]
\ No newline at end of file
diff --git a/test/test_cases/a_lot_of_send_ether_to_schain.py b/test/test_cases/a_lot_of_send_ether_to_schain.py
deleted file mode 100644
index 0e26e7a76..000000000
--- a/test/test_cases/a_lot_of_send_ether_to_schain.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-import time
-
-
-class ALotOfTransactionsSendEtherToSchain(TestCase):
- def __init__(self, config):
- super().__init__('Send ether a lot of times to schain', config)
-
- def _execute(self):
- #
- range_int = 5
- #
- address = self.blockchain.key_to_address(self.config.mainnet_key)
- balance = self.blockchain.get_balance_on_schain(address)
- initial_balance = balance
- # 2 ether (2 000 000 000 000 000 000 wei)
- amount = 2 * 10 ** 18
- #
- for x in range(range_int):
- self.agent.transfer_eth_from_mainnet_to_schain(self.config.mainnet_key,
- self.config.schain_key,
- amount,
- self.timeout)
- a = 23
- #
- balance = self.blockchain.get_balance_on_schain(address)
- if balance == initial_balance + range_int * amount:
- self._mark_passed()
-
-test_pool.register_test(ALotOfTransactionsSendEtherToSchain)
-
-# singe trans
-# Gas usage:
-
-# 3 trans
-# Gas usage: 111058
-# Gas usage: 66122
-# Gas usage: 66122
-
-# 7 trans
-# Gas usage: 111058
diff --git a/test/test_cases/load_send_ether_from_mainnet_to_schain_and_back.py b/test/test_cases/load_send_ether_from_mainnet_to_schain_and_back.py
deleted file mode 100644
index 51839fe91..000000000
--- a/test/test_cases/load_send_ether_from_mainnet_to_schain_and_back.py
+++ /dev/null
@@ -1,85 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from logging import debug
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-from time import sleep
-
-
-class SendEtherFromSchainToMainnetAndBack(TestCase):
-
- def __init__(self, config):
- super().__init__('load_send_ether_from_mainnet_to_schain_and_back', config)
-
- def _execute(self):
- amountRecharge = 2 * 10 ** 18
- self.blockchain.recharge_user_wallet(self.config.mainnet_key, self.config.schain_name, amountRecharge)
- sleep( 5 )
- range_int = 5
- # ETH
- eth_amount = 12 * 10 ** 18
- address = self.blockchain.key_to_address(self.config.mainnet_key)
- # transfer to schain
- self.agent.transfer_eth_from_mainnet_to_schain(self.config.mainnet_key,
- self.config.schain_key,
- eth_amount,
- self.timeout)
- sleep( 5 )
- #
- balance = self.blockchain.get_balance_on_schain(address)
- initial_balance = balance
- # 2 ether (2 000 000 000 000 000 000 wei)
- amount = 2 * 10 ** 18
- # 60 finney back because when we send on mainnet we should be able to cover gas fee on gasPrice 200 Gwei
- amount_from_schain = 7 * 10 ** 16
- #
- self.blockchain.set_time_limit_per_message(self.config.schain_key, 0)
- for x in range(range_int):
- # transfer to schain
- self.agent.transfer_eth_from_mainnet_to_schain(self.config.mainnet_key,
- self.config.schain_key,
- amount,
- self.timeout)
- sleep( 5 )
- # back to mainnet
- self.agent.transfer_eth_from_schain_to_mainnet(self.config.mainnet_key,
- self.config.schain_key,
- amount_from_schain,
- self.timeout)
- sleep( 5 )
- self.blockchain.get_balance_on_schain(address)
- a = 0
- #
- balance = self.blockchain.get_balance_on_schain(address)
- print( 'Real balance.......', balance )
- needed_balance = initial_balance + range_int * amount - range_int * amount_from_schain
- print( 'Needed balance.....', needed_balance )
-
- res = initial_balance - range_int * amount
- if balance == needed_balance:
- print( 'Passed.............', 'YES!' )
- self._mark_passed()
- else:
- print( 'Passed.............', 'NO(' )
-
-
-test_pool.register_test(SendEtherFromSchainToMainnetAndBack)
diff --git a/test/test_cases/send_erc1155_batch_from_mainnet_to_schain.py b/test/test_cases/send_erc1155_batch_from_mainnet_to_schain.py
deleted file mode 100644
index e7da44e81..000000000
--- a/test/test_cases/send_erc1155_batch_from_mainnet_to_schain.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from time import sleep
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-
-
-class SendERC1155BatchToSchain(TestCase):
- erc1155 = None
- tokenIds = [1, 2, 3]
- tokenAmounts = [3, 2, 1]
-
- def __init__(self, config):
- super().__init__('Send ERC1155 Batch to schain', config)
-
- def _prepare(self):
- sleep( 5 )
- self.erc1155 = self.blockchain.deploy_erc1155_on_mainnet(self.config.mainnet_key, 'elv1155')
-
- address = self.blockchain.key_to_address(self.config.mainnet_key)
- mint_txn = self.erc1155.functions.mintBatch(address, self.tokenIds, self.tokenAmounts, "0x")\
- .buildTransaction({
- 'gas': 8000000,
- 'nonce': self.blockchain.get_transactions_count_on_mainnet(address)})
-
- signed_txn = self.blockchain.web3_mainnet.eth.account.signTransaction(mint_txn,
- private_key=self.config.mainnet_key)
- self.blockchain.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
- self.blockchain.disableWhitelistERC1155(self.config.mainnet_key, self.config.schain_name)
- self.blockchain.enableAutomaticDeployERC1155(self.config.schain_key, "Mainnet")
-
- def _execute(self):
-
- self.agent.transfer_erc1155_batch_from_mainnet_to_schain(
- self.erc1155,
- self.config.mainnet_key,
- self.config.schain_key,
- self.tokenIds,
- self.tokenAmounts,
- 0,
- self.timeout
- )
-
- erc1155 = self.blockchain.get_erc1155_on_schain("Mainnet", self.erc1155.address)
- destination_address = self.blockchain.key_to_address(self.config.mainnet_key)
- new_amounts = erc1155.functions.balanceOfBatch([destination_address] * len(self.tokenIds), self.tokenIds).call()
- if self.tokenAmounts == new_amounts:
- self._mark_passed()
-
-test_pool.register_test(SendERC1155BatchToSchain)
diff --git a/test/test_cases/send_erc1155_batch_from_schain_to_mainnet.py b/test/test_cases/send_erc1155_batch_from_schain_to_mainnet.py
deleted file mode 100644
index c8fc21f13..000000000
--- a/test/test_cases/send_erc1155_batch_from_schain_to_mainnet.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from time import sleep
-from logging import error
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-
-
-class SendERC1155BatchToMainnet(TestCase):
- erc1155 = None
- erc1155_clone = None
- token_ids = [1, 2, 5, 6]
- token_amounts = [4, 4, 4, 99999]
-
- def __init__(self, config):
- super().__init__('Send ERC1155 Batch from schain to mainnet', config)
-
- def _prepare(self):
- sleep( 5 )
- amountRecharge = 2 * 10 ** 18
- self.blockchain.recharge_user_wallet(self.config.mainnet_key, self.config.schain_name, amountRecharge)
- sleep( 5 )
- # deploy token
- self.erc1155 = self.blockchain.deploy_erc1155_on_mainnet(self.config.mainnet_key, 'elv1155')
- # mint
- address = self.blockchain.key_to_address(self.config.mainnet_key)
- mint_txn = self.erc1155.functions.mintBatch(address, self.token_ids, self.token_amounts, "0x")\
- .buildTransaction({
- 'gas': 8000000,
- 'nonce': self.blockchain.get_transactions_count_on_mainnet(address)})
- signed_txn = self.blockchain.web3_mainnet.eth.account\
- .signTransaction(mint_txn, private_key=self.config.mainnet_key)
- self.blockchain.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
- self.blockchain.disableWhitelistERC1155(self.config.mainnet_key, self.config.schain_name)
- self.blockchain.enableAutomaticDeployERC1155(self.config.schain_key, "Mainnet")
- # send to schain
- self.agent.transfer_erc1155_batch_from_mainnet_to_schain(self.erc1155,
- self.config.mainnet_key,
- self.config.schain_key,
- self.token_ids,
- self.token_amounts,
- self.timeout)
- sleep( 5 )
- amount_eth = 90 * 10 ** 15
- self.agent.transfer_eth_from_mainnet_to_schain(self.config.mainnet_key,
- self.config.schain_key,
- amount_eth,
- self.timeout)
- sleep( 5 )
- self.erc1155_clone = self.blockchain.get_erc1155_on_schain("Mainnet", self.erc1155.address)
-
- def _execute(self):
- source_address = self.blockchain.key_to_address(self.config.mainnet_key)
- destination_address = self.blockchain.key_to_address(self.config.mainnet_key)
-
- if self.erc1155_clone.functions.balanceOfBatch([source_address] * len(self.token_ids), self.token_ids).call() != self.token_amounts:
- error("Token was not send")
- return
- sleep( 5 )
- self.agent.transfer_erc1155_batch_from_schain_to_mainnet(
- self.erc1155_clone,
- self.erc1155,
- self.config.mainnet_key,
- self.config.schain_key,
- self.token_ids,
- self.token_amounts,
- 6 * 10 ** 16,
- self.timeout
- )
- #
- # erc1155 = self.blockchain.get_erc1155_on_mainnet(self.token_id)
- # new_owner_address = erc1155.functions.ownerOf(self.token_id).call()
- new_amounts = self.erc1155.functions.balanceOfBatch([destination_address] * len(self.token_ids), self.token_ids).call()
- if self.token_amounts == new_amounts:
- self._mark_passed()
-
-
-test_pool.register_test(SendERC1155BatchToMainnet)
diff --git a/test/test_cases/send_erc1155_from_mainnet_to_schain.py b/test/test_cases/send_erc1155_from_mainnet_to_schain.py
deleted file mode 100644
index 5283fee6c..000000000
--- a/test/test_cases/send_erc1155_from_mainnet_to_schain.py
+++ /dev/null
@@ -1,69 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from time import sleep
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-
-
-class SendERC1155ToSchain(TestCase):
- erc1155 = None
- tokenId = 1
- tokenAmount = 3
-
- def __init__(self, config):
- super().__init__('Send ERC1155 to schain', config)
-
- def _prepare(self):
- sleep( 5 )
- self.erc1155 = self.blockchain.deploy_erc1155_on_mainnet(self.config.mainnet_key, 'elv1155')
-
- address = self.blockchain.key_to_address(self.config.mainnet_key)
- mint_txn = self.erc1155.functions.mint(address, self.tokenId, self.tokenAmount, "0x")\
- .buildTransaction({
- 'gas': 8000000,
- 'nonce': self.blockchain.get_transactions_count_on_mainnet(address)})
-
- signed_txn = self.blockchain.web3_mainnet.eth.account.signTransaction(mint_txn,
- private_key=self.config.mainnet_key)
- self.blockchain.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
- self.blockchain.disableWhitelistERC1155(self.config.mainnet_key, self.config.schain_name)
- self.blockchain.enableAutomaticDeployERC1155(self.config.schain_key, "Mainnet")
-
- def _execute(self):
-
- self.agent.transfer_erc1155_from_mainnet_to_schain(
- self.erc1155,
- self.config.mainnet_key,
- self.config.schain_key,
- self.tokenId,
- self.tokenAmount,
- 0,
- self.timeout
- )
-
- erc1155 = self.blockchain.get_erc1155_on_schain("Mainnet", self.erc1155.address)
- destination_address = self.blockchain.key_to_address(self.config.mainnet_key)
- new_amount = erc1155.functions.balanceOf(destination_address, self.tokenId).call()
- if self.tokenAmount == new_amount:
- self._mark_passed()
-
-test_pool.register_test(SendERC1155ToSchain)
diff --git a/test/test_cases/send_erc1155_from_schain_to_mainnet.py b/test/test_cases/send_erc1155_from_schain_to_mainnet.py
deleted file mode 100644
index cd609e57e..000000000
--- a/test/test_cases/send_erc1155_from_schain_to_mainnet.py
+++ /dev/null
@@ -1,97 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from time import sleep
-from logging import error
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-
-
-class Senderc1155ToMainnet(TestCase):
- erc1155 = None
- erc1155_clone = None
- token_id = 1
- token_amount = 4
-
- def __init__(self, config):
- super().__init__('Send ERC1155 from schain to mainnet', config)
-
- def _prepare(self):
- sleep( 5 )
- amountRecharge = 2 * 10 ** 18
- self.blockchain.recharge_user_wallet(self.config.mainnet_key, self.config.schain_name, amountRecharge)
- sleep( 5 )
- # deploy token
- self.erc1155 = self.blockchain.deploy_erc1155_on_mainnet(self.config.mainnet_key, 'elv1155')
- # mint
- address = self.blockchain.key_to_address(self.config.mainnet_key)
- mint_txn = self.erc1155.functions.mint(address, self.token_id, self.token_amount, "0x")\
- .buildTransaction({
- 'gas': 8000000,
- 'nonce': self.blockchain.get_transactions_count_on_mainnet(address)})
- signed_txn = self.blockchain.web3_mainnet.eth.account\
- .signTransaction(mint_txn, private_key=self.config.mainnet_key)
- self.blockchain.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
- self.blockchain.disableWhitelistERC1155(self.config.mainnet_key, self.config.schain_name)
- self.blockchain.enableAutomaticDeployERC1155(self.config.schain_key, "Mainnet")
- # send to schain
- self.agent.transfer_erc1155_from_mainnet_to_schain(self.erc1155,
- self.config.mainnet_key,
- self.config.schain_key,
- self.token_id,
- self.token_amount,
- self.timeout)
- sleep( 5 )
- amount_eth = 90 * 10 ** 15
- self.agent.transfer_eth_from_mainnet_to_schain(self.config.mainnet_key,
- self.config.schain_key,
- amount_eth,
- self.timeout)
- sleep( 5 )
- self.erc1155_clone = self.blockchain.get_erc1155_on_schain("Mainnet", self.erc1155.address)
-
- def _execute(self):
- source_address = self.blockchain.key_to_address(self.config.mainnet_key)
- destination_address = self.blockchain.key_to_address(self.config.mainnet_key)
-
- if self.erc1155_clone.functions.balanceOf(source_address, self.token_id).call() != self.token_amount:
- error("Token was not send")
- return
- sleep( 5 )
- self.agent.transfer_erc1155_from_schain_to_mainnet(
- self.erc1155_clone,
- self.erc1155,
- self.config.mainnet_key,
- self.config.schain_key,
- self.token_id,
- self.token_amount,
- 6 * 10 ** 16,
- self.timeout
- )
- #
- # erc1155 = self.blockchain.get_erc1155_on_mainnet(self.token_id)
- # new_owner_address = erc1155.functions.ownerOf(self.token_id).call()
- new_amount = self.erc1155.functions.balanceOf(destination_address, self.token_id).call()
- if self.token_amount == new_amount:
- self._mark_passed()
-
-
-test_pool.register_test(Senderc1155ToMainnet)
diff --git a/test/test_cases/send_erc20_from_mainnet_to_schain.py b/test/test_cases/send_erc20_from_mainnet_to_schain.py
deleted file mode 100644
index 0459cb4bf..000000000
--- a/test/test_cases/send_erc20_from_mainnet_to_schain.py
+++ /dev/null
@@ -1,66 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from time import sleep
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-
-
-class SendERC20ToSchain(TestCase):
- erc20 = None
-
- def __init__(self, config):
- super().__init__('Send ERC20 to schain', config)
-
- def _prepare(self):
- sleep( 5 )
- self.erc20 = self.blockchain.deploy_erc20_on_mainnet(self.config.mainnet_key, 'D2-Token', 'D2', 100)
-
- address = self.blockchain.key_to_address(self.config.mainnet_key)
- mint_txn = self.erc20.functions.mint(address, 1)\
- .buildTransaction({
- 'gas': 8000000,
- 'nonce': self.blockchain.get_transactions_count_on_mainnet(address)})
-
- signed_txn = self.blockchain.web3_mainnet.eth.account.signTransaction(mint_txn,
- private_key=self.config.mainnet_key)
- self.blockchain.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
- self.blockchain.disableWhitelistERC20(self.config.mainnet_key, self.config.schain_name)
- self.blockchain.enableAutomaticDeployERC20(self.config.schain_key, "Mainnet")
-
- def _execute(self):
- amount = 1
- self.agent.transfer_erc20_from_mainnet_to_schain(
- self.erc20,
- self.config.mainnet_key,
- self.config.schain_key,
- amount,
- 0,
- self.timeout
- )
-
- erc20 = self.blockchain.get_erc20_on_schain("Mainnet", self.erc20.address)
- destination_address = self.blockchain.key_to_address(self.config.mainnet_key)
- balance = erc20.functions.balanceOf(destination_address).call()
- if balance == amount:
- self._mark_passed()
-
-test_pool.register_test(SendERC20ToSchain)
diff --git a/test/test_cases/send_erc20_from_schain_to_mainnet.py b/test/test_cases/send_erc20_from_schain_to_mainnet.py
deleted file mode 100644
index 48e216c80..000000000
--- a/test/test_cases/send_erc20_from_schain_to_mainnet.py
+++ /dev/null
@@ -1,105 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from time import sleep
-from logging import debug, error
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-
-
-class SendERC20ToMainnet(TestCase):
- erc20 = None
- erc20_clone = None
- amount = 4
- # index of token in token_manager_erc20.sol
- index = 1
-
- def __init__(self, config):
- super().__init__('Send ERC20 from schain to mainnet', config)
-
- def _prepare(self):
- sleep( 5 )
- amountRecharge = 2 * 10 ** 18
- self.blockchain.recharge_user_wallet(self.config.mainnet_key, self.config.schain_name, amountRecharge)
- sleep( 5 )
-
- # deploy token
-
- self.erc20 = self.blockchain.deploy_erc20_on_mainnet(self.config.mainnet_key, 'D2-Token', 'D2', 100)
-
- # mint
-
- address = self.blockchain.key_to_address(self.config.mainnet_key)
- mint_txn = self.erc20.functions.mint(address, self.amount)\
- .buildTransaction({
- 'gas': 8000000,
- 'nonce': self.blockchain.get_transactions_count_on_mainnet(address)})
-
- signed_txn = self.blockchain.web3_mainnet.eth.account.signTransaction(mint_txn,
- private_key=self.config.mainnet_key)
- self.blockchain.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
- self.blockchain.disableWhitelistERC20(self.config.mainnet_key, self.config.schain_name)
- self.blockchain.enableAutomaticDeployERC20(self.config.schain_key, "Mainnet")
-
- # send to schain
-
- self.agent.transfer_erc20_from_mainnet_to_schain(self.erc20,
- self.config.mainnet_key,
- self.config.schain_key,
- self.amount,
- self.timeout)
- sleep( 5 )
-
- amount_of_eth = 90 * 10 ** 15
-
- self.agent.transfer_eth_from_mainnet_to_schain(self.config.mainnet_key,
- self.config.schain_key,
- amount_of_eth,
- self.timeout)
- sleep( 5 )
-
- self.erc20_clone = self.blockchain.get_erc20_on_schain("Mainnet", self.erc20.address)
-
- def _execute(self):
- source_address = self.blockchain.key_to_address(self.config.mainnet_key)
- destination_address = self.blockchain.key_to_address(self.config.mainnet_key)
-
- if self.erc20_clone.functions.balanceOf(source_address).call() < self.amount:
- error("Not enough tokens to send")
- return
- balance = self.erc20.functions.balanceOf(destination_address).call()
-
- self.agent.transfer_erc20_from_schain_to_mainnet(
- self.erc20_clone, # token
- self.erc20, # token on mainnet
- self.config.mainnet_key, # from
- self.config.schain_key, # to
- (self.amount - 2), # 2 tokens
- 6 * 10 ** 16,
- self.timeout
- )
-
- # if self.erc20.functions.balanceOf(destination_address).call() == balance + self.amount:
- if self.erc20.functions.balanceOf(destination_address).call() == (self.amount - 2):
- self._mark_passed()
-
-
-test_pool.register_test(SendERC20ToMainnet)
diff --git a/test/test_cases/send_erc721_from_mainnet_to_schain.py b/test/test_cases/send_erc721_from_mainnet_to_schain.py
deleted file mode 100644
index cb610ff5f..000000000
--- a/test/test_cases/send_erc721_from_mainnet_to_schain.py
+++ /dev/null
@@ -1,68 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from time import sleep
-from logging import debug
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-
-
-class SendERC721ToSchain(TestCase):
- erc721 = None
- tokenId = 1
-
- def __init__(self, config):
- super().__init__('Send ERC721 to schain', config)
-
- def _prepare(self):
- sleep( 5 )
- self.erc721 = self.blockchain.deploy_erc721_on_mainnet(self.config.mainnet_key, 'elv721', 'ELV')
-
- address = self.blockchain.key_to_address(self.config.mainnet_key)
- mint_txn = self.erc721.functions.mint(address, self.tokenId)\
- .buildTransaction({
- 'gas': 8000000,
- 'nonce': self.blockchain.get_transactions_count_on_mainnet(address)})
-
- signed_txn = self.blockchain.web3_mainnet.eth.account.signTransaction(mint_txn,
- private_key=self.config.mainnet_key)
- self.blockchain.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
- self.blockchain.disableWhitelistERC721(self.config.mainnet_key, self.config.schain_name)
- self.blockchain.enableAutomaticDeployERC721(self.config.schain_key, "Mainnet")
-
- def _execute(self):
-
- self.agent.transfer_erc721_from_mainnet_to_schain(
- self.erc721,
- self.config.mainnet_key,
- self.config.schain_key,
- self.tokenId,
- 0,
- self.timeout
- )
-
- erc721 = self.blockchain.get_erc721_on_schain("Mainnet", self.erc721.address)
- destination_address = self.blockchain.key_to_address(self.config.mainnet_key)
- new_owner_address = erc721.functions.ownerOf(self.tokenId).call()
- if destination_address == new_owner_address:
- self._mark_passed()
-
-test_pool.register_test(SendERC721ToSchain)
diff --git a/test/test_cases/send_erc721_from_schain_to_mainnet.py b/test/test_cases/send_erc721_from_schain_to_mainnet.py
deleted file mode 100644
index 957ac7c4e..000000000
--- a/test/test_cases/send_erc721_from_schain_to_mainnet.py
+++ /dev/null
@@ -1,99 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from time import sleep
-from logging import debug, error
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-
-
-class Senderc721ToMainnet(TestCase):
- erc721 = None
- erc721_clone = None
- token_id = 1
-
- def __init__(self, config):
- super().__init__('Send ERC721 from schain to mainnet', config)
-
- def _prepare(self):
- sleep( 5 )
- amountRecharge = 2 * 10 ** 18
- self.blockchain.recharge_user_wallet(self.config.mainnet_key, self.config.schain_name, amountRecharge)
- sleep( 5 )
- # deploy token
- self.erc721 = self.blockchain.deploy_erc721_on_mainnet(self.config.mainnet_key, 'elv721', 'ELV')
- # mint
- address = self.blockchain.key_to_address(self.config.mainnet_key)
- mint_txn = self.erc721.functions.mint(address, self.token_id)\
- .buildTransaction({
- 'gas': 8000000,
- 'nonce': self.blockchain.get_transactions_count_on_mainnet(address)})
- signed_txn = self.blockchain.web3_mainnet.eth.account\
- .signTransaction(mint_txn, private_key=self.config.mainnet_key)
- self.blockchain.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
- self.blockchain.disableWhitelistERC721(self.config.mainnet_key, self.config.schain_name)
- self.blockchain.enableAutomaticDeployERC721(self.config.schain_key, "Mainnet")
- # send to schain
- self.agent.transfer_erc721_from_mainnet_to_schain(self.erc721,
- self.config.mainnet_key,
- self.config.schain_key,
- self.token_id,
- self.timeout)
- sleep( 5 )
- #
- amount_eth = 90 * 10 ** 15
- #
- self.agent.transfer_eth_from_mainnet_to_schain(self.config.mainnet_key,
- self.config.schain_key,
- amount_eth,
- self.timeout)
-
- #
- sleep( 5 )
- self.erc721_clone = self.blockchain.get_erc721_on_schain("Mainnet", self.erc721.address)
-
- def _execute(self):
- source_address = self.blockchain.key_to_address(self.config.mainnet_key)
- destination_address = self.blockchain.key_to_address(self.config.mainnet_key)
-
- if self.erc721_clone.functions.ownerOf(self.token_id).call() != source_address:
- error("Token was not send")
- return
- #
- sleep( 5 )
- self.agent.transfer_erc721_from_schain_to_mainnet(
- self.erc721_clone,
- self.erc721,
- self.config.mainnet_key,
- self.config.schain_key,
- self.token_id,
- 6 * 10 ** 16,
- self.timeout
- )
- #
- # erc721 = self.blockchain.get_erc721_on_mainnet(self.token_id)
- # new_owner_address = erc721.functions.ownerOf(self.token_id).call()
- new_owner_address = self.erc721.functions.ownerOf(self.token_id).call()
- if destination_address == new_owner_address:
- self._mark_passed()
-
-
-test_pool.register_test(Senderc721ToMainnet)
diff --git a/test/test_cases/send_ether_from_schain_to_mainnet.py b/test/test_cases/send_ether_from_schain_to_mainnet.py
deleted file mode 100644
index 84b1e1732..000000000
--- a/test/test_cases/send_ether_from_schain_to_mainnet.py
+++ /dev/null
@@ -1,89 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from logging import debug
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-
-from time import sleep
-
-class SendEtherToMainnet(TestCase):
- amount = 7 * 10 ** 16 # 60 finney
- from_key = None
- to_key = None
-
- def __init__(self, config):
- super().__init__('Send ether from schain to mainnet', config)
-
- def _prepare(self):
- sleep( 5 )
- amountRecharge = 2 * 10 ** 18
- self.blockchain.recharge_user_wallet(self.config.mainnet_key, self.config.schain_name, amountRecharge)
- sleep( 5 )
-
- source_address = self.blockchain.key_to_address(self.config.schain_key)
- if self.blockchain.get_balance_on_schain(source_address) < self.amount:
- self.agent.transfer_eth_from_mainnet_to_schain(self.config.mainnet_key,
- self.config.schain_key,
- self.amount,
- timeout=self.timeout)
- min_transaction_fee = 21 * 10 ** 15
- destination_address = self.blockchain.key_to_address(self.config.mainnet_key)
- if self.blockchain.get_balance_on_mainnet(destination_address) < min_transaction_fee:
- self.blockchain.send_ether_on_mainnet(self.config.mainnet_key, self.config.mainnet_key, min_transaction_fee)
- sleep( 5 )
-
- def _execute(self):
- source_address = self.blockchain.key_to_address(self.config.mainnet_key)
- if self.blockchain.get_balance_on_schain(source_address) < self.amount:
- return
-
- debug('Balance on schain:', self.blockchain.get_balance_on_schain(source_address))
-
-
- destination_address = self.blockchain.key_to_address(self.config.mainnet_key)
- balance = self.blockchain.get_balance_on_mainnet(destination_address)
-
- debug('Destination balance:', balance)
-
- self.agent.transfer_eth_from_schain_to_mainnet(self.config.mainnet_key,
- self.config.schain_key,
- self.amount,
- self.timeout)
- sleep( 5 )
-
- transaction_fee = 6 * 10 ** 16
- approximate_gas_spends = 3 * 10 ** 15
- extra_subtract_value = 1 * 10 ** 17
-
- real_balance = self.blockchain.get_balance_on_mainnet(destination_address)
- print( 'Real balance.......', real_balance )
- expected_balance = balance + self.amount - transaction_fee - approximate_gas_spends - extra_subtract_value
- print( 'Expected balance...', expected_balance )
-
- if real_balance > expected_balance:
- print( 'Passed.............', 'YES!' )
- self._mark_passed()
- else:
- print( 'Passed.............', 'NO(' )
-
-
-test_pool.register_test(SendEtherToMainnet)
diff --git a/test/test_cases/send_ether_to_schain.py b/test/test_cases/send_ether_to_schain.py
deleted file mode 100644
index 007fa19c7..000000000
--- a/test/test_cases/send_ether_to_schain.py
+++ /dev/null
@@ -1,44 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from tools.test_case import TestCase
-from tools.test_pool import test_pool
-
-
-class SendEtherToSchain(TestCase):
- def __init__(self, config):
- super().__init__('Send ether to schain', config)
-
- def _execute(self):
- address = self.blockchain.key_to_address(self.config.mainnet_key)
- balance = self.blockchain.get_balance_on_schain(address)
- initial_balance = balance
- amount = 2 * 10 ** 15 # 2 finney
-
- self.agent.transfer_eth_from_mainnet_to_schain(self.config.mainnet_key,
- self.config.schain_key,
- amount,
- self.timeout)
-
- balance = self.blockchain.get_balance_on_schain(address)
- if balance == initial_balance + amount:
- self._mark_passed()
-
-test_pool.register_test(SendEtherToSchain)
diff --git a/test/tools/blockchain.py b/test/tools/blockchain.py
deleted file mode 100644
index 4b0da570f..000000000
--- a/test/tools/blockchain.py
+++ /dev/null
@@ -1,396 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from web3 import Web3, HTTPProvider
-import json
-from eth_account import Account
-from time import sleep
-
-class BlockChain:
- config = None
- web3_mainnet = None
- web3_schain = None
-
-
- def __init__(self, config):
- self.config = config
- self.web3_mainnet = Web3(HTTPProvider(self.config.mainnet_rpc_url))
- self.web3_schain = Web3(HTTPProvider(self.config.schain_rpc_url))
- if not self.config.user_key:
- self.config.user_key = Account.create().privateKey.hex()[2:]
-
- def get_balance_on_schain(self, address):
- eth_token = self._get_contract_on_schain('eth_erc20')
- return eth_token.functions.balanceOf(address).call()
-
- def get_balance_on_mainnet(self, address):
- return self.web3_mainnet.eth.getBalance(address)
-
- @staticmethod
- def key_to_address(key):
- return Account.privateKeyToAccount(key).address
-
- def wei_to_bigger(self, amount):
- units = {'wei': 1,
- 'babbage': 10 ** 3,
- 'lovelace': 10 ** 6,
- 'shannon': 10 ** 9,
- 'szabo': 10 ** 12,
- 'finney': 10 ** 15,
- 'ether': 10 ** 18}
-
- unit_name, new_amount = 'wei', amount
- for unit, value in units.items():
- if amount % value == 0:
- if amount // value < new_amount:
- unit_name = unit
- new_amount = amount // value
- return new_amount, unit_name
-
- def get_approved_amount(self, address):
- deposit_box_eth = self._get_contract_on_mainnet('deposit_box_eth')
- return deposit_box_eth.functions.approveTransfers(address).call()
-
- def enableAutomaticDeployERC20(self, from_key, schainName):
- sender_address = self.key_to_address(from_key)
- token_manager_erc20 = self._get_contract_on_schain('token_manager_erc20')
- enable = token_manager_erc20.encodeABI(fn_name="enableAutomaticDeploy", args=[])
- signed_txn = self.web3_schain.eth.account.signTransaction(dict(
- nonce=self.web3_schain.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_schain.eth.gasPrice,
- gas=200000,
- to=token_manager_erc20.address,
- value=0,
- data = enable
- ),
- from_key)
- self.web3_schain.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def enableAutomaticDeployERC721(self, from_key, schainName):
- sender_address = self.key_to_address(from_key)
- token_manager_erc721 = self._get_contract_on_schain('token_manager_erc721')
- enable = token_manager_erc721.encodeABI(fn_name="enableAutomaticDeploy", args=[])
- signed_txn = self.web3_schain.eth.account.signTransaction(dict(
- nonce=self.web3_schain.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_schain.eth.gasPrice,
- gas=200000,
- to=token_manager_erc721.address,
- value=0,
- data = enable
- ),
- from_key)
- self.web3_schain.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def enableAutomaticDeployERC1155(self, from_key, schainName):
- sender_address = self.key_to_address(from_key)
- token_manager_erc1155 = self._get_contract_on_schain('token_manager_erc1155')
- enable = token_manager_erc1155.encodeABI(fn_name="enableAutomaticDeploy", args=[])
- signed_txn = self.web3_schain.eth.account.signTransaction(dict(
- nonce=self.web3_schain.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_schain.eth.gasPrice,
- gas=200000,
- to=token_manager_erc1155.address,
- value=0,
- data = enable
- ),
- from_key)
- self.web3_schain.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def disableWhitelistERC20(self, from_key, schainName):
- sender_address = self.key_to_address(from_key)
- deposit_box_erc20 = self._get_contract_on_mainnet('deposit_box_erc20')
- disable = deposit_box_erc20.encodeABI(fn_name="disableWhitelist", args=[schainName])
- signed_txn = self.web3_mainnet.eth.account.signTransaction(dict(
- nonce=self.web3_mainnet.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_mainnet.eth.gasPrice,
- gas=200000,
- to=deposit_box_erc20.address,
- value=0,
- data = disable
- ),
- from_key)
- self.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def disableWhitelistERC721(self, from_key, schainName):
- sender_address = self.key_to_address(from_key)
- deposit_box_erc721 = self._get_contract_on_mainnet('deposit_box_erc721')
- disable = deposit_box_erc721.encodeABI(fn_name="disableWhitelist", args=[schainName])
- signed_txn = self.web3_mainnet.eth.account.signTransaction(dict(
- nonce=self.web3_mainnet.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_mainnet.eth.gasPrice,
- gas=200000,
- to=deposit_box_erc721.address,
- value=0,
- data = disable
- ),
- from_key)
- self.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def disableWhitelistERC1155(self, from_key, schainName):
- sender_address = self.key_to_address(from_key)
- deposit_box_erc1155 = self._get_contract_on_mainnet('deposit_box_erc1155')
- disable = deposit_box_erc1155.encodeABI(fn_name="disableWhitelist", args=[schainName])
- signed_txn = self.web3_mainnet.eth.account.signTransaction(dict(
- nonce=self.web3_mainnet.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_mainnet.eth.gasPrice,
- gas=200000,
- to=deposit_box_erc1155.address,
- value=0,
- data = disable
- ),
- from_key)
- self.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def addERC20TokenByOwner(self, from_key, schainName, erc20Address):
- sender_address = self.key_to_address(from_key)
- deposit_box_erc20 = self._get_contract_on_mainnet('deposit_box_erc20')
- disable = deposit_box_erc20.encodeABI(fn_name="addERC20TokenByOwner", args=[schainName, erc20Address])
- signed_txn = self.web3_mainnet.eth.account.signTransaction(dict(
- nonce=self.web3_mainnet.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_mainnet.eth.gasPrice,
- gas=200000,
- to=deposit_box_erc20.address,
- value=0,
- data = disable
- ),
- from_key)
- self.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def addERC721TokenByOwner(self, from_key, schainName, erc20Address):
- sender_address = self.key_to_address(from_key)
- deposit_box_erc721 = self._get_contract_on_mainnet('deposit_box_erc721')
- disable = deposit_box_erc721.encodeABI(fn_name="addERC721TokenByOwner", args=[schainName, erc20Address])
- signed_txn = self.web3_mainnet.eth.account.signTransaction(dict(
- nonce=self.web3_mainnet.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_mainnet.eth.gasPrice,
- gas=200000,
- to=deposit_box_erc721.address,
- value=0,
- data = disable
- ),
- from_key)
- self.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def addERC1155TokenByOwner(self, from_key, schainName, erc20Address):
- sender_address = self.key_to_address(from_key)
- deposit_box_erc1155 = self._get_contract_on_mainnet('deposit_box_erc1155')
- disable = deposit_box_erc1155.encodeABI(fn_name="addERC1155TokenByOwner", args=[schainName, erc20Address])
- signed_txn = self.web3_mainnet.eth.account.signTransaction(dict(
- nonce=self.web3_mainnet.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_mainnet.eth.gasPrice,
- gas=200000,
- to=deposit_box_erc1155.address,
- value=0,
- data = disable
- ),
- from_key)
- self.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def add_eth_cost(self, from_key, amount):
- sender_address = self.key_to_address(from_key)
- token_manager = self._get_contract_on_schain('token_manager')
- add_eth_cost_encode_abi = token_manager.encodeABI(fn_name="addEthCostWithoutAddress", args=[amount])
- signed_txn = self.web3_schain.eth.account.signTransaction(dict(
- nonce=self.web3_schain.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_schain.eth.gasPrice,
- gas=200000,
- to=token_manager.address,
- value=0,
- data = add_eth_cost_encode_abi
- ),
- from_key)
- self.web3_schain.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def send_ether_on_mainnet(self, from_key, to_key, amount_wei):
- sender_address = self.key_to_address(from_key)
- recipient_address = self.key_to_address(to_key)
- signed_txn = self.web3_mainnet.eth.account.signTransaction(dict(
- nonce=self.web3_mainnet.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_mainnet.eth.gasPrice,
- gas=100000,
- to=recipient_address,
- value=amount_wei
- ),
- from_key)
-
- self.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def recharge_user_wallet(self, from_key, schainName, amount_wei):
- sender_address = self.key_to_address(from_key)
- community_pool = self._get_contract_on_mainnet('community_pool')
- recharge_abi = community_pool.encodeABI(fn_name="rechargeUserWallet", args=[schainName, sender_address])
- signed_txn = self.web3_mainnet.eth.account.signTransaction(dict(
- nonce=self.web3_mainnet.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_mainnet.eth.gasPrice,
- gas=200000,
- to=community_pool.address,
- value=amount_wei,
- data = recharge_abi
- ),
- from_key)
- self.web3_mainnet.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def set_time_limit_per_message(self, from_key, time_limit):
- sender_address = self.key_to_address(from_key)
- community_locker = self._get_contract_on_schain('community_locker')
- time_limit_abi = community_locker.encodeABI(fn_name="setTimeLimitPerMessage", args=["Mainnet", time_limit])
- signed_txn = self.web3_schain.eth.account.signTransaction(dict(
- nonce=self.web3_schain.eth.getTransactionCount(sender_address),
- gasPrice=self.web3_schain.eth.gasPrice,
- gas=200000,
- to=community_locker.address,
- value=0,
- data=time_limit_abi
- ),
- from_key)
- self.web3_schain.eth.sendRawTransaction(signed_txn.rawTransaction)
-
- def deploy_erc20_on_mainnet(self, private_key, name, symbol, decimals):
- return self._deploy_contract_to_mainnet(self.config.test_root + '/resources/ERC20MintableDetailed.json',
- [name, symbol, decimals],
- private_key)
- def deploy_erc721_on_mainnet(self, private_key, name, symbol):
- return self._deploy_contract_to_mainnet(self.config.test_root + '/resources/ERC721FullMetadataMintable.json',
- [name, symbol],
- private_key)
-
- def deploy_erc1155_on_mainnet(self, private_key, uri):
- return self._deploy_contract_to_mainnet(self.config.test_root + '/resources/ERC1155BurnableMintable.json',
- [uri],
- private_key)
-
- def get_transactions_count_on_mainnet(self, address):
- return self.web3_mainnet.eth.getTransactionCount(address)
-
- def get_erc20_on_schain(self, schain_name, erc20_address_mainnet):
- lock_erc20 = self._get_contract_on_schain('token_manager_erc20')
- mainnet_hash = Web3.solidityKeccak(['string'], ["Mainnet"])
- erc20_address = lock_erc20.functions.clonesErc20(mainnet_hash, erc20_address_mainnet).call()
- if erc20_address == '0x0000000000000000000000000000000000000000':
- raise ValueError('No such token')
- with open(self.config.proxy_root + '/artifacts/contracts/schain/tokens/ERC20OnChain.sol/ERC20OnChain.json') as erc20_on_chain_file:
- erc20_on_chain_json = json.load(erc20_on_chain_file)
- return self.web3_schain.eth.contract(address=erc20_address, abi=erc20_on_chain_json['abi'])
-
- def get_erc721_on_schain(self, schain_name, erc721_address_mainnet):
- lock_erc721 = self._get_contract_on_schain('token_manager_erc721')
- mainnet_hash = Web3.solidityKeccak(['string'], ["Mainnet"])
- erc721_address = lock_erc721.functions.clonesErc721(mainnet_hash, erc721_address_mainnet).call()
- if erc721_address == '0x0000000000000000000000000000000000000000':
- raise ValueError('No such token')
- with open(self.config.proxy_root + '/artifacts/contracts/schain/tokens/ERC721OnChain.sol/ERC721OnChain.json') as erc721_on_chain_file:
- erc721_on_chain_json = json.load(erc721_on_chain_file)
- return self.web3_schain.eth.contract(address=erc721_address, abi=erc721_on_chain_json['abi'])
-
- def get_erc1155_on_schain(self, schain_name, erc1155_address_mainnet):
- lock_erc1155 = self._get_contract_on_schain('token_manager_erc1155')
- mainnet_hash = Web3.solidityKeccak(['string'], ["Mainnet"])
- erc1155_address = lock_erc1155.functions.clonesErc1155(mainnet_hash, erc1155_address_mainnet).call()
- if erc1155_address == '0x0000000000000000000000000000000000000000':
- raise ValueError('No such token')
- with open(self.config.proxy_root + '/artifacts/contracts/schain/tokens/ERC1155OnChain.sol/ERC1155OnChain.json') as erc1155_on_chain_file:
- erc1155_on_chain_json = json.load(erc1155_on_chain_file)
- return self.web3_schain.eth.contract(address=erc1155_address, abi=erc1155_on_chain_json['abi'])
-
- def get_erc20_on_mainnet(self, index):
- lock_erc20 = self._get_contract_on_mainnet('deposit_box_erc20')
- erc20_address = lock_erc20.functions.erc20Tokens(index).call()
- if erc20_address == '0x0000000000000000000000000000000000000000':
- raise ValueError('No such token')
- with open(self.config.test_resource_dir + '/ERC20MintableDetailed.json') as erc20_file:
- erc20_on_mainnet_json = json.load(erc20_file)
- return self.web3_schain.eth.contract(address=erc20_address, abi=erc20_on_mainnet_json['abi'])
-
- def get_erc721_on_mainnet(self, index):
- lock_erc721 = self._get_contract_on_mainnet('deposit_box_erc721')
- erc721_address = lock_erc721.functions.erc721Tokens(index).call()
- if erc721_address == '0x0000000000000000000000000000000000000000':
- raise ValueError('No such token')
- with open(self.config.test_resource_dir + '/ERC721FullMetadataMintable.json') as erc721_file:
- erc721_on_mainnet_json = json.load(erc721_file)
- return self.web3_schain.eth.contract(address=erc721_address, abi=erc721_on_mainnet_json['abi'])
-
- def get_erc1155_on_mainnet(self, index):
- lock_erc1155 = self._get_contract_on_mainnet('deposit_box_erc1155')
- erc1155_address = lock_erc1155.functions.erc1155Tokens(index).call()
- if erc1155_address == '0x0000000000000000000000000000000000000000':
- raise ValueError('No such token')
- with open(self.config.test_resource_dir + '/ERC1155BurnableMintable.json') as erc1155_file:
- erc1155_on_mainnet_json = json.load(erc1155_file)
- return self.web3_schain.eth.contract(address=erc1155_address, abi=erc1155_on_mainnet_json['abi'])
-
- # private
-
- def _get_contact(self, web3, json_filename, name):
- with open(json_filename) as abi_file:
- abis = json.load(abi_file)
- contract = web3.eth.contract(
- address=abis[name + '_address'],
- abi=abis[name + '_abi']
- )
- return contract
-
- def _get_contract_on_schain(self, name):
- return self._get_contact(self.web3_schain, self.config.abi_schain, name)
-
- def _get_contract_on_mainnet(self, name):
- return self._get_contact(self.web3_mainnet, self.config.abi_mainnet, name)
-
- @staticmethod
- def _deploy_contract_from_json(web3, json_filename, constructor_arguments, private_key):
- with open(json_filename) as json_file:
- address = BlockChain.key_to_address(private_key)
-
- json_contract = json.load(json_file)
- abi = json_contract['abi']
- bytecode = json_contract['bytecode']
- contract = web3.eth.contract(abi=abi, bytecode=bytecode)
-
- nonce = web3.eth.getTransactionCount(address)
-
- deploy_txn = contract.constructor(*constructor_arguments).buildTransaction({
- 'gas': 4712388,
- 'gasPrice': web3.toWei('1', 'gwei'),
- 'nonce': nonce,
- })
- signed_txn = web3.eth.account.signTransaction(deploy_txn, private_key=private_key)
- transaction_hash = web3.eth.sendRawTransaction(signed_txn.rawTransaction)
- #
- receipt = BlockChain.await_receipt(web3, transaction_hash)
- #
- contract = web3.eth.contract(address=receipt.contractAddress, abi=abi)
- return contract
-
- @staticmethod
- def await_receipt(web3, tx, retries=10, timeout=5):
- for _ in range(0, retries):
- receipt = BlockChain.get_receipt(web3, tx)
- if (receipt != None):
- return receipt
- sleep( timeout )
- return None
-
- @staticmethod
- def get_receipt(web3, tx):
- return web3.eth.getTransactionReceipt(tx)
-
- def _deploy_contract_to_mainnet(self, json_filename, constructor_arguments, private_key):
- return self._deploy_contract_from_json(self.web3_mainnet, json_filename, constructor_arguments, private_key)
-
diff --git a/test/tools/config.py b/test/tools/config.py
deleted file mode 100644
index 763e2e795..000000000
--- a/test/tools/config.py
+++ /dev/null
@@ -1,70 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-class Config:
- src_root = '.'
- agent_root = 'agent'
- skale_ima_root = 'npms/skale-ima'
- proxy_root = 'proxy'
- test_root = 'test'
- test_working_dir = 'working'
- test_resource_dir = 'resources'
- network_for_mainnet = 'mainnet'
- network_for_schain = 'schain'
- mainnet_key=''
- mainnet_rpc_url='http://localhost:8545'
- schain_key = ''
- schain_rpc_url = 'http://localhost:8545'
- schain_name = 'd2'
- schain_name_2 = 'd3'
- abi_mainnet = 'data/proxyMainnet.json'
- abi_schain = 'data/proxySchain_'
- abi_schain_2 = 'data/proxySchain_'
- user_key = ''
-
- def __init__(self, src_root, config_json):
- self.src_root = src_root
- self.proxy_root = src_root + '/' + self.proxy_root
- self.agent_root = src_root + '/' + self.agent_root
- self.skale_ima_root = src_root + '/' + self.skale_ima_root
- self.test_root = src_root + '/' + self.test_root
- self.test_working_dir = self.test_root + '/' + self.test_working_dir
- self.test_resource_dir = self.test_root + '/' + self.test_resource_dir
-
- if 'NETWORK_FOR_ETHEREUM' in config_json:
- self.network_for_mainnet = config_json['NETWORK_FOR_ETHEREUM']
- if 'NETWORK_FOR_SCHAIN' in config_json:
- self.network_for_schain = config_json['NETWORK_FOR_SCHAIN']
- self.mainnet_key = config_json['PRIVATE_KEY_FOR_ETHEREUM']
- if 'URL_W3_ETHEREUM' in config_json:
- self.mainnet_rpc_url = config_json['URL_W3_ETHEREUM']
- self.schain_key = config_json['PRIVATE_KEY_FOR_SCHAIN']
- if 'URL_W3_S_CHAIN' in config_json:
- self.schain_rpc_url = config_json['URL_W3_S_CHAIN']
- if 'CHAIN_NAME_SCHAIN' in config_json:
- self.schain_name = config_json['CHAIN_NAME_SCHAIN']
- if 'user_key' in config_json:
- self.user_key = config_json['user_key']
-
- self.abi_mainnet = self.proxy_root + '/' + self.abi_mainnet
- self.abi_schain = self.proxy_root + '/' + self.abi_schain + self.schain_name + '.json'
- self.abi_schain_2 = self.proxy_root + '/' + self.abi_schain_2 + self.schain_name_2 + '.json'
-
-
diff --git a/test/tools/config_generator.py b/test/tools/config_generator.py
deleted file mode 100644
index 3cbc955b8..000000000
--- a/test/tools/config_generator.py
+++ /dev/null
@@ -1,50 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-import json
-from tools.config import Config
-
-def config_generator(src_root, json_filename):
- def _internal_config_generator(current_preconfig):
- if type(current_preconfig) is not dict:
- raise TypeError('Config should be a dictionary')
-
- is_config = True
- for key, value in current_preconfig.items():
- if type(value) is list:
- is_config = False
- for current_value in value:
- if type(current_value) is dict:
- preconfig_copy = current_preconfig.copy()
- preconfig_copy.pop(key)
- for config_object in _internal_config_generator({**preconfig_copy, **current_value}):
- yield config_object
- else:
- for config_object in _internal_config_generator({**current_preconfig, key: value}):
- yield config_object
- break
-
- if is_config:
- yield Config(src_root, current_preconfig)
-
- with open(json_filename) as config_file:
- preconfig = json.load(config_file)
- for config in _internal_config_generator(preconfig):
- yield config
diff --git a/test/tools/environment.py b/test/tools/environment.py
deleted file mode 100644
index e5375d166..000000000
--- a/test/tools/environment.py
+++ /dev/null
@@ -1,24 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-class Environment:
-
- def prepare(self):
- pass
diff --git a/test/tools/test_case.py b/test/tools/test_case.py
deleted file mode 100644
index cdf973e79..000000000
--- a/test/tools/test_case.py
+++ /dev/null
@@ -1,90 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from tools.blockchain import BlockChain
-from proxy.deployer import Deployer
-from agent.agent import Agent
-from time import time
-from logging import error
-
-class TestCase:
- name = None
- deployer = None
- agent = None
- passed = False
- blockchain = None
- config = None
- time_started = time()
- timeout = None
- timeout_of_entire_test = None
-
- def __init__(self, name, config, timeout=10, timeout_of_entire_test=80000):
- self.name = name
- self.deployer = Deployer(config)
- self.agent = Agent(config)
- self.blockchain = BlockChain(config)
- self.config = config
- self.timeout = timeout
- self.timeout_of_entire_test = timeout_of_entire_test
-
-
- def prepare(self):
- self.deployer.deploy()
- self.agent.register()
- self.agent.start()
- self._prepare()
-
- def execute(self):
- self.time_started = time()
- self._execute()
- if self._timeout():
- error(f'CRITICAL INTEGRATION TEST ERROR: Test "{self.name}" will be marked failed due to timeout')
- self.passed = False
-
- def clean_up(self):
- self.agent.stop()
- self._clean_up()
-
- def is_passed(self):
- return self.passed
-
- def get_name(self):
- return self.name
-
- # protected
-
- def _prepare(self):
- pass
-
- def _execute(self):
- pass
-
- def _clean_up(self):
- pass
-
- def _mark_passed(self):
- self.passed = True
-
- def _timeout(self):
- if self.timeout is not None and time() > self.time_started + self.timeout_of_entire_test:
- return True
- else:
- return False
- return False
diff --git a/test/tools/test_pool.py b/test/tools/test_pool.py
deleted file mode 100644
index 3ea984627..000000000
--- a/test/tools/test_pool.py
+++ /dev/null
@@ -1,32 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-class TestPool:
- tests = []
-
- def get_tests(self, config):
- return [test(config) for test in self.tests]
-
-
- def register_test(self, test):
- self.tests.append(test)
-
-
-test_pool = TestPool()
\ No newline at end of file
diff --git a/test/tools/test_runner.py b/test/tools/test_runner.py
deleted file mode 100644
index 638ca0d36..000000000
--- a/test/tools/test_runner.py
+++ /dev/null
@@ -1,62 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from logging import info, error
-
-from tools.config_generator import config_generator
-from tools.test_pool import test_pool
-
-from test_cases import *
-# Do not remove this unused import. It is needed for tests registration
-
-
-class TestRunner:
- src_root = None
- config_filename = 'config.json'
- tests = None
-
- def __init__(self, src_root, config_filename, tests):
- self.src_root = src_root
- self.config_filename = config_filename
- self.tests = tests
-
- def run(self):
- for config in config_generator(self.src_root, self.config_filename):
- for test in test_pool.get_tests(config):
- test_name = test.get_name()
- if self.tests is not None and test_name not in self.tests:
- info(f'Skip test {test_name}')
- continue
- else:
- info(f'Execute test {test_name}')
-
- info(f'Preparing test {test_name}')
- test.prepare()
- info(f'Starting test {test_name}')
- test.execute()
- info(f'Cleaning up after test {test_name}')
- test.clean_up()
-
- if test.is_passed():
- info(f'Test "{test_name}" passed')
- else:
- error(f'CRITICAL INTEGRATION TEST ERROR: Test "{test_name}" failed')
- exit(1)
- info('All tests passed')
diff --git a/test/tools/utils.py b/test/tools/utils.py
deleted file mode 100644
index 40d04a4df..000000000
--- a/test/tools/utils.py
+++ /dev/null
@@ -1,31 +0,0 @@
-# SPDX-License-Identifier: AGPL-3.0-only
-# -*- coding: utf-8 -*-
-#
-# This file is part of SKALE IMA.
-#
-# Copyright (C) 2019-Present SKALE Labs
-#
-# SKALE IMA is free software: you can redistribute it and/or modify
-# it under the terms of the GNU Affero General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# SKALE IMA is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU Affero General Public License for more details.
-#
-# You should have received a copy of the GNU Affero General Public License
-# along with SKALE IMA. If not, see .
-
-from logging import error
-
-from os import system
-
-def execute(command: str, print_command=False):
- if print_command:
- print('Execute:', command)
- exit_code = system(command)
- if exit_code:
- error(f'CRITICAL INTEGRATION TEST ERROR: Command "{command}" failed with exit code {exit_code}')
- exit(1)