1414 networkDefaultProofOfWorkNonceTrialsPerByte ,
1515 networkDefaultPayloadLengthExtraBytes )
1616
17+ from .partial import TestPartialRun
1718from .samples import sample_pow_target , sample_pow_initial_hash
1819
1920default_ttl = 7200
2021
2122
22- class TestProofofworkBase (unittest . TestCase ):
23+ class TestProofofworkBase (TestPartialRun ):
2324 """Basic test case for proofofwork"""
2425
2526 @classmethod
2627 def setUpClass (cls ):
2728 proofofwork .init ()
29+ super (TestProofofworkBase , cls ).setUpClass ()
30+
31+ def setUp (self ):
32+ self .state .shutdown = 0
2833
2934 @staticmethod
3035 def _make_sample_payload (TTL = default_ttl ):
@@ -43,14 +48,6 @@ def test_calculate(self):
4348class TestProofofwork (TestProofofworkBase ):
4449 """The main test case for proofofwork"""
4550
46- @classmethod
47- def tearDownClass (cls ):
48- import state
49- state .shutdown = 0
50-
51- def setUp (self ):
52- self .tearDownClass ()
53-
5451 def _make_sample_data (self ):
5552 payload = self ._make_sample_payload ()
5653 return payload , proofofwork .getTarget (
@@ -70,10 +67,8 @@ def test_calculate(self):
7067 pack ('>Q' , nonce ) + payload , 2000 , 2000 ,
7168 int (time .time ()) + TTL - 3600 ))
7269
73- import state
74-
7570 with self .assertRaises (StopIteration ):
76- state .shutdown = 1
71+ self . state .shutdown = 1
7772 proofofwork .calculate (payload , TTL )
7873
7974 def test_CPoW (self ):
0 commit comments