From ce33185ca14d85d95813765e314a680df34caaba Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Fri, 27 Aug 2021 10:21:21 +0300 Subject: [PATCH 01/22] Add script test_faucet.py (166-faucet) --- proxy/test_faucet.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 proxy/test_faucet.py diff --git a/proxy/test_faucet.py b/proxy/test_faucet.py new file mode 100644 index 000000000..60c18df54 --- /dev/null +++ b/proxy/test_faucet.py @@ -0,0 +1,16 @@ +import unittest + +class Test_Faucet(unittest.TestCase): + @classmethod + def setUpClass(cls): + print("\n\nTest Faucet Started") + + @classmethod + def tearDownClass(cls): + print("\nTest Faucet Finished") + + def test_env(self): + print("# test_env") + +if __name__ == '__main__': + unittest.main() From 18a4081c672f583ba60fb2e51e734cc664825b85 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Fri, 27 Aug 2021 11:47:58 +0300 Subject: [PATCH 02/22] Add faucet service to docker-compose-test.yml (166-faucet) --- proxy/docker-compose-test.yml | 14 ++++++++++++++ proxy/test_faucet.py | 9 ++++++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/proxy/docker-compose-test.yml b/proxy/docker-compose-test.yml index 7c42a2cd6..5b36c6a26 100644 --- a/proxy/docker-compose-test.yml +++ b/proxy/docker-compose-test.yml @@ -34,5 +34,19 @@ services: networks: - net + faucet: + container_name: faucet + image: cybercoredev/faucet:${REVISION} + environment: + - WEB3_RPC_URL=http://localhost:9090/solana + - WEB3_PRIVATE_KEY=0x0000000000000000000000000000000000000000000000000000000000000Ace + hostname: faucet + ports: + - 127.0.0.1:3333:3333 + expose: + - "3333" + networks: + - net + networks: net: diff --git a/proxy/test_faucet.py b/proxy/test_faucet.py index 60c18df54..9ffa3ecfa 100644 --- a/proxy/test_faucet.py +++ b/proxy/test_faucet.py @@ -5,12 +5,15 @@ class Test_Faucet(unittest.TestCase): def setUpClass(cls): print("\n\nTest Faucet Started") + def test_env(self): + print("\n# test_env") + + def test_config(self): + print("\n# test_config") + @classmethod def tearDownClass(cls): print("\nTest Faucet Finished") - def test_env(self): - print("# test_env") - if __name__ == '__main__': unittest.main() From d7bbec569fe9e35902fd117e1cd763018c152759 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Mon, 30 Aug 2021 09:22:29 +0300 Subject: [PATCH 03/22] No need for container for faucet (166-faucet) --- proxy/docker-compose-test.yml | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/proxy/docker-compose-test.yml b/proxy/docker-compose-test.yml index 5b36c6a26..7c42a2cd6 100644 --- a/proxy/docker-compose-test.yml +++ b/proxy/docker-compose-test.yml @@ -34,19 +34,5 @@ services: networks: - net - faucet: - container_name: faucet - image: cybercoredev/faucet:${REVISION} - environment: - - WEB3_RPC_URL=http://localhost:9090/solana - - WEB3_PRIVATE_KEY=0x0000000000000000000000000000000000000000000000000000000000000Ace - hostname: faucet - ports: - - 127.0.0.1:3333:3333 - expose: - - "3333" - networks: - - net - networks: net: From 49c914409d33e9a80c8e9c11a124bc19445dd90e Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Wed, 22 Sep 2021 12:37:28 +0300 Subject: [PATCH 04/22] Create test for faucet (166-faucet) --- proxy/test_faucet.py | 19 ------------------- proxy/test_neon_faucet.py | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 19 deletions(-) delete mode 100644 proxy/test_faucet.py create mode 100644 proxy/test_neon_faucet.py diff --git a/proxy/test_faucet.py b/proxy/test_faucet.py deleted file mode 100644 index 9ffa3ecfa..000000000 --- a/proxy/test_faucet.py +++ /dev/null @@ -1,19 +0,0 @@ -import unittest - -class Test_Faucet(unittest.TestCase): - @classmethod - def setUpClass(cls): - print("\n\nTest Faucet Started") - - def test_env(self): - print("\n# test_env") - - def test_config(self): - print("\n# test_config") - - @classmethod - def tearDownClass(cls): - print("\nTest Faucet Finished") - -if __name__ == '__main__': - unittest.main() diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py new file mode 100644 index 000000000..d053f45b2 --- /dev/null +++ b/proxy/test_neon_faucet.py @@ -0,0 +1,37 @@ +# File: test_neon_faucet.py +# Test for the faucet service. + +import unittest +import os + +class Test_Neon_Faucet(unittest.TestCase): + @classmethod + def setUpClass(cls): + os.environ['FAUCET_RPC_PORT'] = '3333' + os.environ['FAUCET_RPC_ALLOWED_ORIGINS'] = 'http://localhost' + os.environ['FAUCET_WEB3_ENABLE'] = 'false' + os.environ['WEB3_RPC_URL'] = 'http://localhost:9090/solana' + os.environ['WEB3_PRIVATE_KEY'] = '0x0000000000000000000000000000000000000000000000000000000000000Ace' + os.environ['NEON_ERC20_TOKENS'] = '0x00000000000000000000000000000000CafeBabe, 0x00000000000000000000000000000000DeadBeef' + os.environ['NEON_ERC20_MAX_AMOUNT'] = '1000' + os.environ['FAUCET_SOLANA_ENABLE'] = 'true' + os.environ['SOLANA_URL'] = 'http://localhost:8899' + os.environ['EVM_LOADER'] = 'EvmLoaderId11111111111111111111111111111111' + os.environ['NEON_TOKEN_MINT'] = 'TokenMintId11111111111111111111111111111111' + os.environ['NEON_TOKEN_MINT_DECIMALS'] = '9' + os.environ['NEON_OPERATOR_KEYFILE'] = 'id.json' + os.environ['NEON_ETH_MAX_AMOUNT'] = '10' + os.system('faucet run --workers 1') + + def test_eth_token(self): + print("\n# test_eth_token") + + def test_erc20_tokens(self): + print("\n# test_erc20_tokens") + + @classmethod + def tearDownClass(cls): + print("\nTest Neon Faucet finished") + +if __name__ == '__main__': + unittest.main() From 0ef9665fbf98cc5814a4067275cac9952be79afb Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Wed, 22 Sep 2021 19:17:24 +0300 Subject: [PATCH 05/22] Add port 3333 in container to use by faucet service (166-faucet) --- proxy/docker-compose-test.yml | 1 + proxy/test_neon_faucet.py | 12 ++++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/proxy/docker-compose-test.yml b/proxy/docker-compose-test.yml index b16c0da3d..590f74bd8 100644 --- a/proxy/docker-compose-test.yml +++ b/proxy/docker-compose-test.yml @@ -24,6 +24,7 @@ services: - CONFIG=ci hostname: proxy ports: + - 127.0.0.1:3333:3333 - 127.0.0.1:9090:9090 expose: - "9090" diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index d053f45b2..850aaa2d7 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -3,6 +3,8 @@ import unittest import os +import io +import subprocess class Test_Neon_Faucet(unittest.TestCase): @classmethod @@ -21,7 +23,7 @@ def setUpClass(cls): os.environ['NEON_TOKEN_MINT_DECIMALS'] = '9' os.environ['NEON_OPERATOR_KEYFILE'] = 'id.json' os.environ['NEON_ETH_MAX_AMOUNT'] = '10' - os.system('faucet run --workers 1') + cls.faucet = subprocess.Popen(['faucet', 'run', '--workers', '1'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) def test_eth_token(self): print("\n# test_eth_token") @@ -31,7 +33,13 @@ def test_erc20_tokens(self): @classmethod def tearDownClass(cls): - print("\nTest Neon Faucet finished") + print('1') + with io.TextIOWrapper(cls.faucet.stdout, encoding="utf-8") as out: + for line in out: + print(line.strip()) + print('2') + cls.faucet.terminate() + print('3') if __name__ == '__main__': unittest.main() From ee58f06514784b24a30b0c379f1df355192d8345 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Wed, 22 Sep 2021 20:34:12 +0300 Subject: [PATCH 06/22] Start and stop the faucet service (166-faucet) --- proxy/test_neon_faucet.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index 850aaa2d7..e0558b8aa 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -4,7 +4,9 @@ import unittest import os import io +import time import subprocess +import requests class Test_Neon_Faucet(unittest.TestCase): @classmethod @@ -24,6 +26,7 @@ def setUpClass(cls): os.environ['NEON_OPERATOR_KEYFILE'] = 'id.json' os.environ['NEON_ETH_MAX_AMOUNT'] = '10' cls.faucet = subprocess.Popen(['faucet', 'run', '--workers', '1'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + time.sleep(1) def test_eth_token(self): print("\n# test_eth_token") @@ -33,13 +36,10 @@ def test_erc20_tokens(self): @classmethod def tearDownClass(cls): - print('1') + requests.post('http://localhost:{}/request_stop'.format(os.environ['FAUCET_RPC_PORT']), data='{"delay": 1000}') with io.TextIOWrapper(cls.faucet.stdout, encoding="utf-8") as out: for line in out: print(line.strip()) - print('2') - cls.faucet.terminate() - print('3') if __name__ == '__main__': unittest.main() From 09e9a4f532a50e3a94b29c5a5b482c277847b165 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Thu, 23 Sep 2021 15:05:24 +0300 Subject: [PATCH 07/22] First successful request (166-faucet) --- proxy/docker-compose-test.yml | 3 ++- proxy/test_neon_faucet.py | 20 +++++++++++++------- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/proxy/docker-compose-test.yml b/proxy/docker-compose-test.yml index 590f74bd8..22b00c916 100644 --- a/proxy/docker-compose-test.yml +++ b/proxy/docker-compose-test.yml @@ -24,8 +24,9 @@ services: - CONFIG=ci hostname: proxy ports: - - 127.0.0.1:3333:3333 - 127.0.0.1:9090:9090 + - 127.0.0.1:8899:8899 + - 127.0.0.1:3333:3333 expose: - "9090" networks: diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index e0558b8aa..b4233baab 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -19,24 +19,30 @@ def setUpClass(cls): os.environ['NEON_ERC20_TOKENS'] = '0x00000000000000000000000000000000CafeBabe, 0x00000000000000000000000000000000DeadBeef' os.environ['NEON_ERC20_MAX_AMOUNT'] = '1000' os.environ['FAUCET_SOLANA_ENABLE'] = 'true' - os.environ['SOLANA_URL'] = 'http://localhost:8899' - os.environ['EVM_LOADER'] = 'EvmLoaderId11111111111111111111111111111111' - os.environ['NEON_TOKEN_MINT'] = 'TokenMintId11111111111111111111111111111111' + os.environ['SOLANA_URL'] = 'http://solana:8899' + os.environ['EVM_LOADER'] = '53DfF883gyixYNXnM7s5xhdeyV8mVk9T4i2hGV9vG9io' + os.environ['NEON_TOKEN_MINT'] = 'HPsV9Deocecw3GeZv1FkAPNCBRfuVyfw9MMwjwRe1xaU' os.environ['NEON_TOKEN_MINT_DECIMALS'] = '9' - os.environ['NEON_OPERATOR_KEYFILE'] = 'id.json' + os.environ['NEON_OPERATOR_KEYFILE'] = '/root/.config/solana/id.json' os.environ['NEON_ETH_MAX_AMOUNT'] = '10' cls.faucet = subprocess.Popen(['faucet', 'run', '--workers', '1'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - time.sleep(1) + print('Sleeping 1 sec...') + time.sleep(1) # 1 second def test_eth_token(self): - print("\n# test_eth_token") + url = 'http://localhost:{}/request_eth_token'.format(os.environ['FAUCET_RPC_PORT']) + data = '{"wallet": "0x4570e07200b6332989Dc04fA2a671b839D26eF0E", "amount": 1}' + r = requests.post(url, data=data) + print('r:',r) def test_erc20_tokens(self): print("\n# test_erc20_tokens") @classmethod def tearDownClass(cls): - requests.post('http://localhost:{}/request_stop'.format(os.environ['FAUCET_RPC_PORT']), data='{"delay": 1000}') + url = 'http://localhost:{}/request_stop'.format(os.environ['FAUCET_RPC_PORT']) + data = '{"delay": 1000}' # 1 second + requests.post(url, data=data) with io.TextIOWrapper(cls.faucet.stdout, encoding="utf-8") as out: for line in out: print(line.strip()) From 61072d99e5e3dee8e5f19461d67db2b9586faec9 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Thu, 23 Sep 2021 15:47:07 +0300 Subject: [PATCH 08/22] Implement test_eth_token (166-faucet) --- proxy/test_neon_faucet.py | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index b4233baab..b4a19091a 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -7,6 +7,10 @@ import time import subprocess import requests +from web3 import Web3 + +proxy_url = os.environ.get('PROXY_URL', 'http://localhost:9090/solana') +proxy = Web3(Web3.HTTPProvider(proxy_url)) class Test_Neon_Faucet(unittest.TestCase): @classmethod @@ -30,13 +34,20 @@ def setUpClass(cls): time.sleep(1) # 1 second def test_eth_token(self): + print() + address = '0x1111111111111111111111111111111111111111' + balance_before = proxy.eth.get_balance(address) + print('balance_before:', balance_before) url = 'http://localhost:{}/request_eth_token'.format(os.environ['FAUCET_RPC_PORT']) - data = '{"wallet": "0x4570e07200b6332989Dc04fA2a671b839D26eF0E", "amount": 1}' + data = '{"wallet": "' + address + '", "amount": 1}' r = requests.post(url, data=data) - print('r:',r) + assert(r.ok) + balance_after = proxy.eth.get_balance(address) + print('balance_after:', balance_after) + self.assertEqual(balance_after - balance_before, 1000000000000000000) def test_erc20_tokens(self): - print("\n# test_erc20_tokens") + print() @classmethod def tearDownClass(cls): From a16238cb0545e9bece9e01b903aee9d3240498dc Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Thu, 23 Sep 2021 18:13:13 +0300 Subject: [PATCH 09/22] Developing test_erc20_tokens (166-faucet) --- proxy/test_neon_faucet.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index b4a19091a..8ff5dfd57 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -17,8 +17,8 @@ class Test_Neon_Faucet(unittest.TestCase): def setUpClass(cls): os.environ['FAUCET_RPC_PORT'] = '3333' os.environ['FAUCET_RPC_ALLOWED_ORIGINS'] = 'http://localhost' - os.environ['FAUCET_WEB3_ENABLE'] = 'false' - os.environ['WEB3_RPC_URL'] = 'http://localhost:9090/solana' + os.environ['FAUCET_WEB3_ENABLE'] = 'true' + os.environ['WEB3_RPC_URL'] = proxy_url os.environ['WEB3_PRIVATE_KEY'] = '0x0000000000000000000000000000000000000000000000000000000000000Ace' os.environ['NEON_ERC20_TOKENS'] = '0x00000000000000000000000000000000CafeBabe, 0x00000000000000000000000000000000DeadBeef' os.environ['NEON_ERC20_MAX_AMOUNT'] = '1000' @@ -33,6 +33,7 @@ def setUpClass(cls): print('Sleeping 1 sec...') time.sleep(1) # 1 second + @unittest.skip("a.i.") def test_eth_token(self): print() address = '0x1111111111111111111111111111111111111111' @@ -41,19 +42,31 @@ def test_eth_token(self): url = 'http://localhost:{}/request_eth_token'.format(os.environ['FAUCET_RPC_PORT']) data = '{"wallet": "' + address + '", "amount": 1}' r = requests.post(url, data=data) + if not r.ok: + print('Response:', r.status_code) assert(r.ok) balance_after = proxy.eth.get_balance(address) print('balance_after:', balance_after) self.assertEqual(balance_after - balance_before, 1000000000000000000) + # @unittest.skip("a.i.") def test_erc20_tokens(self): print() + address = '0x1111111111111111111111111111111111111111' + url = 'http://localhost:{}/request_erc20_tokens'.format(os.environ['FAUCET_RPC_PORT']) + data = '{"wallet": "' + address + '", "amount": 1}' + r = requests.post(url, data=data) + if not r.ok: + print('Response:', r.status_code) + assert(r.ok) @classmethod def tearDownClass(cls): url = 'http://localhost:{}/request_stop'.format(os.environ['FAUCET_RPC_PORT']) data = '{"delay": 1000}' # 1 second - requests.post(url, data=data) + r = requests.post(url, data=data) + if not r.ok: + cls.faucet.terminate with io.TextIOWrapper(cls.faucet.stdout, encoding="utf-8") as out: for line in out: print(line.strip()) From 059f655d01e92415583f868a6f36732512260b16 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Thu, 23 Sep 2021 19:02:07 +0300 Subject: [PATCH 10/22] Deploy 2 ERC20 tokens (166-faucet) --- proxy/test_neon_faucet.py | 171 +++++++++++++++++++++++++++++++++++--- 1 file changed, 159 insertions(+), 12 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index 8ff5dfd57..ad04c9ac2 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -8,30 +8,174 @@ import subprocess import requests from web3 import Web3 +from solcx import install_solc +install_solc(version='0.8.7') +from solcx import compile_source +EXTRA_GAS = int(os.environ.get("EXTRA_GAS", "100000")) proxy_url = os.environ.get('PROXY_URL', 'http://localhost:9090/solana') proxy = Web3(Web3.HTTPProvider(proxy_url)) +admin = proxy.eth.account.create('issues/neonlabsorg/neon-evm/166/admin') +user = proxy.eth.account.create('issues/neonlabsorg/neon-evm/166/user') +proxy.eth.default_account = admin.address + +ERC20_CONTRACT_SOURCE = ''' +pragma solidity >=0.8.0; +// ---------------------------------------------------------------------------- +// Safe maths +// ---------------------------------------------------------------------------- +contract SafeMath { + function safeAdd(uint a, uint b) public pure returns (uint c) { + c = a + b; + require(c >= a); + } + function safeSub(uint a, uint b) public pure returns (uint c) { + require(b <= a); + c = a - b; + } +} +// ---------------------------------------------------------------------------- +// ERC Token Standard #20 Interface +// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md +// ---------------------------------------------------------------------------- +abstract contract ERC20Interface { + function totalSupply() virtual public view returns (uint); + function balanceOf(address tokenOwner) virtual public view returns (uint balance); + function allowance(address tokenOwner, address spender) virtual public view returns (uint remaining); + function transfer(address to, uint tokens) virtual public returns (bool success); + function approve(address spender, uint tokens) virtual public returns (bool success); + function transferFrom(address from, address to, uint tokens) virtual public returns (bool success); + event Transfer(address indexed from, address indexed to, uint tokens); + event Approval(address indexed tokenOwner, address indexed spender, uint tokens); +} +// ---------------------------------------------------------------------------- +// ERC20 Token, with the addition of symbol, name and decimals +// assisted token transfers +// ---------------------------------------------------------------------------- +contract N47Token is ERC20Interface, SafeMath { + string public symbol; + string public name; + uint8 public decimals; + uint public _totalSupply; + mapping(address => uint) balances; + mapping(address => mapping(address => uint)) allowed; + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + constructor() { + symbol = "TST"; + name = "TestToken"; + decimals = 18; + _totalSupply = 10000000000000000000000000000; + balances[msg.sender] = _totalSupply; + emit Transfer(address(0), msg.sender, _totalSupply); + } + // ------------------------------------------------------------------------ + // Total supply + // ------------------------------------------------------------------------ + function totalSupply() public override view returns (uint) { + return _totalSupply - balances[address(0)]; + } + // ------------------------------------------------------------------------ + // Get the token balance for account tokenOwner + // ------------------------------------------------------------------------ + function balanceOf(address tokenOwner) public override view returns (uint balance) { + return balances[tokenOwner]; + } + // ------------------------------------------------------------------------ + // Transfer the balance from token owner's account to receiver account + // - Owner's account must have sufficient balance to transfer + // - 0 value transfers are allowed + // ------------------------------------------------------------------------ + function transfer(address receiver, uint tokens) public override returns (bool success) { + balances[msg.sender] = safeSub(balances[msg.sender], tokens); + balances[receiver] = safeAdd(balances[receiver], tokens); + emit Transfer(msg.sender, receiver, tokens); + return true; + } + // ------------------------------------------------------------------------ + // Token owner can approve for spender to transferFrom(...) tokens + // from the token owner's account + // + // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md + // recommends that there are no checks for the approval double-spend attack + // as this should be implemented in user interfaces + // ------------------------------------------------------------------------ + function approve(address spender, uint tokens) public override returns (bool success) { + allowed[msg.sender][spender] = tokens; + emit Approval(msg.sender, spender, tokens); + return true; + } + // ------------------------------------------------------------------------ + // Transfer tokens from sender account to receiver account + // + // The calling account must already have sufficient tokens approve(...)-d + // for spending from sender account and + // - From account must have sufficient balance to transfer + // - Spender must have sufficient allowance to transfer + // - 0 value transfers are allowed + // ------------------------------------------------------------------------ + function transferFrom(address sender, address receiver, uint tokens) public override returns (bool success) { + balances[sender] = safeSub(balances[sender], tokens); + allowed[sender][msg.sender] = safeSub(allowed[sender][msg.sender], tokens); + balances[receiver] = safeAdd(balances[receiver], tokens); + emit Transfer(sender, receiver, tokens); + return true; + } + // ------------------------------------------------------------------------ + // Returns the amount of tokens approved by the owner that can be + // transferred to the spender's account + // ------------------------------------------------------------------------ + function allowance(address tokenOwner, address spender) public override view returns (uint remaining) { + return allowed[tokenOwner][spender]; + } +} +''' class Test_Neon_Faucet(unittest.TestCase): @classmethod def setUpClass(cls): + cls.compile_erc20_contract(cls) + token_a = cls.deploy_erc20_token(cls) + token_b = cls.deploy_erc20_token(cls) + cls.start_faucet(cls, token_a, token_b) + print('Sleeping 1 sec...') + time.sleep(1) + + def compile_erc20_contract(self): + compiled_contract = compile_source(ERC20_CONTRACT_SOURCE) + contract_id, contract_interface = compiled_contract.popitem() + self.contract = contract_interface + + def deploy_erc20_token(self): + erc20 = proxy.eth.contract(abi=self.contract['abi'], bytecode=self.contract['bin']) + nonce = proxy.eth.get_transaction_count(proxy.eth.default_account) + tx = {'nonce': nonce} + tx_constructor = erc20.constructor().buildTransaction(tx) + tx_deploy = proxy.eth.account.sign_transaction(tx_constructor, admin.key) + tx_deploy_hash = proxy.eth.send_raw_transaction(tx_deploy.rawTransaction) + print('tx_deploy_hash:', tx_deploy_hash.hex()) + tx_deploy_receipt = proxy.eth.wait_for_transaction_receipt(tx_deploy_hash) + print('tx_deploy_receipt:', tx_deploy_receipt) + print('deploy status:', tx_deploy_receipt.status) + return tx_deploy_receipt.contractAddress + + def start_faucet(self, token_a, token_b): os.environ['FAUCET_RPC_PORT'] = '3333' os.environ['FAUCET_RPC_ALLOWED_ORIGINS'] = 'http://localhost' os.environ['FAUCET_WEB3_ENABLE'] = 'true' os.environ['WEB3_RPC_URL'] = proxy_url - os.environ['WEB3_PRIVATE_KEY'] = '0x0000000000000000000000000000000000000000000000000000000000000Ace' - os.environ['NEON_ERC20_TOKENS'] = '0x00000000000000000000000000000000CafeBabe, 0x00000000000000000000000000000000DeadBeef' + os.environ['WEB3_PRIVATE_KEY'] = proxy.eth.default_account + os.environ['NEON_ERC20_TOKENS'] = token_a + ',' + token_b os.environ['NEON_ERC20_MAX_AMOUNT'] = '1000' os.environ['FAUCET_SOLANA_ENABLE'] = 'true' - os.environ['SOLANA_URL'] = 'http://solana:8899' - os.environ['EVM_LOADER'] = '53DfF883gyixYNXnM7s5xhdeyV8mVk9T4i2hGV9vG9io' + os.environ['SOLANA_URL'] = os.environ.get('SOLANA_URL', 'http://solana:8899') + os.environ['EVM_LOADER'] = os.environ.get('EVM_LOADER', '53DfF883gyixYNXnM7s5xhdeyV8mVk9T4i2hGV9vG9io') os.environ['NEON_TOKEN_MINT'] = 'HPsV9Deocecw3GeZv1FkAPNCBRfuVyfw9MMwjwRe1xaU' os.environ['NEON_TOKEN_MINT_DECIMALS'] = '9' os.environ['NEON_OPERATOR_KEYFILE'] = '/root/.config/solana/id.json' os.environ['NEON_ETH_MAX_AMOUNT'] = '10' - cls.faucet = subprocess.Popen(['faucet', 'run', '--workers', '1'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - print('Sleeping 1 sec...') - time.sleep(1) # 1 second + self.faucet = subprocess.Popen(['faucet', 'run', '--workers', '1'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) @unittest.skip("a.i.") def test_eth_token(self): @@ -49,7 +193,7 @@ def test_eth_token(self): print('balance_after:', balance_after) self.assertEqual(balance_after - balance_before, 1000000000000000000) - # @unittest.skip("a.i.") + @unittest.skip("a.i.") def test_erc20_tokens(self): print() address = '0x1111111111111111111111111111111111111111' @@ -60,16 +204,19 @@ def test_erc20_tokens(self): print('Response:', r.status_code) assert(r.ok) - @classmethod - def tearDownClass(cls): + def stop_faucet(self): url = 'http://localhost:{}/request_stop'.format(os.environ['FAUCET_RPC_PORT']) data = '{"delay": 1000}' # 1 second r = requests.post(url, data=data) if not r.ok: - cls.faucet.terminate - with io.TextIOWrapper(cls.faucet.stdout, encoding="utf-8") as out: + self.faucet.terminate + with io.TextIOWrapper(self.faucet.stdout, encoding="utf-8") as out: for line in out: print(line.strip()) + @classmethod + def tearDownClass(cls): + cls.stop_faucet(cls) + if __name__ == '__main__': unittest.main() From 8433595d1702f76097a7463955de63953c11cc06 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Thu, 23 Sep 2021 19:37:29 +0300 Subject: [PATCH 11/22] Refactoring (166-faucet) --- proxy/test_neon_faucet.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index ad04c9ac2..3a8043e65 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -20,6 +20,7 @@ proxy.eth.default_account = admin.address ERC20_CONTRACT_SOURCE = ''' +// SPDX-License-Identifier: MIT pragma solidity >=0.8.0; // ---------------------------------------------------------------------------- // Safe maths @@ -52,7 +53,7 @@ // ERC20 Token, with the addition of symbol, name and decimals // assisted token transfers // ---------------------------------------------------------------------------- -contract N47Token is ERC20Interface, SafeMath { +contract TestToken is ERC20Interface, SafeMath { string public symbol; string public name; uint8 public decimals; @@ -136,28 +137,27 @@ class Test_Neon_Faucet(unittest.TestCase): @classmethod def setUpClass(cls): cls.compile_erc20_contract(cls) - token_a = cls.deploy_erc20_token(cls) - token_b = cls.deploy_erc20_token(cls) + token_a = cls.deploy_erc20_token(cls, 'A') + token_b = cls.deploy_erc20_token(cls, 'B') cls.start_faucet(cls, token_a, token_b) print('Sleeping 1 sec...') time.sleep(1) def compile_erc20_contract(self): + print('Compiling ERC20 contract...') compiled_contract = compile_source(ERC20_CONTRACT_SOURCE) contract_id, contract_interface = compiled_contract.popitem() self.contract = contract_interface - def deploy_erc20_token(self): + def deploy_erc20_token(self, name): erc20 = proxy.eth.contract(abi=self.contract['abi'], bytecode=self.contract['bin']) nonce = proxy.eth.get_transaction_count(proxy.eth.default_account) tx = {'nonce': nonce} tx_constructor = erc20.constructor().buildTransaction(tx) tx_deploy = proxy.eth.account.sign_transaction(tx_constructor, admin.key) tx_deploy_hash = proxy.eth.send_raw_transaction(tx_deploy.rawTransaction) - print('tx_deploy_hash:', tx_deploy_hash.hex()) tx_deploy_receipt = proxy.eth.wait_for_transaction_receipt(tx_deploy_hash) - print('tx_deploy_receipt:', tx_deploy_receipt) - print('deploy status:', tx_deploy_receipt.status) + print('Token', name, '=', tx_deploy_receipt.contractAddress) return tx_deploy_receipt.contractAddress def start_faucet(self, token_a, token_b): @@ -165,7 +165,7 @@ def start_faucet(self, token_a, token_b): os.environ['FAUCET_RPC_ALLOWED_ORIGINS'] = 'http://localhost' os.environ['FAUCET_WEB3_ENABLE'] = 'true' os.environ['WEB3_RPC_URL'] = proxy_url - os.environ['WEB3_PRIVATE_KEY'] = proxy.eth.default_account + os.environ['WEB3_PRIVATE_KEY'] = admin.key.hex() os.environ['NEON_ERC20_TOKENS'] = token_a + ',' + token_b os.environ['NEON_ERC20_MAX_AMOUNT'] = '1000' os.environ['FAUCET_SOLANA_ENABLE'] = 'true' @@ -193,7 +193,7 @@ def test_eth_token(self): print('balance_after:', balance_after) self.assertEqual(balance_after - balance_before, 1000000000000000000) - @unittest.skip("a.i.") + # @unittest.skip("a.i.") def test_erc20_tokens(self): print() address = '0x1111111111111111111111111111111111111111' From 43dd3b3abc400258344188ca5cc0f32343041db9 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Thu, 23 Sep 2021 20:11:43 +0300 Subject: [PATCH 12/22] Complete test_erc20_tokens (166-faucet) --- proxy/test_neon_faucet.py | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index 3a8043e65..4bda0080e 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -137,9 +137,9 @@ class Test_Neon_Faucet(unittest.TestCase): @classmethod def setUpClass(cls): cls.compile_erc20_contract(cls) - token_a = cls.deploy_erc20_token(cls, 'A') - token_b = cls.deploy_erc20_token(cls, 'B') - cls.start_faucet(cls, token_a, token_b) + cls.token_a = cls.deploy_erc20_token(cls, 'A') + cls.token_b = cls.deploy_erc20_token(cls, 'B') + cls.start_faucet(cls) print('Sleeping 1 sec...') time.sleep(1) @@ -150,6 +150,7 @@ def compile_erc20_contract(self): self.contract = contract_interface def deploy_erc20_token(self, name): + print('Deploying ERC20 token...') erc20 = proxy.eth.contract(abi=self.contract['abi'], bytecode=self.contract['bin']) nonce = proxy.eth.get_transaction_count(proxy.eth.default_account) tx = {'nonce': nonce} @@ -160,13 +161,13 @@ def deploy_erc20_token(self, name): print('Token', name, '=', tx_deploy_receipt.contractAddress) return tx_deploy_receipt.contractAddress - def start_faucet(self, token_a, token_b): + def start_faucet(self): os.environ['FAUCET_RPC_PORT'] = '3333' os.environ['FAUCET_RPC_ALLOWED_ORIGINS'] = 'http://localhost' os.environ['FAUCET_WEB3_ENABLE'] = 'true' os.environ['WEB3_RPC_URL'] = proxy_url os.environ['WEB3_PRIVATE_KEY'] = admin.key.hex() - os.environ['NEON_ERC20_TOKENS'] = token_a + ',' + token_b + os.environ['NEON_ERC20_TOKENS'] = self.token_a + ',' + self.token_b os.environ['NEON_ERC20_MAX_AMOUNT'] = '1000' os.environ['FAUCET_SOLANA_ENABLE'] = 'true' os.environ['SOLANA_URL'] = os.environ.get('SOLANA_URL', 'http://solana:8899') @@ -177,32 +178,40 @@ def start_faucet(self, token_a, token_b): os.environ['NEON_ETH_MAX_AMOUNT'] = '10' self.faucet = subprocess.Popen(['faucet', 'run', '--workers', '1'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - @unittest.skip("a.i.") + # @unittest.skip("a.i.") def test_eth_token(self): print() - address = '0x1111111111111111111111111111111111111111' - balance_before = proxy.eth.get_balance(address) + balance_before = proxy.eth.get_balance(user.address) print('balance_before:', balance_before) url = 'http://localhost:{}/request_eth_token'.format(os.environ['FAUCET_RPC_PORT']) - data = '{"wallet": "' + address + '", "amount": 1}' + data = '{"wallet": "' + user.address + '", "amount": 1}' r = requests.post(url, data=data) if not r.ok: print('Response:', r.status_code) assert(r.ok) - balance_after = proxy.eth.get_balance(address) + balance_after = proxy.eth.get_balance(user.address) print('balance_after:', balance_after) self.assertEqual(balance_after - balance_before, 1000000000000000000) # @unittest.skip("a.i.") def test_erc20_tokens(self): print() - address = '0x1111111111111111111111111111111111111111' + a_before = self.get_token_balance(self.token_a, user.address) + b_before = self.get_token_balance(self.token_b, user.address) url = 'http://localhost:{}/request_erc20_tokens'.format(os.environ['FAUCET_RPC_PORT']) - data = '{"wallet": "' + address + '", "amount": 1}' + data = '{"wallet": "' + user.address + '", "amount": 1}' r = requests.post(url, data=data) if not r.ok: print('Response:', r.status_code) assert(r.ok) + a_after = self.get_token_balance(self.token_a, user.address) + b_after = self.get_token_balance(self.token_b, user.address) + self.assertEqual(a_after - a_before, 1000000000000000000) + self.assertEqual(b_after - b_before, 1000000000000000000) + + def get_token_balance(self, token_address, address): + erc20 = proxy.eth.contract(address=token_address, abi=self.contract['abi']) + return erc20.functions.balanceOf(address).call() def stop_faucet(self): url = 'http://localhost:{}/request_stop'.format(os.environ['FAUCET_RPC_PORT']) From 10f4dc43e4535ac0caa0c673f908f9671c1aabd8 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Thu, 23 Sep 2021 21:27:26 +0300 Subject: [PATCH 13/22] Refactoring (166-faucet) --- proxy/test_neon_faucet.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index 4bda0080e..08d320e28 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -67,7 +67,7 @@ symbol = "TST"; name = "TestToken"; decimals = 18; - _totalSupply = 10000000000000000000000000000; + _totalSupply = 100000000000000000000000000000000000000000; balances[msg.sender] = _totalSupply; emit Transfer(address(0), msg.sender, _totalSupply); } @@ -140,7 +140,6 @@ def setUpClass(cls): cls.token_a = cls.deploy_erc20_token(cls, 'A') cls.token_b = cls.deploy_erc20_token(cls, 'B') cls.start_faucet(cls) - print('Sleeping 1 sec...') time.sleep(1) def compile_erc20_contract(self): @@ -182,7 +181,7 @@ def start_faucet(self): def test_eth_token(self): print() balance_before = proxy.eth.get_balance(user.address) - print('balance_before:', balance_before) + print('NEO balance before:', balance_before) url = 'http://localhost:{}/request_eth_token'.format(os.environ['FAUCET_RPC_PORT']) data = '{"wallet": "' + user.address + '", "amount": 1}' r = requests.post(url, data=data) @@ -190,7 +189,7 @@ def test_eth_token(self): print('Response:', r.status_code) assert(r.ok) balance_after = proxy.eth.get_balance(user.address) - print('balance_after:', balance_after) + print('NEO balance after:', balance_after) self.assertEqual(balance_after - balance_before, 1000000000000000000) # @unittest.skip("a.i.") @@ -198,6 +197,8 @@ def test_erc20_tokens(self): print() a_before = self.get_token_balance(self.token_a, user.address) b_before = self.get_token_balance(self.token_b, user.address) + print('token A balance before:', a_before) + print('token B balance before:', b_before) url = 'http://localhost:{}/request_erc20_tokens'.format(os.environ['FAUCET_RPC_PORT']) data = '{"wallet": "' + user.address + '", "amount": 1}' r = requests.post(url, data=data) @@ -206,6 +207,8 @@ def test_erc20_tokens(self): assert(r.ok) a_after = self.get_token_balance(self.token_a, user.address) b_after = self.get_token_balance(self.token_b, user.address) + print('token A balance after:', a_after) + print('token B balance after:', b_after) self.assertEqual(a_after - a_before, 1000000000000000000) self.assertEqual(b_after - b_before, 1000000000000000000) From 880ccc3ff822508669e5ea7085b137d100563978 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Fri, 24 Sep 2021 08:47:07 +0300 Subject: [PATCH 14/22] Comment out check temporarily (166-faucet) --- proxy/test_neon_faucet.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index 08d320e28..35f8d28f1 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -190,7 +190,8 @@ def test_eth_token(self): assert(r.ok) balance_after = proxy.eth.get_balance(user.address) print('NEO balance after:', balance_after) - self.assertEqual(balance_after - balance_before, 1000000000000000000) + print('NEO balance difference:', balance_after - balance_before) + #self.assertEqual(balance_after - balance_before, 1000000000000000000) # @unittest.skip("a.i.") def test_erc20_tokens(self): From 3a7d4cd0352c339a91076e928a6a0d5e043aba87 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Mon, 27 Sep 2021 16:07:40 +0300 Subject: [PATCH 15/22] Use solc 0.7 (166-faucet) --- proxy/test_neon_faucet.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index 35f8d28f1..8724b4017 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -9,7 +9,7 @@ import requests from web3 import Web3 from solcx import install_solc -install_solc(version='0.8.7') +install_solc(version='0.7.6') from solcx import compile_source EXTRA_GAS = int(os.environ.get("EXTRA_GAS", "100000")) @@ -21,7 +21,7 @@ ERC20_CONTRACT_SOURCE = ''' // SPDX-License-Identifier: MIT -pragma solidity >=0.8.0; +pragma solidity >=0.7.0; // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- @@ -180,6 +180,14 @@ def start_faucet(self): # @unittest.skip("a.i.") def test_eth_token(self): print() + # First request - trigger creation of the account + #url = 'http://localhost:{}/request_eth_token'.format(os.environ['FAUCET_RPC_PORT']) + #data = '{"wallet": "' + user.address + '", "amount": 1}' + #r = requests.post(url, data=data) + #if not r.ok: + # print('Response:', r.status_code) + #assert(r.ok) + # Second request - actual test balance_before = proxy.eth.get_balance(user.address) print('NEO balance before:', balance_before) url = 'http://localhost:{}/request_eth_token'.format(os.environ['FAUCET_RPC_PORT']) @@ -191,9 +199,9 @@ def test_eth_token(self): balance_after = proxy.eth.get_balance(user.address) print('NEO balance after:', balance_after) print('NEO balance difference:', balance_after - balance_before) - #self.assertEqual(balance_after - balance_before, 1000000000000000000) + self.assertEqual(balance_after - balance_before, 1000000000000000000) - # @unittest.skip("a.i.") + @unittest.skip("a.i.") def test_erc20_tokens(self): print() a_before = self.get_token_balance(self.token_a, user.address) From 141245620c4adb90ffdcc2d19ec8eb7f20e2f95f Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Wed, 29 Sep 2021 08:47:50 +0300 Subject: [PATCH 16/22] Developing (166-faucet) --- proxy/test_neon_faucet.py | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index 8724b4017..bdeb4d7fb 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -100,7 +100,7 @@ // // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20.md // recommends that there are no checks for the approval double-spend attack - // as this should be implemented in user interfaces + // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public override returns (bool success) { allowed[msg.sender][spender] = tokens; @@ -109,7 +109,7 @@ } // ------------------------------------------------------------------------ // Transfer tokens from sender account to receiver account - // + // // The calling account must already have sufficient tokens approve(...)-d // for spending from sender account and // - From account must have sufficient balance to transfer @@ -181,12 +181,12 @@ def start_faucet(self): def test_eth_token(self): print() # First request - trigger creation of the account - #url = 'http://localhost:{}/request_eth_token'.format(os.environ['FAUCET_RPC_PORT']) - #data = '{"wallet": "' + user.address + '", "amount": 1}' - #r = requests.post(url, data=data) - #if not r.ok: - # print('Response:', r.status_code) - #assert(r.ok) + url = 'http://localhost:{}/request_eth_token'.format(os.environ['FAUCET_RPC_PORT']) + data = '{"wallet": "' + user.address + '", "amount": 1}' + r = requests.post(url, data=data) + if not r.ok: + print('Response:', r.status_code) + assert(r.ok) # Second request - actual test balance_before = proxy.eth.get_balance(user.address) print('NEO balance before:', balance_before) @@ -196,6 +196,7 @@ def test_eth_token(self): if not r.ok: print('Response:', r.status_code) assert(r.ok) + # Check balance_after = proxy.eth.get_balance(user.address) print('NEO balance after:', balance_after) print('NEO balance difference:', balance_after - balance_before) From 65a12280cfa12614914f4b9d2e215877768782ea Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Wed, 29 Sep 2021 09:11:21 +0300 Subject: [PATCH 17/22] Enable all tests (166-faucet) --- proxy/test_neon_faucet.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index bdeb4d7fb..7fac57caa 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -180,9 +180,9 @@ def start_faucet(self): # @unittest.skip("a.i.") def test_eth_token(self): print() - # First request - trigger creation of the account + # First request - trigger creation of the account without real transfer url = 'http://localhost:{}/request_eth_token'.format(os.environ['FAUCET_RPC_PORT']) - data = '{"wallet": "' + user.address + '", "amount": 1}' + data = '{"wallet": "' + user.address + '", "amount": 0}' r = requests.post(url, data=data) if not r.ok: print('Response:', r.status_code) @@ -202,7 +202,7 @@ def test_eth_token(self): print('NEO balance difference:', balance_after - balance_before) self.assertEqual(balance_after - balance_before, 1000000000000000000) - @unittest.skip("a.i.") + # @unittest.skip("a.i.") def test_erc20_tokens(self): print() a_before = self.get_token_balance(self.token_a, user.address) From 5da9bb8a44a58c3da48b82b134d0ff63392fc5ef Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Wed, 29 Sep 2021 10:51:13 +0300 Subject: [PATCH 18/22] Copy faucet to /spl/bin (166-faucet) --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 8904dfcc1..a73aa669e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -32,7 +32,7 @@ COPY --from=cli /opt/solana/bin/solana \ COPY --from=spl /opt/solana/bin/solana /cli/bin/ COPY --from=spl /opt/evm_loader.so /opt/evm_loader-keypair.json \ - /opt/neon-cli /spl/bin/ + /opt/neon-cli /opt/faucet /spl/bin/ COPY --from=spl /opt/spl-token /opt/test_token_keypair /opt/test_token_owner /spl/bin/ COPY --from=spl /opt/collateral_pool_generator.py \ /opt/solana_utils.py \ From db0e4d0bbbcbae41a646167776dabf6d6ecf6605 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Wed, 29 Sep 2021 11:13:07 +0300 Subject: [PATCH 19/22] Refactoring (166-faucet) --- proxy/test_neon_faucet.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index 7fac57caa..00be0037d 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -12,11 +12,12 @@ install_solc(version='0.7.6') from solcx import compile_source +issue = 'https://github.com/neonlabsorg/neon-evm/issues/166' EXTRA_GAS = int(os.environ.get("EXTRA_GAS", "100000")) proxy_url = os.environ.get('PROXY_URL', 'http://localhost:9090/solana') proxy = Web3(Web3.HTTPProvider(proxy_url)) -admin = proxy.eth.account.create('issues/neonlabsorg/neon-evm/166/admin') -user = proxy.eth.account.create('issues/neonlabsorg/neon-evm/166/user') +admin = proxy.eth.account.create(issue + '/admin') +user = proxy.eth.account.create(issue + '/user') proxy.eth.default_account = admin.address ERC20_CONTRACT_SOURCE = ''' @@ -136,6 +137,7 @@ class Test_Neon_Faucet(unittest.TestCase): @classmethod def setUpClass(cls): + print('\n\n' + issue) cls.compile_erc20_contract(cls) cls.token_a = cls.deploy_erc20_token(cls, 'A') cls.token_b = cls.deploy_erc20_token(cls, 'B') From 80be91429924818fba286c5eb88e6a26397842f7 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Wed, 29 Sep 2021 11:21:27 +0300 Subject: [PATCH 20/22] Refactoring (166-faucet) --- proxy/test_neon_faucet.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index 00be0037d..4d0371de4 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -180,7 +180,7 @@ def start_faucet(self): self.faucet = subprocess.Popen(['faucet', 'run', '--workers', '1'], stdout=subprocess.PIPE, stderr=subprocess.STDOUT) # @unittest.skip("a.i.") - def test_eth_token(self): + def test_neon_faucet_01_eth_token(self): print() # First request - trigger creation of the account without real transfer url = 'http://localhost:{}/request_eth_token'.format(os.environ['FAUCET_RPC_PORT']) @@ -205,7 +205,7 @@ def test_eth_token(self): self.assertEqual(balance_after - balance_before, 1000000000000000000) # @unittest.skip("a.i.") - def test_erc20_tokens(self): + def test_neon_faucet_02_erc20_tokens(self): print() a_before = self.get_token_balance(self.token_a, user.address) b_before = self.get_token_balance(self.token_b, user.address) From 2907cb8ccbef0c7e765d8e29791621b1b090dd9b Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Thu, 30 Sep 2021 11:01:15 +0300 Subject: [PATCH 21/22] Remove unneeded variable (166-faucet) --- proxy/test_neon_faucet.py | 1 - 1 file changed, 1 deletion(-) diff --git a/proxy/test_neon_faucet.py b/proxy/test_neon_faucet.py index 4d0371de4..8a82b7eea 100644 --- a/proxy/test_neon_faucet.py +++ b/proxy/test_neon_faucet.py @@ -13,7 +13,6 @@ from solcx import compile_source issue = 'https://github.com/neonlabsorg/neon-evm/issues/166' -EXTRA_GAS = int(os.environ.get("EXTRA_GAS", "100000")) proxy_url = os.environ.get('PROXY_URL', 'http://localhost:9090/solana') proxy = Web3(Web3.HTTPProvider(proxy_url)) admin = proxy.eth.account.create(issue + '/admin') From 340325e929c890366599d9f2dba2469d3d747de2 Mon Sep 17 00:00:00 2001 From: Vasily Kondratyev Date: Thu, 30 Sep 2021 19:16:15 +0300 Subject: [PATCH 22/22] Remove unneeded ports (166-faucet) --- proxy/docker-compose-test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/proxy/docker-compose-test.yml b/proxy/docker-compose-test.yml index fc1a28e7f..294a16dda 100644 --- a/proxy/docker-compose-test.yml +++ b/proxy/docker-compose-test.yml @@ -25,8 +25,6 @@ services: hostname: proxy ports: - 127.0.0.1:9090:9090 - - 127.0.0.1:8899:8899 - - 127.0.0.1:3333:3333 expose: - "9090" networks: