Add test for duplicates, but eth_tester does not detect :/

This commit is contained in:
nolash
2020-11-16 19:19:13 +01:00
parent a8ed83dde4
commit 3c4992fbbb
5 changed files with 32 additions and 4 deletions

View File

@@ -1,12 +1,16 @@
import os
import unittest
import json
import logging
import web3
import eth_tester
from eth_accounts_index import AccountRegistry
logging.basicConfig(level=logging.DEBUG)
logg = logging.getLogger()
testdir = os.path.dirname(__file__)
@@ -26,8 +30,8 @@ class Test(unittest.TestCase):
f.close()
backend = eth_tester.PyEVMBackend(eth_params)
self.eth_tester = instance = eth_tester.EthereumTester(backend)
provider = web3.Web3.EthereumTesterProvider(instance)
self.eth_tester = eth_tester.EthereumTester(backend)
provider = web3.Web3.EthereumTesterProvider(self.eth_tester)
self.w3 = web3.Web3(provider)
c = self.w3.eth.contract(abi=abi, bytecode=bytecode)
tx_hash = c.constructor().transact({'from': self.w3.eth.accounts[0]})
@@ -82,6 +86,18 @@ class Test(unittest.TestCase):
self.assertFalse(registry.have(self.w3.eth.accounts[3]))
def test_no_duplicates(self):
registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1])
tx_hash = registry.add(self.w3.eth.accounts[2])
self.eth_tester.mine_block()
tx_hash = registry.add(self.w3.eth.accounts[3])
self.eth_tester.mine_block()
# BUG: eth_tester does not detect the duplicate here, but does in the test.py file in the solidity folder
#self.assertRaises(Exception):
tx_hash = registry.add(self.w3.eth.accounts[2])
self.eth_tester.mine_block()
def test_list(self):
registry = AccountRegistry(self.w3, self.address, self.w3.eth.accounts[1])