@@ -29,9 +29,10 @@ def math_contract(web3, MATH_ABI, MATH_CODE, MATH_RUNTIME, address_conversion_fu
29
29
bytecode_runtime = MATH_RUNTIME ,
30
30
ContractFactoryClass = ImplicitContract ,
31
31
)
32
- contract = MathContract (math_address )
33
- assert contract .address == math_address
34
- return contract
32
+ with pytest .warns (DeprecationWarning , match = 'deprecated in favor of contract.caller' ):
33
+ contract = MathContract (math_address )
34
+ assert contract .address == math_address
35
+ return contract
35
36
36
37
37
38
@pytest .fixture ()
@@ -51,7 +52,8 @@ def get_transaction_count(blocknum_or_label):
51
52
def test_implicitcontract_call_default (math_contract , get_transaction_count ):
52
53
# When a function is called that defaults to call
53
54
blocknum , starting_txns = get_transaction_count ("pending" )
54
- start_count = math_contract .counter ()
55
+ with pytest .warns (DeprecationWarning , match = 'deprecated in favor of classic contract syntax' ):
56
+ start_count = math_contract .counter ()
55
57
assert is_integer (start_count )
56
58
# Check that a call was made and not a transact
57
59
# (Auto-mining is enabled, so query by block number)
@@ -62,13 +64,19 @@ def test_implicitcontract_call_default(math_contract, get_transaction_count):
62
64
63
65
def test_implicitcontract_transact_default (web3 , math_contract , get_transaction_count ):
64
66
# Use to verify correct operation later on
65
- start_count = math_contract .counter ()
67
+ with pytest .warns (DeprecationWarning , match = 'deprecated in favor of classic contract syntax' ):
68
+ start_count = math_contract .counter ()
69
+
66
70
assert is_integer (start_count ) # Verify correct type
67
71
# When a function is called that defaults to transact
68
72
blocknum , starting_txns = get_transaction_count ("pending" )
69
- math_contract .increment (transact = {})
70
- # Check that a transaction was made and not a call
71
- assert math_contract .counter () - start_count == 1
73
+ with pytest .warns (DeprecationWarning ,
74
+ match = 'deprecated in favor of classic contract syntax' ) as warnings :
75
+ math_contract .increment (transact = {})
76
+ # Check that a transaction was made and not a call
77
+ assert math_contract .counter () - start_count == 1
78
+ # Check that the correct number of warnings are raised
79
+ assert len (warnings ) == 2
72
80
# (Auto-mining is enabled, so query by block number)
73
81
assert get_transaction_count (blocknum ) == starting_txns + 1
74
82
# Check that only one block was mined
@@ -78,7 +86,8 @@ def test_implicitcontract_transact_default(web3, math_contract, get_transaction_
78
86
def test_implicitcontract_call_override (math_contract , get_transaction_count ):
79
87
# When a function is called with transact override that defaults to call
80
88
blocknum , starting_txns = get_transaction_count ("pending" )
81
- math_contract .counter (transact = {})
89
+ with pytest .warns (DeprecationWarning , match = 'deprecated in favor of classic contract syntax' ):
90
+ math_contract .counter (transact = {})
82
91
# Check that a transaction was made and not a call
83
92
# (Auto-mining is enabled, so query by block number)
84
93
assert get_transaction_count (blocknum ) == starting_txns + 1
@@ -88,19 +97,23 @@ def test_implicitcontract_call_override(math_contract, get_transaction_count):
88
97
89
98
def test_implicitcontract_transact_override (math_contract , get_transaction_count ):
90
99
# Use to verify correct operation later on
91
- start_count = math_contract .counter ()
100
+ with pytest .warns (DeprecationWarning , match = 'deprecated in favor of classic contract syntax' ):
101
+ start_count = math_contract .counter ()
92
102
assert is_integer (start_count ) # Verify correct type
93
103
# When a function is called with call override that defaults to transact
94
104
blocknum , starting_txns = get_transaction_count ("pending" )
95
- math_contract .increment (call = {})
96
- # Check that a call was made and not a transact
97
- assert math_contract .counter () - start_count == 0
105
+ with pytest .warns (DeprecationWarning ,
106
+ match = 'deprecated in favor of classic contract syntax' ) as warnings :
107
+ math_contract .increment (call = {})
108
+ # Check that a call was made and not a transact
109
+ assert math_contract .counter () - start_count == 0
110
+ assert len (warnings ) == 2
98
111
# (Auto-mining is enabled, so query by block number)
99
112
assert get_transaction_count (blocknum ) == starting_txns
100
113
# Check that no blocks were mined
101
114
assert get_transaction_count ("pending" ) == (blocknum , 0 )
102
115
103
116
104
117
def test_implicitcontract_deprecation_warning (math_contract ):
105
- with pytest .warns (DeprecationWarning ):
118
+ with pytest .warns (DeprecationWarning , match = 'deprecated in favor of classic contract syntax' ):
106
119
math_contract .counter (transact = {})
0 commit comments