Browse Source

test.py ethdev: auto-use precompiled contract data if solc not available

The MMGen Project 5 years ago
parent
commit
3d9bcd7876

+ 0 - 0
test/ref/ethereum/bin/mm1/ERC20Interface.bin


+ 1 - 0
test/ref/ethereum/bin/mm1/Owned.bin

@@ -0,0 +1 @@
+608060405234801561001057600080fd5b5060008054600160a060020a031916331790556101e1806100326000396000f3fe608060405234801561001057600080fd5b5060043610610068577c0100000000000000000000000000000000000000000000000000000000600035046379ba5097811461006d5780638da5cb5b14610077578063d4ee1d901461009b578063f2fde38b146100a3575b600080fd5b6100756100c9565b005b61007f610151565b60408051600160a060020a039092168252519081900360200190f35b61007f610160565b610075600480360360208110156100b957600080fd5b5035600160a060020a031661016f565b600154600160a060020a031633146100e057600080fd5b60015460008054604051600160a060020a0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031681565b600154600160a060020a031681565b600054600160a060020a0316331461018657600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039290921691909117905556fea165627a7a72305820e7f664519bd1791f866d95a52ea79ff5ee25c0090774fb96a5426dad45089cdc0029

+ 1 - 0
test/ref/ethereum/bin/mm1/SafeMath.bin

@@ -0,0 +1 @@
+608060405234801561001057600080fd5b506101a8806100206000396000f3fe608060405234801561001057600080fd5b5060043610610068577c01000000000000000000000000000000000000000000000000000000006000350463a293d1e8811461006d578063b5931f7c146100a2578063d05c78da146100c5578063e6cb9013146100e8575b600080fd5b6100906004803603604081101561008357600080fd5b508035906020013561010b565b60408051918252519081900360200190f35b610090600480360360408110156100b857600080fd5b5080359060200135610120565b610090600480360360408110156100db57600080fd5b5080359060200135610141565b610090600480360360408110156100fe57600080fd5b508035906020013561016c565b60008282111561011a57600080fd5b50900390565b600080821161012e57600080fd5b818381151561013957fe5b049392505050565b81810282158061015b575081838281151561015857fe5b04145b151561016657600080fd5b92915050565b8181018281101561016657600080fdfea165627a7a723058200ba26a79dc73f8668c347ba0864d0abd8f0735855f58b4d26dbe3d1ed03d68120029

File diff suppressed because it is too large
+ 0 - 0
test/ref/ethereum/bin/mm1/Token.bin


+ 0 - 0
test/ref/ethereum/bin/mm2/ERC20Interface.bin


+ 1 - 0
test/ref/ethereum/bin/mm2/Owned.bin

@@ -0,0 +1 @@
+608060405234801561001057600080fd5b5060008054600160a060020a031916331790556101e1806100326000396000f3fe608060405234801561001057600080fd5b5060043610610068577c0100000000000000000000000000000000000000000000000000000000600035046379ba5097811461006d5780638da5cb5b14610077578063d4ee1d901461009b578063f2fde38b146100a3575b600080fd5b6100756100c9565b005b61007f610151565b60408051600160a060020a039092168252519081900360200190f35b61007f610160565b610075600480360360208110156100b957600080fd5b5035600160a060020a031661016f565b600154600160a060020a031633146100e057600080fd5b60015460008054604051600160a060020a0393841693909116917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e091a3600180546000805473ffffffffffffffffffffffffffffffffffffffff19908116600160a060020a03841617909155169055565b600054600160a060020a031681565b600154600160a060020a031681565b600054600160a060020a0316331461018657600080fd5b6001805473ffffffffffffffffffffffffffffffffffffffff1916600160a060020a039290921691909117905556fea165627a7a723058205c423983189f5e4a8cef05984b44684791f408081e1c0c11db5d827d9aec51900029

+ 1 - 0
test/ref/ethereum/bin/mm2/SafeMath.bin

@@ -0,0 +1 @@
+608060405234801561001057600080fd5b506101a8806100206000396000f3fe608060405234801561001057600080fd5b5060043610610068577c01000000000000000000000000000000000000000000000000000000006000350463a293d1e8811461006d578063b5931f7c146100a2578063d05c78da146100c5578063e6cb9013146100e8575b600080fd5b6100906004803603604081101561008357600080fd5b508035906020013561010b565b60408051918252519081900360200190f35b610090600480360360408110156100b857600080fd5b5080359060200135610120565b610090600480360360408110156100db57600080fd5b5080359060200135610141565b610090600480360360408110156100fe57600080fd5b508035906020013561016c565b60008282111561011a57600080fd5b50900390565b600080821161012e57600080fd5b818381151561013957fe5b049392505050565b81810282158061015b575081838281151561015857fe5b04145b151561016657600080fd5b92915050565b8181018281101561016657600080fdfea165627a7a72305820eb50b147fd9c750227f1de52fa6c0f0287cea771f796a17e7058a0bb51246a6f0029

File diff suppressed because it is too large
+ 0 - 0
test/ref/ethereum/bin/mm2/Token.bin


+ 1 - 0
test/test.py

@@ -597,6 +597,7 @@ class TestSuiteRunner(object):
 		from collections import OrderedDict
 		from collections import OrderedDict
 		self.rebuild_list = OrderedDict()
 		self.rebuild_list = OrderedDict()
 		self.gm = CmdGroupMgr()
 		self.gm = CmdGroupMgr()
+		self.repo_root = repo_root
 
 
 		if opt.log:
 		if opt.log:
 			self.log_fd = open(log_file,'a')
 			self.log_fd = open(log_file,'a')

+ 28 - 20
test/test_py_d/ts_ethdev.py

@@ -46,19 +46,26 @@ parity_pid_fn = 'parity.pid'
 parity_key_fn = 'parity.devkey'
 parity_key_fn = 'parity.devkey'
 
 
 # Token sends require varying amounts of gas, depending on compiler version
 # Token sends require varying amounts of gas, depending on compiler version
-try:
-	cmd_out = run(['solc','--version'],stdout=PIPE).stdout.decode()
-	solc_ver = re.search(r'Version:\s*(.*)',cmd_out).group(1)
-except:
-	solc_ver = '' # no solc on system - prompt for precompiled v0.5.3 contract files
+def get_solc_ver():
+	try: cp = run(['solc','--version'],stdout=PIPE)
+	except: return None
 
 
-if re.match(r'\b0.5.1\b',solc_ver): # Raspbian Stretch
+	if cp.returncode:
+		return None
+
+	line = cp.stdout.decode().splitlines()[1]
+	m = re.search(r'Version:\s*(\d+)\.(\d+)\.(\d+)',line)
+	return '.'.join(m.groups()) if m else None
+
+solc_ver = get_solc_ver()
+
+if solc_ver == '0.5.1':
 	vbal1 = '1.2288337'
 	vbal1 = '1.2288337'
 	vbal1a = 'TODO'
 	vbal1a = 'TODO'
 	vbal2 = '99.997085083'
 	vbal2 = '99.997085083'
 	vbal3 = '1.23142165'
 	vbal3 = '1.23142165'
 	vbal4 = '127.0287837'
 	vbal4 = '127.0287837'
-elif solc_ver == '' or re.match(r'\b0.5.3\b',solc_ver): # Ubuntu Bionic
+else: # 0.5.3 or precompiled 0.5.3
 	vbal1 = '1.2288487'
 	vbal1 = '1.2288487'
 	vbal1a = '1.22627465'
 	vbal1a = '1.22627465'
 	vbal2 = '99.997092733'
 	vbal2 = '99.997092733'
@@ -133,6 +140,7 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
 	networks = ('eth','etc')
 	networks = ('eth','etc')
 	passthru_opts = ('coin',)
 	passthru_opts = ('coin',)
 	tmpdir_nums = [22]
 	tmpdir_nums = [22]
+	solc_vers = ('0.5.1','0.5.3') # 0.5.1: Raspbian Stretch, 0.5.3: Ubuntu Bionic
 	cmd_group = (
 	cmd_group = (
 		('setup',               'Ethereum Parity dev mode tests for coin {} (start parity)'.format(g.coin)),
 		('setup',               'Ethereum Parity dev mode tests for coin {} (start parity)'.format(g.coin)),
 		('wallet_upgrade1',     'upgrading the tracking wallet (v1 -> v2)'),
 		('wallet_upgrade1',     'upgrading the tracking wallet (v1 -> v2)'),
@@ -302,10 +310,16 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
 
 
 	def setup(self):
 	def setup(self):
 		self.spawn('',msg_only=True)
 		self.spawn('',msg_only=True)
-		if g.platform == 'win':
-			m1 = 'Please copy precompiled contract data to {d}/mm1 and {d}/mm2\n'.format(d=self.tmpdir)
-			m2 = '\nPress ENTER to continue: '
-			my_raw_input(m1+m2)
+		if solc_ver in self.solc_vers:
+			imsg('Found solc version {}'.format(solc_ver))
+		else:
+			imsg('Solc compiler {}. Using precompiled contract data'.format(
+				'version {} not supported by test suite'.format(solc_ver)
+				if solc_ver else 'not found' ))
+			srcdir = os.path.join(self.tr.repo_root,'test','ref','ethereum','bin')
+			from shutil import copytree
+			for d in ('mm1','mm2'):
+				copytree(os.path.join(srcdir,d),os.path.join(self.tmpdir,d))
 		start_test_daemons(g.coin)
 		start_test_daemons(g.coin)
 		return 'ok'
 		return 'ok'
 
 
@@ -535,15 +549,9 @@ class TestSuiteEthdev(TestSuiteBase,TestSuiteShared):
 
 
 	def token_compile(self,token_data={}):
 	def token_compile(self,token_data={}):
 		odir = joinpath(self.tmpdir,token_data['symbol'].lower())
 		odir = joinpath(self.tmpdir,token_data['symbol'].lower())
-		if self.skip_for_win():
-			try:
-				os.stat(os.path.join(odir,'Token.bin'))
-			except:
-				m ='Copy solc v0.5.3 contract data for token {} to directory {} and hit ENTER: '
-				input(m.format(token_data['symbol'],odir))
-			else:
-				msg('Using precompiled contract data in {}'.format(odir))
-			return 'skip'
+		if not solc_ver:
+			imsg('Using precompiled contract data in {}'.format(odir))
+			return 'skip' if os.path.exists(odir) else False
 		self.spawn('',msg_only=True)
 		self.spawn('',msg_only=True)
 		cmd_args = ['--{}={}'.format(k,v) for k,v in list(token_data.items())]
 		cmd_args = ['--{}={}'.format(k,v) for k,v in list(token_data.items())]
 		imsg("Compiling solidity token contract '{}' with 'solc'".format(token_data['symbol']))
 		imsg("Compiling solidity token contract '{}' with 'solc'".format(token_data['symbol']))

Some files were not shown because too many files changed in this diff